[JAVA] Incorrect stylesheet link in generated html file

Hi,

GroupDoc.Viewer v17.2

I’m generating html file in cache folder with ResourcesEmbedded = false, because it seems the total size is smaller when sending to browser.
But I found the stylesheet link is incorrect.
For example below in page1.html(image.png (5.0 KB)):

<link rel="stylesheet" type="text/css" href="fontFaces.css" media="all" />

Actually, fontFaces.css is in “resources/page1” folder(image.png (5.0 KB)),
So correct link should be:

<link rel="stylesheet" type="text/css" href="resources/page1/fontFaces.css" media="all" />

I attached generated files for your reference(3J3FiHDE5iqr2M6leW9r9aAWWy2aQbqU4vkzWVrrrWg_txt.zip (16.7 KB)).

Thank you.

@andersonlin,

Thanks for sharing the issue details with all the relevant information. We successfully reproduced this issue at our end. Hence, its been logged in our internal issue tracking system with ID:VIEWERJAVA-1503. As we get any update from the concerned team, we’ll surely notify you.

@andersonlin,

We got an update. You need to save HTML resources as well in order to view HTML pages properly.

Save resources in cache:
options.setHtmlResourcePrefix("resources/page{page-number}/");

Save resources in output HTML files as follows:
for(HtmlResource resource : page.getHtmlResources()){ //save resource into "resources/page" + page.getPageNumber() + "/" }

This is how complete method will look like:


HtmlOptions options = new HtmlOptions();
options.setResourcesEmbedded(false);
options.setHtmlResourcePrefix("resources/page{page-number}/");
			
List<PageHtml> pages = htmlHandler.getPages(guid, options);

for (PageHtml page : pages) {
   Utilities.saveAsHtml(page.getPageNumber() + "_" + fileName, page.getHtmlContent());
                               
   for(HtmlResource resource : page.getHtmlResources()){
       //save resource into "resources/page" + page.getPageNumber() + "/"
   }
}

If you still face any further issues, please let us know.

@andersonlin,

The issue you have found earlier (filed as VIEWERJAVA-1503) has been fixed in this update.