GroupDocs.Assembly provides a great feature which is loading of HTML template documents referencing external resource files to be assembled and saved to non-HTML formats.
Since version 19.5, when loading an HTML document from a file, its containing folder is used as a base URI to resolve external resource files’ relative URIs to absolute ones by default as shown in the following example. The following code snippet shows the way of API usage:
fromgroupdocs.assemblyimportDataSourceInfo,DocumentAssembler# The template's pictures are read from the template's own folderassembler=DocumentAssembler()assembler.assemble_document("externalresourcefiles.htm","externalresourcefiles-report.docx",DataSourceInfo("Harbor Lane Provisions","value"))
The following code snippet shows the default folder used to resolve external resource files’ relative URIs are overridden by an explicitly specified folder.
importosfromgroupdocs.assemblyimportDataSourceInfo,DocumentAssembler,LoadSaveOptions# Read the template's pictures from another folderoptions=LoadSaveOptions()options.resource_load_base_uri=os.path.abspath("ExternalResourceFiles")assembler=DocumentAssembler()assembler.assemble_document("externalresourcefiles.htm","externalresourcefiles-report.docx",options,DataSourceInfo("Harbor Lane Provisions","value"))