InsertHtml

Hello

we have a database that contains rich text and images between texts and
when we try to print a single word formatted text prints but does not print
the images.
To print the document I use the command:

Builder.InsertHtml(Variable, true);

Attached Files :
Resultado_actual : is the way it is currently presented.

Resultado_deseado : it is the way we need it to watch the final file.

What we need to display images
Regards.

Hi there,

Thanks for your inquiry. Please make sure that the path of image is correct in your html. You can check the html output by opening it in browser. If you still face problem, please share your html document here for investigation purposes. We will then provide you more information on this.

Hello Tahir ,

We attach the required information.(texto_1.docx)

For some reason he is not assuming the full URL of the image
source you want to add to the document.

You could help us find the solution.

Regards!
Rodrigo.

Hi Rodrigo,

Thanks
for sharing the detail. Please use the following configuration settings
in your application. Hope this helps you. Please let us know if you
have any more queries.

<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
HttpWebRequestElement webRequestSettings = new HttpWebRequestElement();
webRequestSettings.UseUnsafeHeaderParsing = true;

Hi Tahir,

Unfortunately it did not work the settings that you have recommended us.

There would be some other things that we can apply to so you can take full URL of the image that need to print the document.

add screenshot.

regards!

Hi there,

Thanks for your inquiry. Could you please open your html in browser and check the output. Make sure that the path of image is correct.

DocumentBuilder.InsertImage Method (String) inserts an image from a file or URL into the document. This overload will automatically download the image before inserting into the document if you specify a remote URI.

There is no issue with InsertImage method. Please try the following code example in your application and let us know about your findings.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertImage("http://www.aspose.com/images/aspose-logo.gif");
doc.Save(MyDir + "DocumentBuilder.InsertImageFromUrl Out.doc");

Hi Tahir ,

In order to better clarify the stage , attached a file in which the requirement is explained and what the results we are getting.

Datos.docx - Explain the process of loading of logs (text and images ) and how it should be displayed in the final print.

Archivo_2.docx - Displays the current result.

error.docx - Shows where the problem which does not take the picture.

Waiting we can help validate options in order to find a solution to the case .

Regards!

Hi there,

Thanks for sharing the detail. In your case, I suggest you please use LoadOptions.BaseUri property to get or set the string that will be used to resolve relative URIs found in the document into absolute URIs when required.

This property is used to resolve relative URIs into absolute in the following cases:

  • When loading an HTML document from a stream and the document contains images with relative URIs and does not have a base URI specified in the BASE HTML element.
  • When saving a document to PDF and other formats, to retrieve images linked using relative URIs so the images can be saved into the output document.

Please check following code example for your kind reference. See the image tag from following html. Hope this helps you.

Simple file.

LoadOptions loadOptions = new LoadOptions();
loadOptions.BaseUri = "http://www.aspose.com/images/";
Document doc = new Document(MyDir + "in.docx", loadOptions);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(MyDir + "in.html"));
doc.Save(MyDir + "Out.docx");

Hi Tahir,

We performed the tests according to your indications but unfortunately we are not displaying the images in the document.

Attached is the result after using the statement you provided us.

We welcome your feedback to solve this case.

Regards!

Thanks for your inquiry. There is no issue with DocumentBuilder.InsertHtml method. The path of image is not accessible when you are inserting html fragment using InsertHtml method. If you save the html fragment into separate html file and open it in browser, you will not see the image also.
Please use the complete URL of image in html instead of following.
"/Proyecto_Auditoria/Documentos%20compartidos/PTT/Especifico/informe1/1.png"
Could you please open following link in browser and check if you can see the image in browser?

Hi Tahir ,

Finally we have the problem correjido print images .

Many thanks for your time.

Hi there,

Thanks for your inquiry. Unfortunately, I have not understood your query. Could you please elaborate your query?

Hi Tahir ,
Sorry , I just wanted to inform you that we have already solved the problem of printing images

Hi there,

Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.