HTML to PDF - Images are not displayed from Shared Floder

Hello,


I am using Aspose.PDF version 11.2 to convert HTML to PDF. In my HTML files I have some images loading from a shared network path.

Images are loading properly inside the html file but they are not displayed inside PDF file. below is the code I am using:

Dim pLicence As Aspose.Pdf.License = New Aspose.Pdf.License
pLicence.SetLicense(“Aspose.Total.lic”)

Dim basePath As String = Path.GetDirectoryName(FilePath)
Dim htmloptions As New HtmlLoadOptions(basePath)

’ Load HTML file
Dim pdfDocument As New Document(FilePath, htmloptions)
pdfDocument.PageInfo.Width = 597.6
pdfDocument.PageInfo.Height = 842.4

'get page collection
Dim pageCollection As PageCollection = pdfDocument.Pages
'get particular page
For Each pdfPage As Page In pageCollection
pdfPage.SetPageSize(597.6, 842.4)
Next

'Optimize the pdf file in order to decrease it’s size
Dim optimization As Aspose.Pdf.Document.OptimizationOptions = New Aspose.Pdf.Document.OptimizationOptions()
optimization.LinkDuplcateStreams = True
optimization.RemoveUnusedObjects = True
optimization.RemoveUnusedStreams = True
optimization.CompressImages = True
pdfDocument.OptimizeResources(optimization)

’ Save HTML file
pdfDocument.Save(pdfFilePath, SaveFormat.Pdf)



How can I resolve the issue. I need a solution ASAP.

Thanks.

Hi David,


Thanks for using our API’s.

Can you please share the resource files (HTML and referenced images), so that we can test the scenario in our environment. We are sorry for this inconvenience.

I attached the requested files. I need a solution ASAP since the generated PDF file is not showing images located in a shared folder.

Hi David,


Thanks for sharing the resource files.

As per my observations, the path for image file in HTML is not correct. It should be folder relative. During my testing with latest release of Aspose.Pdf for .NET 11.2.0, I am unable to notice any issue and as per my observations, the image is properly appearing over my end. For your reference, I have also attached the resource files generated over my end.

I have no issue with images in absolute path. I am talking about having images in a Network Path as below:
\\computername\foldername\image.png

In above case the html is rendering images properly but pdf file is not showing the images.

Please re-test with network path.


Hi David,


Thanks for sharing the details.

I have tested the scenario and have managed to reproduce the same issue that images are not being rendering inside PDF file when referenced from network path.For the sake of correction, I have logged it as PDFNEWNET-40246 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.