Loading of template documents from HTML with resources

Note
This feature is supported by version 19.5. or greater
Note
The code uses some of the objects defined in The Business Layer.

Loading of template documents from HTML with resources

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:

// For complete examples and data files, please go to https://github.com/groupdocs-assembly/GroupDocs.Assembly-for-Java
//Setting up resource directory for input template and output
String strDirectoryPath = CommonUtilities.getSourceFolder("\\ResourceLoad\\");
//Instantiate DocumentAssembler class
DocumentAssembler assembler = new DocumentAssembler();
assembler.assembleDocument(strDirectoryPath + "TestWordsResourceLoad.htm",
strDirectoryPath + "TestWordsResourceLoad Out.docx",
new DataSourceInfo("It should be a jeep image.", "value"));

The following code snippet shows the default folder used to resolve external resource files’ relative URIs are overridden by an explicitly specified folder.

// For complete examples and data files, please go to https://github.com/groupdocs-assembly/GroupDocs.Assembly-for-Java
//Setting up resource directory for input template and output
String strDirectoryPath = CommonUtilities.getSourceFolder("\\ResourceLoad\\");
//Instantiate DocumentAssembler class
DocumentAssembler assembler = new DocumentAssembler();
LoadSaveOptions loadSaveOptions = new LoadSaveOptions();
loadSaveOptions.setResourceLoadBaseUri(strDirectoryPath + "Alternative");
assembler.assembleDocument(strDirectoryPath + "TestWordsResourceLoad.htm", strDirectoryPath +
"TestWordsResourceLoad Out.docx",
loadSaveOptions, new DataSourceInfo("It should be a sport car image.", "value"));
Close
Loading

Analyzing your prompt, please hold on...

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