Appearance of Annotations differ when flattened

106 views
Skip to first unread message

Christian Gruber

unread,
Apr 26, 2018, 1:04:20 PM4/26/18
to PDFTron WebViewer

Hi, 


when creating an annotation, e.g. Text Annotation and I flatten the entire document, the annotation doesn't look exactly the same as before. 

Here I created an annotation using the Annotation Tool "Free Text" of WebViewer 3.1


Then I flattened the annotations into the document using the PDFTron PDFNet Java SDK (libPDFNetC.so.6.7.1)

PDFDoc doc = new PDFDoc(inputStream);
FDFDoc fdoc = FDFDoc.createFromXFDF(document.getXfdfData());
doc
.fdfMerge(fdoc);
makeAnnotationsAppear
(doc.getPageIterator()); // custom code, calling refreshAppearance() on all annotations
doc
.flattenAnnotations(false);



So there clearly is a difference visible. Do you have any solution to this problem? 

Best regards, 

Christian





Matt Parizeau

unread,
Apr 26, 2018, 3:28:16 PM4/26/18
to PDFTron WebViewer
Hi Christian,

It looks like the images didn't get attached properly. Would you be able to reattach them?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
Apr 27, 2018, 1:05:21 PM4/27/18
to PDFTron WebViewer

Image 1: Free Text annotation made with Annotation Tools



Image 2: Annotation flattened into the document



(if the images aren't attached again, please check out these links: 1) https://drive.google.com/open?id=1eWON0gO1HlNj98WM48ktiKpAxu5SDKaw 2) https://drive.google.com/open?id=1wwkLz16Y2vLFNCFgL7SLZNWx-vn3l_rG )




Matt Parizeau

unread,
Apr 27, 2018, 3:11:52 PM4/27/18
to PDFTron WebViewer
Hi Christian,

We've reproduced the issue and it definitely does look like the line spacing is different in WebViewer than in other viewers. We've adjusted the spacing in this build: http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.2.0.65364.zip. Let us know if this looks better to you.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
May 2, 2018, 1:01:15 PM5/2/18
to PDFTron WebViewer
Hi Matt, 

can you provide the exact location of the change? Shouldn't be a big change is it? We customized WebViewer 3.1 pretty much and don't want to upgrade to 3.2 right now. 

Thanks

Christian

Matt Parizeau

unread,
May 2, 2018, 6:56:23 PM5/2/18
to PDFTron WebViewer
Hi Christian,

You're right that the change isn't very big but it's inside CoreControls.js which makes it trickier to integrate for you. I've made a 3.1 build with the adjustment that you can use here http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.1.0.65433.zip

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
May 3, 2018, 1:15:33 PM5/3/18
to PDFTron WebViewer
Hi Matt, 

I replaced the entire WebViewer folder in our project with the build you provided, but the error is still there. 

Is the change already live on https://www.pdftron.com/samples/web/showcase/index.html ? In my opinion, line spacing of a text annotation changes when the annotation looses focus. Line spacing is correct when the annotation is in "Edit Mode".

Is it just CoreControls.js that has to be replaced or are there more affected files? 

Another difference I see is Kerning (Letter spacing) - the spacing between letters changes when flattened into the document. You see the difference in my examples as well. This issue is not that important for us, but I just wanted to report it. 

Best regards,

Christian


Matt Parizeau

unread,
May 3, 2018, 6:23:27 PM5/3/18
to PDFTron WebViewer
Hi Christian,


The showcase on the website hasn't been updated with it yet and only CoreControls.js needs to be updated on your side. We've found the line spacing a bit tricky to get exactly the same as the final PDF and will likely be revisiting this at some point. The font also isn't necessarily the exact same one since it may not be available on the web which may impact letter (and possibly line) spacing.

Thanks for the reports, I hope that this latest build will get it closer to what the output PDF looks like. If it still feels too far off it would be great if you could provide us with a PDF with the FreeText (before it's flattened) that renders significantly differently in WebViewer and other PDF viewers.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
May 7, 2018, 12:17:42 PM5/7/18
to PDFTron WebViewer
Hi Matt, 

I replaced CoreControl.js but the error is still there (line spacing). 

Do you think it's related to the operating system and installed fonts? I use Ubuntu / Chrome to annotate the documents and also an Ubuntu machine is used on the server side where the annotations are flattened into the document. 

Would creating a PDF/A version of the document help? 

It think it's not necessary to provide a PDF because the error occurs with every document. 

Best regards, 

Christian


Matt Parizeau

unread,
May 7, 2018, 3:49:46 PM5/7/18
to PDFTron WebViewer
Hi Christian,

Hmm, it might be related to the operating system and fonts. I'm not sure a PDF/A version would help because the line spacing does seem to be quite different. I think it would still be useful to us if you could provide a PDF document with the FreeText you created in WebViewer (or XOD + XFDF if that's what you're using). Then we can compare on our end to see if we see the incorrect line spacing and narrow down where the problem is coming from.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
May 8, 2018, 1:06:39 PM5/8/18
to PDFTron WebViewer
Hi Matt, 

please find attached the XOD and XFDF files.

As said, the annotation looks good when displayed using the WebViewer. But when you flatten the annotation into the document, line and letter spacing differ.

When I look into the XFDF file, I see that Verdana is used for the FreeText annotation. Verdana is installed on our Ubuntu server where the annotation gets flattened (msttcorefonts/Verdana.ttf). However, would it be possible to change the font to a more generic one since Verdana is a Microsoft font? 

Best regards, 

Christian
xfdf.xml
demo.xod

Matt Parizeau

unread,
May 9, 2018, 3:19:27 PM5/9/18
to PDFTron WebViewer
Hi Christian,

Thanks for sending the file. It looks like the problem was that WebViewer was adding a fixed spacing between lines regardless of font size but to be consistent with other viewers it needs to increase the line spacing when the font size increases.

Can you try this build which better matches the behavior across different font sizes: http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.1.0.65541.zip
On your file + xfdf, WebViewer will now only display five lines of Xs like the PDF.

If you want to change the font of a FreeText annotation you can set the Font attribute (https://www.pdftron.com/api/web/Annotations.FreeTextAnnotation.html#FreeTextAnnotation__anchor), for example: freeTextAnnot.Font = 'Courier';

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Christian Gruber

unread,
May 11, 2018, 12:59:03 PM5/11/18
to PDFTron WebViewer
Hi Matt, 

thanks for the build, now it works perfectly! No need to change the font anymore. 

Are you going to merge this change for future versions? Just to be sure we can upgrade without problems. 

Best regards, 

Christian

Matt Parizeau

unread,
May 11, 2018, 1:03:48 PM5/11/18
to PDFTron WebViewer
Yep it will be a part of future WebViewer versions.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Reply all
Reply to author
Forward
0 new messages