function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Simon@M+veSimon@M+ve 

PDF Data truncated

I hope someone can help me with this interesting little nugget.


We are using the Docusign API to manage electronic signatures on some documents.  Part of the process of this is to send a letter out to the user as a PDF.  We create the PDF by using a Visualforce Page set as "renderAs='PDF'" assign it to a PageReference object, and then use the .getContent() method to assign the data to a Blob.

 

We have three scenarios attempted to get this to work:

 

1.  Run the code from a button on a VF page - this works fine.  The PDF isn't truncated (i.e in the XML message the tag 'PDFBytes' is well formed and the correct length).

 

2.  Run the code from a button on a VF page, but it uses an @future call (this is necessary as we are aiming towards batch processing of Docusign processing) and this also works fine.  The page was a simple test page with three inputs and a button that called the @future method.

 

3.  Run the code from a button, but THIS button processes other bits and pieces in Apex first.  At the end of it's processing, it calls the @future method.  This fails.  The reason it fails is that the WebService Callout receives an error about processing anchor tags.

 

After some investigation on the Docusign website, it appears one of the reasons for this WebService Callout error is the PDF document being sent as been truncated.  We checked our logs and low and behold, our 'PDFBytes' tag was extremely truncated.

 

So - the root problem seems to be, running this code to retrieve a Blob from a PDF-rendered VF page sometimes works (scenarios 1 & 2 above) and sometimes doesn't (scenario 3).  I have tried searching the Developer boards AND the Docusign boards (even though this isn't really a Docusign problem) but with no luck.

 

Can anyone help??

 

Thanks.