Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri May 07, 2021 2:16 am

I have HTML source that contains relative images. Those images live in a directory but there's no way to pass in a *base* directory so the code can resolve it. During the PDF render, it fails to find those images and they are blank. The HTML source isn't public nor are the images, so a URL won't work. How can we render those images?

We created a sample code and it works with URL's but like we said, those links aren't public.
We created another sample using Base64 image links but that isn't realistic for our scenario.

Any help would be greatly appreciated.

Thanks,

daniel.dority
 
Posts: 14
Joined: Thu Jan 11, 2018 2:57 pm

Fri May 07, 2021 8:30 am

Hello,

Thanks for your inquiry.
Based on your description, I simulated a sample HTML file and then tested with the plugin conversion method (code is as follows), but the image could be rendered when converted to PDF. Attached are my input file and my output file. You could test it on your side.
If your HTML file has some extra settings, please share it with us to help us further investigate it. Thanks in advance.
Code: Select all
            string input = "sample.html";
            string outputFile = "ToPDF.pdf";
            Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(input,
            outputFile,
            true,
            10 * 1000,
            new SizeF(612, 792),
            new Spire.Pdf.Graphics.PdfMargins(0));


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri May 07, 2021 5:12 pm

I've modified the HTML to include an IMG html tag with the source embedded into the HTML, not CSS. We still could not get this to work. Please try on your side.

daniel.dority
 
Posts: 14
Joined: Thu Jan 11, 2018 2:57 pm

Sat May 08, 2021 6:34 am

Hello,

Thanks for your feedback.
For the modified html you provided, I tested it with the latest Spire.PDF v7.5.0, but the image can display well. Here I uploaded my test project, please run it directly on your side to see if the issue still occurs.
If this issue only occurs in your project, please provide it to help us reproduce your issue. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon May 17, 2021 8:17 am

Hello,

Have you run the project we provided to you? What is the result? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF