Skip to main content
Participating Frequently
July 11, 2022
Question

Doc Gen API generating new PDF that will only open in Preview and Safari but not Chrome or Adobe

  • July 11, 2022
  • 3 replies
  • 1432 views

After the newly generated PDF is created from my DOCX template and JSON data, the file will throw and error if trying to open in Chrome that says:

 

"Error. Failed to load PDF document." as well as "Adobe Acrobat Reader could not open 'test.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)." if trying to open in Adobe Reader.

 

However, when opening in Safari or the native Mac Preview app, the file will open. 

We are using the Document Generation API (https://documentcloud.adobe.com/document-services/index.html#post-documentGeneration) to pass the template file and JSON data. I have tried using our own DOCX file as well as the template DOCX that is given on the Playgound site. They generate with 201 status code.

Please help! 

This topic has been closed for replies.

3 replies

Participating Frequently
July 12, 2022
Joel Geraci
Community Expert
Community Expert
July 12, 2022

Ok - Now I see what's going on. The returned object is multipart form data, not PDF. The PDF is in the multipart form data. See image below. You'll need to parse the response to get the PDF.

Participating Frequently
July 13, 2022

Yes, this is the reason and I'm inclined to think this is an example of a poor API design on the Adobe part. Returning multipart response is not the best way in this case, as well as the actual endpoint is about the status of the job. So if it's complete, why not return a CDN result location or have an extra API endpoint to get the result by job ID? Not easy to integrate with at all in its current shape. Just an observation.

Participating Frequently
July 12, 2022

Yes! Please see the files below - the PDF file won't let me attach (likely because it's corrupted), but I am going to post a public URL with it

Joel Geraci
Community Expert
Community Expert
July 12, 2022

Can you share both the Word template and the JSON?