Annotations being rotated for certain landscape documents

760 views
Skip to first unread message

prakhar jaiswal

unread,
Nov 24, 2016, 12:52:30 PM11/24/16
to PDFTron WebViewer
Hi,

We are undergoing 90 degrees rotation of annotations (particularly comment annotation tool and custom stamps) for few documents (have attached one sample). It can be replicated on sample pages as well (local PDF sample - use PDF mode than XOD).
Unlike the viewer, ordinary PDF viewer applications like Acrobat are drawing the annotations properly (un-rotated) - we validated against Acrobat Reader: Build: 15.20.20042.205528.

Thanks

landscape.pdf

Matt Parizeau

unread,
Nov 25, 2016, 3:55:25 PM11/25/16
to PDFTron WebViewer
Hi,

Thanks for the report. Here is a build which fixes the display of comment annotations http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_2.2.1.52847.zip

For your custom stamp annotations you'll need to set the Rotation property when you create them. You can do that using the following code:
stampAnnot.Rotation = readerControl.docViewer.getCompleteRotation(stampAnnot.PageNumber) * 90;

Matt Parizeau
Software Developer
PDFTron Systems Inc.

arpit srivastava

unread,
Nov 29, 2016, 12:42:08 PM11/29/16
to PDFTron WebViewer
Hi Matt,

Thanks for new build patch.Issues got fixed for custom stamp and other annotation on landscape mode.
Hi Matt,

The above patch worked for us for pdf which are in landscape mode.Thanks.

But right now we are facing issue when we drop image for the pdfs which are in landscape mode as the position of Images are getting shifted by some pixels.But that same logic works great for portrait mode.Below is the code snippet which does the job

let origDropEvent = event.originalEvent;
let scrollContainer = $("#DocumentViewer");
let viewportTop = scrollContainer.scrollTop();
let viewportLeft = scrollContainer.scrollLeft();
let clickPosition = {
x: origDropEvent.pageX + viewportLeft,
y: origDropEvent.pageY + viewportTop
};
debugger;
let visiblePages = window.readerControl.docViewer.getDisplayModeManager().getDisplayMode().getVisiblePages();
let pageIndex, viewerCoordinate;
for(var iterator in visiblePages){
pageIndex = visiblePages[iterator];
viewerCoordinate = displayMode.windowToPage(clickPosition, pageIndex);
if(viewerCoordinate.y > 0){
break;
}
}
let imagePosition = {
x: Math.max(clickPosition.x - imageDimension.width / 2, 10),
y: Math.max(clickPosition.y - imageDimension.height / 2, 10)
};
return displayMode.windowToPage(imagePosition, pageIndex);

Above logic works perfect for portrait mode but in landscape mode it get shifted to some pixel in negative.Did we miss something?

arpit srivastava

unread,
Nov 30, 2016, 1:53:52 PM11/30/16
to PDFTron WebViewer
Hi Matt,

Thanks for reply.But issue still persist for Text UnderLine, Text Strikeout and Text Squiggly Annotation for the above zip file


On Saturday, November 26, 2016 at 2:25:25 AM UTC+5:30, Matt Parizeau wrote:

prakhar jaiswal

unread,
Dec 1, 2016, 1:03:08 PM12/1/16
to PDFTron WebViewer
Thanks for the updates Matt! Appreciate it


Just a question, the height and width attributes ought to be translated with rotation as well, or it will have to be handled explicitly? Currently, if I add rotation to a stamp annotation based on page orientation; the image gets skewed because the height and width are not altered accordingly with rotation.

In summary, should the application continue to handle the dimension translation on rotation with this being a feature, or is this an un-expected behavior and will be addressed in future with translations being handled implicitly by the library?

Matt Parizeau

unread,
Dec 1, 2016, 3:40:07 PM12/1/16
to PDFTron WebViewer
Hi,

Can you provide a screenshot of the problems you're seeing with text annotations? I'm unclear about the difference you're seeing between the expected and actual behavior.

For the issue with images being shifted could you provide the full sample code so that we can reproduce the issue?

For the other question about stamps, yes you'll need to swap the width and height of the annotation when the page is rotated 90 or 270 degrees.

Thanks,

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages