This post was flagged by the community and is temporarily hidden.
Hi there,
Thank you for reaching out to pdf.js express,
The merge API endpoint seems to be working, has there been any changes to proxy/vpn? Could you please try with the latest version of PDF.js version? Has your license expired?
Thank you in advance.
Best regards,
Kevin Kim
This post was flagged by the community and is temporarily hidden.
Hi Kevin,
I upgraded to the latest version of PDF.JS Express, which is version 8.7.0. I’m still running into the issue when using the Merge REST API. You mentioned that you or the engineering team was able to successfully use the Merge REST API? Do you have an example of where it works properly?
Thanks,
Quinn
Hi Quinn,
The annotations are flattened when downloading via the demo, I was able to see that there are no rectangle annotation when I created one and downloaded it via the demo:
Note that if you call instance.UI.downloadPdf() in the console on the demo page, the PDF will not have the annotation.
I was able to check the merge API endpoint using the example in the guide here:
Merging XFDF using the Express REST API | Documentation
And at the bottom of this page shows that the setFile API only accepts files under 5.5MB
https://pdfjs.express/api/utils/
Best regards,
Kevin Kim
Hi Kevin,
Thanks for checking. From the documentation, it states the following about the file to process:
“The max file size for an in memory file is 5.5mb. If your file is larger than that, it must be accessible via URL, and the URL must be passed to this parameter.”
So we actually do pass over URLs instead of loading PDFs in memory. So, when I pass over a S3 URL to the demo page, it does not work. For example, when I click on the “Try your own file” button, it provides an option to enter a URL.
When I click on Submit, the PDF loads without any issues. This is a 9MB file.
After annotating the document, and then trying to download, it just hangs indefinitely.
This used to work and is no longer working as of this past weekend.
Are you able to use the merge API with passing over a url?
Thanks,
Quinn
Hi Quinn,
Using the demo, I get a 413 status code for a 18MB pdf (https://showcase.apryse.com/gallery/canada-income-tax-act.pdf):
When I use the mergeAPI in code via the sample method the sample method (url instead of blob):
// mergeAPI
const mergeFile = async () => {
// const xfdf = await annotationManager.exportAnnotations({ links: false, widgets: false });
// const fileData = await documentViewer.getDocument().getFileData({});
// const blob = new Blob([fileData], { type: 'application/pdf' });
const fileURL = 'https://showcase.apryse.com/gallery/canada-income-tax-act.pdf';
const xfdf2 = `<?xml version="1.0" encoding="UTF-8" ?><xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><pdf-info xmlns="http://www.pdftron.com/pdfinfo" version="2" import-version="4" /><fields /><annots><square page="0" rect="165.240,334.690,478.990,504.880" color="#E44234" flags="print" name="8f7d1037-9345-24e4-0086-8c921e9a6ebc" title="Guest" subject="Rectangle" date="D:20230314111930-07'00'" interior-color="#007A3B" opacity="0.6489166156074194" creationdate="D:20230314111900-07'00'"/><freetext page="0" rect="378.580,558.140,511.720,619.500" color="#88271F" flags="print" name="b05fced8-b561-a179-3bdb-600aa18aa0eb" title="Guest" subject="FreeText" date="D:20230314111906-07'00'" width="0" creationdate="D:20230314111904-07'00'" TextColor="#00CC63" FontSize="12"><trn-custom-data bytes="{"trn-wrapped-text-lines":"[\\"test \\"]"}"/><contents>test</contents><contents-richtext><body><p><span>test</span></p></body></contents-richtext><defaultappearance>0 0.478 0.231 rg /Helvetica 12 Tf</defaultappearance><defaultstyle>font: Helvetica 12pt; text-align: center; text-vertical-align: top; color: #00CC63</defaultstyle></freetext></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>`
const data = new FormData();
data.append('xfdf', xfdf2);
// data.append('file', blob);
data.append('file', fileURL);
// data.append('license', my_license_key);
// Process the file
const response = await fetch('https://api.pdfjs.express/xfdf/merge', {
method: 'post',
body: data
}).then(resp => resp.json());
console.log('response:', response);
const { url, key, id } = response;
// Download the file
const mergedFileBlob = await fetch(url, {
headers: {
Authorization: key
}
}).then(resp => resp.blob())
console.log('merge complete, fetched mergedFileBlob:', mergedFileBlob);
console.log('fetched id', id);
// load the new blob:
instance.UI.loadDocument(mergedFileBlob);
}
Could you please try the above method and see if that works for you?
Best regards,
Kevin Kim
Hi Kevin,
Thank you for providing that example. It works for me, although I was getting a CORS issue with that particular PDF.
So I think I am starting to narrow down the issue to possibly some setting that is being updated on the PDF during our publishing / merging action. This appears to lock the PDF such that merges cannot be made to the PDF.
Again, the interesting thing is that this was working up until this past weekend. I will continue to research today and get back to you.
Thanks,
Quinn