BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
When using HtmlToPdfConverter in a .NET Core background service installed as windows service the intialisation of the HtmlToPdfConverter creates the error
Invalid URI: The URI is empty.
This is snippet from Event Viewer
CoreCLR Version: 8.0.824.36612
.NET Version: 8.0.8
Description: The process was terminated due to an unhandled exception.
Exception Info: System.UriFormatException: Invalid URI: The URI is empty.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString)
at Syncfusion.HtmlConverter.BlinkConverterSettings..ctor()
at Syncfusion.HtmlConverter.HtmlToPdfConverter.set_RenderingEngine(HtmlRenderingEngine value)
We have used the Nuget package Syncfusion.HtmlToPdfConverter.Net.Windows v27.1.58
Do we need to specifically reference a certain URI when using the HtmlToPdfConverter in this way?
Hi Martin,
Thank you for reaching out to us.
Our Syncfusion HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Please find our documentation to perform HTML to PDF conversion using blink rendering engine.
Converting HTML to PDF | Syncfusion
However, we have attached the sample and output document below for your reference
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HTML-to-PDF-NET8.0-1603290155
Output: https://www.syncfusion.com/downloads/support/directtrac/general/pd/HTML-to-PDF-1204513699
Since the provided details are not enough to replicate the issue. We kindly request you to share the complete code snippet, input HTML document or specific URL, modified sample, .NET version and environment details to replicate the same issue on our end. This information will be more helpful for us to analyze and provide you with a prompt solution.
Regards,
Arumugam M
I have attached the Program and Worker.cs files. If I debug it works fine and converts html to PDF. However when installed as a windows service using sc create the HtmlToPdfConverter has an error.
Hi Martin,
Thank you for providing the details. Currently, we are trying to reproduce the reported issue with the provided details, and we will provide further details on November 12, 2024
Regards,
Arumugam M
Hi Martin,
Currently, we are facing issue in reproducing the reported issue with the provided details. We are checking on this with high priority and we will update further details on November 14, 2024. Meanwhile, we kindly request you to share the steps to reproduce the reported issue. This will be more helpful for us to reproduce the issue and provide a prompt solution.
Regards,
Arumugam M
Hi there, i have created a sample project and upload to github: https://github.com/martingholmes/Test-HTML-to-PDF
When publish i use the following setting:
Then it is installed as a windows service using sc create "servicename" binpath= "path to exe"
When an email is added to the watched folder and the HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); is called it errors with error message Invalid URI: The URI is empty.
Thanks, Martin
Hi Martin,
Upon further analysis, we suspect that the reported issue may occur with your specific input documents. We kindly request you to share your input documents with us. This will be more helpful for us to analyze and provide a prompt solution.
Regards,
Arumugam M
Hi Arumugam,
It is definetely not the input document as the code does not get that far. The line that errors is:
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
The relevant document is not passed to this line of code.
Thanks, Martin
You can close this ticket, I have resolved the issue. The issue was selecting "Produce single file" on publish. Untick this and it works fine.
Thanks, Martin
Hi Martin,
We are glad to hear that you resolved the issue. Please get back to us if you need further assistance.
Regards,
Arumugam M