XY coordinate issue for some documents

PDF express version : 8.4

We are programmatically adding a free text annotation with every text annotation. For that we are using annotation change event. In that event, we create a free text annotation and place it at the bottom using XY coordinates of the annotation.

const freeText = new Annotations.FreeTextAnnotation();
var timeStamp = serverTime ? serverTime : moment().format(“MM-DD-YYYY HH:mm:ss”);
freeText.PageNumber = PageNumber; //el.PageNumber;
freeText.X = X; //el.LeftMost;
freeText.Y = Y + Height; //el.BottomMost;
freeText.Width = authorWidth;
freeText.Height = authorHeight;
freeText.setContents(userObj.nickname + “\n” + timeStamp);
freeText.FontSize = “12pt”;
freeText.Locked = true;
freeText.NoDelete = true;
freeText.LockedContents = true;
freeText.NoMove = true;
freeText.StrokeThickness = 0;
freeText.Id = el.Ry + “-author”;
freeText.Subject = “author”;
freeText.TextColor = new Annotations.Color(59, 108, 180);
annotManager.addAnnotation(freeText);
annotManager.redrawAnnotation(freeText);

Issue is, there are some documents having wrong X Y axis

In this specific document, PDF express text annotation is getting placed correctly but our custom generated text is getting placed 90 degrees rotated due this coordinate mix-up. Is there anyway to resolve this

Hi Lakshan,

Thank you for contacting us regarding pdf express.

I will investigate the issue and update you once we have further progress.

Hi, Any update on this?

Hi Iakshan,

Sorry for the late reply as I was away last week.

We highly suspect that this is caused by the internal document rotation.

To investigate the issue further, could you share the file(s) with me? You can sent the file or share the link to jkung@apryse.com.

Attached the file below

Cinnamon Red, LLC__Credit Card Activity Report (2).pdf (58.8 KB)

Hi Iakshan,

Thank you for providing the information.

I will look into the issue and update you once we have further progress.

Hi,

Any update on this

Hi Iakshan,

Sorry for the late reply as I missed sending out the reply.

After looking into the document you provided, the internal document rotation is 90 degrees, that means you will need to apply the same degree to the programmatically added free text annotation.

To further investigate the issue, could you provide the whole code snippet to add the free text annotation in the annotationChanged event? thank you.

Custom text code:

            const freeText = new Annotations.FreeTextAnnotation();
            var timeStamp = serverTime ? serverTime : moment().format("MM-DD-YYYY HH:mm:ss");
            freeText.PageNumber = PageNumber; //el.PageNumber;
            freeText.X = X; //LeftMost;
            freeText.Y = Y + Height; //BottomMost;
            freeText.Width = authorWidth;
            freeText.Height = authorHeight;
            freeText.setContents(userObj.nickname + "\n" + timeStamp);
            freeText.FontSize = "12pt";
            freeText.Locked = true;
            freeText.NoDelete = true;
            freeText.LockedContents = true;
            freeText.NoMove = true;
            freeText.StrokeThickness = 0;
            freeText.Id = el.Ry + "-author";
            freeText.Subject = "author";
            freeText.TextColor = new Annotations.Color(59, 108, 180);
            annotManager.addAnnotation(freeText);
            annotManager.redrawAnnotation(freeText);
  1. How to identify internally rotated documents?
  2. How to get the current rotation value of the document and pass it to freetext?

I tried freeText.Rotation = 90;.
Text is getting rotated, But there are number of issues.

Main problem is, after we merge pdf with pdf express merge API original text annotations are getting rotated

This is an example just using pdfexpress text tool (without custom texts)

Before merge

After merge

Hi Iakshan,

Thank you for providing the information.

To get the rotation of the page, you can use instance.Core.documentViewer.getDocument().getPageRotation(1) to get the rotation, and it’s 90 degrees.

Could you provide the whole code snippet for merging?

Back-end code:

exports.mergeAnnotations = async function (req, res) {
try {
const utils = new Utils({
serverKey: serverKey,
clientKey: clientKey,
});
utils.setFile(req.body.file).setXFDF(req.body.xfdf);
const response = await utils.merge(); // merge XFDF
const mergedFile = await response.getBlob();
res.send({ url: response.url, key: response.key, blob: mergedFile });
} catch (error) {
res.status(500).send(error);
}
};

Front-end code:
const xfdf = await annotManager.exportAnnotations({ links: false, widgets: false });
const pdfExpressData = new FormData();
pdfExpressData.append(“file”, s3File);
pdfExpressData.append(“xfdf”, xfdf);
pdfExpressData.append(“license”, licenseKey);

            const response = await fetch("/merge-annotations", {
              method: "post",
              body: pdfExpressData,
            }).then((resp) => resp.json());
            const { url, key, mergedBlob } = response;
            // Download the file
            const mergedFileBlob = await fetch(url, {
              headers: {
                Authorization: key,
              },
            }).then((resp) => resp.blob());
            var pdfblob = new Blob([mergedFileBlob], { type: "application/pdf" });

Hi,

any update on this?

Hi,

any update on this?