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:
fromgroupdocs.assemblyimportDataSourceInfo,DocumentAssembler# The report's pictures and styles are written next to the reportassembler=DocumentAssembler()assembler.assemble_document("externalresourcefiles.docx","externalresourcefiles-report.htm",DataSourceInfo("Harbor Lane Provisions","value"))
In the following example, the default folder used to store HTML resource files is overridden by an explicitly specified folder.
importosfromgroupdocs.assemblyimportDataSourceInfo,DocumentAssembler,LoadSaveOptions# Write the report's pictures and styles to another folderoptions=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"))