HTML to Word/PDF update strips images red x

Hello: We just upgraded to the new version of Aspose Word and PDF converters because the old version started throwing errors about methods being obsolete.

As soon as we upgraded, when we convert HTML to Word and save as PDF, we lose any images we are trying to convert. This is a severe work stoppage issue. Please help!


This message was posted using Aspose.Live 2 Forum

Hello,

May be you can try using the following code lines to specify the path where images of HTML file are placed.

// Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = "D:/pdftest/MemoryStream/";

In case it does not resolve yor problem, can you please share the source HTML so that we can test the scenario at our end. We apologize for your inconvenience.

Hi there,

When we used the older version the code looked like this :

Dim baseUrl As String

baseUrl = uri.AbsoluteUri

baseUrl = baseUrl.Replace(uri.PathAndQuery, "/")

Original code is commented below since the new ASPOSE Dlls do not support this method any longer

'Dim doc As New Document(mergeItem.stream, baseUrl, Aspose.Words.LoadFormat.Html, Nothing)

Dim doc As New Document(mergeItem.stream) -----------This is what I replaced the above commented code with

Dim msHtml As New MemoryStream()

doc.Save(msHtml, Aspose.Words.SaveFormat.Pdf)

files.Add(msHtml)

When I declare the doc the load format is not acecpting HTML anymore. We are trying to stream it to Doc. When I do Doc.Save can I chnage the image url here, and how ?

If I do Saveformat.html it gives error saying

Image file cannot be written to disk. When saving the document to a stream either ImagesFolder should be specified or custom streams should be provided via HtmlExportImageSaving event handler. Please see documentation for details.

Hi,

Thanks for sharing the information.

The query seems to be related to Aspose.Words, so I am moving this thread to Aspose.Words forum and I believe our team of experts taking care of this product would be in better position to answer this query. We apologize for your inconvenience.

Hi there,

Thanks for your inquiry. There were some breaking changes to the API in the newer versions. Now load properties like BaseUri and Password are passed using an instance of the LoadOptions class. For code examples please see the page here.

Regarding the message you are getting when attempting to save in the HTML format to a stream, you need to do exactly what the message says, and that is set a folder for the images or stream for the images to be saved to. You can find some details on using the ImagesFolder property here. If you are looking to keep all content together in one place I would suggest using SaveFormat.Mhtml instead.

For full details of the API changes please see the migration article here.

Thanks,

Hi All:

We resolved this issue by replacing the src on the image tag with the actual URL of the image instead of the directory as previously used.

i.e. src='images/image.png' now src='http://localhost/images/image.png'

Thanks for your replies.

Hello.

It's great that you managed to solve the problem. Please feel free to ask any issues, we'll be glad to help.