Saving to HTML with External Resource Files

Note
The example reads the shop data described in The Business Layer.

Since version 19.5, The GroupDocs.Assembly provides a great feature which is saving of external resource files while an assembled document loaded from a non-HTML format is being saved to HTML.

From now on, when saving an assembled document to an HTML file, by default, external resource files are stored to a folder having the same name as the HTML file without extension plus the “_files” suffix. This folder is located in the same folder as the HTML file. The following example illustrates the scenario. The following code snippet shows the way of API usage:

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

# The report's pictures and styles are written next to the report
assembler = DocumentAssembler()
assembler.assemble_document("externalresourcefiles.docx", "externalresourcefiles-report.htm",
                            DataSourceInfo("Harbor Lane Provisions", "value"))

The following sample file is used in this example: externalresourcefiles.docx

externalresourcefiles-report.htm (698 bytes)
externalresourcefiles-report_files/Aspose.Words.165b7697-7df9-499c-92f6-dda9068177f6.001.jpeg (2 KB)

Download full output

In the following example, the default folder used to store HTML resource files is overridden by an explicitly specified folder.

import os

from groupdocs.assembly import DataSourceInfo, DocumentAssembler, LoadSaveOptions

# Write the report's pictures and styles to another folder
options = LoadSaveOptions()
options.resource_save_folder = os.path.abspath("resources")

assembler = DocumentAssembler()
assembler.assemble_document("externalresourcefiles.docx", "externalresourcefiles-report.htm", options,
                            DataSourceInfo("Harbor Lane Provisions", "value"))

The following sample file is used in this example: externalresourcefiles.docx

externalresourcefiles-report.htm (725 bytes)
resources/Aspose.Words.5ece6732-d711-4035-b268-404c3fb6d420.001.jpeg (2 KB)

Download full output

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.