Annotations not properly exported

Product: @pdftron/webviewer

Product Version: 7.3.3

Please give a brief summary of your issue:
Annotations are not being properly exported (on download or on programatic export)

Please describe your issue and provide steps to reproduce it:

We’re loading a PDF, and we insert 4 free text annotations.

Given this data:

"textFields": [
          {
            "content": "Temár Jordão Gomes",
            "region": {
              "x": 75,
              "y": 530,
              "width": 150,
              "height": 30,
              "pageNumber": 2
            },
            "fontSize":17
          },
          {
            "content": "Temár Jordão Gomes",
            "region": {
              "x": 75,
              "y": 573,
              "width": 150,
              "height": 30,
              "pageNumber": 2
            },
            "fontSize":11
          },
          {
            "content": "07/07/2020 16:42",
            "region": {
              "x": 75,
              "y": 590,
              "width": 150,
              "height": 30,
              "pageNumber": 2
            },
            "fontSize":11
          },
          {
            "content": "TEST TIAGO",
            "region": {
              "x": 75,
              "y": 610,
              "width": 150,
              "height": 30,
              "pageNumber": 2
            },
            "fontSize":11
          }          
        ]

We apply the following:

        document.textFields.forEach(textField => {
          const freeText = new Annotations.FreeTextAnnotation();
          freeText.PageNumber = textField.region.pageNumber;
          freeText.X = textField.region.x;
          freeText.Y = textField.region.y;
          freeText.Width = textField.region.width;
          freeText.Height = textField.region.height;

          freeText.setPadding(new Annotations.Rect(0, 0, 0, 0));
          freeText.setContents(replaceDatePlaceholder(textField.content));
          freeText.FontSize = `${textField.fontSize || 20}pt`;
          freeText.ReadOnly = true;
          freeText.Locked = true;
          freeText.Font = "serif";
          freeText.TextAlign = "left";
          freeText.TextColor = new Annotations.Color(0, 0, 0, 1);
          freeText.StrokeThickness = 0;

          annotManager.addAnnotation(freeText, { autoFocus: false });
          annotManager.redrawAnnotation(freeText);
        });

We get the following output on the screen (which is perfect):

image

The problem is when we try to download the document. It’s like this:

(The same problematic output occurs when we try to export it, programatically).

IMPORTANT NOTE:
This was all working perfectly on our previous version (that was using web viewer 5.x

On top of the code that I pasted, we WERE also applying the following:

            annotation.setPath([
                new Annotations.Point(textField.region.x, textField.region.y),
                new Annotations.Point(
                    textField.region.x + textField.region.width,
                    textField.region.y + textField.region.height
                )
            ]);

Apparently, I can no longer use this on 7.3.3 ?

Can you please help? This is a big blocker for us.

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Thanks for the detailed steps to reproduce. I do see the difference in behavior between WebViewer 5.2 and 7.3.

While we investigate a workaround that may work for you would be to set the font to “Times” instead of “serif”. This seems to work for me in WebViewer 7.3.

For setPath what type of annotation are you trying to call it on? It appears that FreeHandAnnotation defines a setPath function but FreeTextAnnotation only has setPathPoint and this appears to be the same as 5.2. PDFTron WebViewer Class: FreeTextAnnotation

I think you may be able to use setPathPoint to achieve the same thing for FreeText annotations.

Thanks for the reply, Matt.

Well, it’s still not quite right (but definitely better). Using “Times” instead of “serif”, the download / export looks like this:

image

Notice how the letters with special characters don’t appear properly.

Regarding the setPath , I’m not too familiar on what the purpose was, but just mentioned it, in case it was relevant for the particular issue (which is not, I tried the setPathPoint , and using “serif” the issue remains.

Any ideas on why this is happening? So, browsing the PDF, everything looks fine - exporting / downloading is the issue.

Appreciate the help.
Tiago

You’re right, I can reproduce the same thing when using “Times” and special characters. Talking to our Core SDK team it looks like what’s happening is that saving the font in the document we need to apply “font substitution” because in the browser we don’t have direct access to font files. We host a number of fonts for this and have logic that will try to determine the best font to use based on the font name that is provided for the annotation.

Our internal logic for matching font names has changed since version 5 in a number of ways which seems to be why serif used to work but now doesn’t as it’s matching a different font in the latest version. I did some more testing and if you use “Times New Roman” it seems to match the same font that “serif” matched in 5.2 and special characters look correct for me in the downloaded file.

I would recommend using that as the font name instead and in the mean time I will follow up with our Core SDK team to see if our font substitution logic needs to be tweaked to handle these cases better.

Hi Matt,

Sorry for the delay.
I can confirm that using “Times New Roman” on the new versions, matches “serif” on version 5.2

Thank you for the reply!