JS API and PDF Creation


(Lewis) #1

Hi,

Does anyone have any idea how to use the JS API in Squiz Matrix 5.5.3.3 to create a PDF and then update its content?

I’ve got as far as creating the assets. You then have to acquire the locks to attempt to update the content, which I’ve successfully done. The penultimate call (add the content) then appears to go through without any problems but, after releasing the locks again and trying to preview the newly created PDF asset, the reader says there is an error opening it.

I’ve tried opening it natively in Google Chrome, Mozilla and Opera as well as Adobe itself but they all say the same thing and it looks like the PDF asset is ‘corrupted’.

For the time being, I’m hard coding a BASE64 encoded string (as the manual says) to parse content to the API for content creation.

The file size each time comes back ridiculously small at something like 19 bytes!

Interestingly, Word documents created using the JS API are fine - they load into MS Word no problem, albeit perhaps without preserving any formatting (I tried tables and headings in BASE64 earlier and they didn’t preserve) but the newly created Word asset otherwise functions as you’d expect - a seemingly complete Word doc!

PDFs though … ??? any ideas??