BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi,
I've been having issues running a JavaScript Fetch during the conversion of a web page to a PDF, I have JavaScript enabled and the Additional Delay set at 2000ms (the default options), but the code doesn't run during conversion.
I'm running the latest NuGet weekly package (20.4.0.42) and NET 7.0 on Debian Linux 11.6.
If I view the page that I'm trying to PDF through a browser everything works okay and well within the two second delay being allowed, (the response and changes to the page are almost instant).
If I try to set some plain text via JavaScript that displays as expected so I know parts of the script run during conversion which makes me think that an API call during conversion isn't supported.
My next step is to strip out the PDF and JS code into a standalone app to try and debug further but if anybody can confirm if Fetch is supported and if it is do I need to do anything different, it will save me quite a bit of work.
Thanks.
Currently, we are checking on this and we will update the further details on jan 10th 2023.
In the meantime, we request that you share the complete code snippet and what URL is being called in the fetch API, how it is rendered, and a screenshot of the issue.So that it will helpful for us.
Hi,
Thanks for the reply, I've included a cut down version of the code I am using to generate the PDF to try and give you what you need without too much extra code that isn't related.
PDFController.cs contains the main function which creates a PDF from a web-based invoice page.
ViewInvoice.cshtml and ViewInvoice.cshtml.cs is the main section of code that can generate the same invoice in three different ways depending on whether a site admin, a client or the PDF generator is viewing an invoice.
The PDF version calls invoicepdf.js which calls getcustomer.js file which uses JavaScript Fetch to an API and then populates customer details onto the invoice.
I can't give you access to the API directly as it returns details about my customers and as such requires authentication, however, I have included two PDF files in the zip file, Rose-IT-Solutions-Invoice-138 (Not Working).pdf is a version of the file generated using the JavaScript functions and has the details under "Bill To" missing, the other PDF file Rose-IT-Solutions-Invoice-138 (Workaround).pdf uses my original Razor code and server side rendering to populate data and works as expected.
My plan has been to migrate data population to JavaScript and use an API which can make certain elements of the page update without a full-page refresh and a roundtrip to the server.
If you need anything else, please let me know.
Regards,
Adrian Rose.
Thank you for sharing the details, it was very helpful for us to investigate on this. On our further analysis, the fetch API is supported in HTML to PDF conversion. We have ensured this with simple sample in our side. Please find the sample for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/FetchAPI_HtmlTtoPdf-1523157642
We suspect that the authentication of web api will be the root cause for this issue. So, can you by-pass the authentication for the conversion and try the conversion in your side to confirm the root cause. If authentication of the web api causing this issue, please share us the type of authentication used for the web api.
Our HTML to PDF converter supports, windows, forms and token based authentications, so please refer below UG links and try the conversion with respective authentication details.
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/features#windows-authentication
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/features#form-authentication
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/features#token-based-authentication