Using viewer in HTML mode to mimic user experience when using native apps

hi, I am looking for a solution to use your Viewer on Java to display documents on the web application. My targeted documents are mostly : pdf (some of the pdf’s might be coming from scanners) plus all microsoft office files and also emails. .
The goal is to setup viewer in a way that it is as much close to the experience when users has when viewing documents in native apps (Nitro, Adobe, Ms Office etc. ). I don’t care about performance - my goal is to make sure that documents looks good - as much close as possible to the real native apps.

What I have spot so far when playing around with your viewer is that some of the default settings are “not optimal” e.g. I spot that by default image quality of the images inside the PDF is set to “LOW”, which is different vs Nitro. From what I can see each type of the document has it’s special settings and also some of them are “generic” (applied for all the types).

I think for generic once I should be probably using:
//generic options
viewOptions.setMinify(false); //Minification can break some layout fidelity (e.g., whitespace-sensitive glyph alignments).
viewOptions.setForPrinting(false); // prevents layout changes
viewOptions.setRemoveJavaScript(false);

But for those specific to PDF and MS office - I would like to ask you for the best settings which would ignore performance but give user the almost-native experience in terms of viewing a document in webbrowser. Please help and advice some good starting point settings.

Best Regards,
PG

P.S. - where can I found in documentation what default setting are taken -e.g. I couldn’t find what are default settings for e,g, EnableLayeredRendering for pdfDocumentOptions.

Hello @PG123 ,

By default the GroupDocs.Viewer sets most of options to some sort of trade-off between performance and quality. Of course, you can adjust them to reach the max quality of the rendered documents.

From what I understand, you are only interested in rendering documents to the HTML output format. For such case you need to use the HtmlViewOptions class — create its instance and then pass it to the Viewer.view() method. The HtmlViewOptions class has different properties, where for every formats familiy there is a distinct one: HtmlViewOptions.setPdfOptions() for tuning PDF rendering, HtmlViewOptions.setWordProcessingOptions() for tuning Wordprocessing (DOC, DOCX, DOCM, RTF,…) rendering, HtmlViewOptions.setEmailOptions() for tuning email rendering, and so on.

So, regarding the max quality settings:

HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewOptions.getPdfOptions().setEnableLayeredRendering(true);
viewOptions.getPdfOptions().setRenderOriginalPageSize(true); //works only when rendering to PNG or JPEG, ignored for HTML 
viewOptions.getPdfOptions().setImageQuality(ImageQuality.HIGH); 

That’s all. For all other formats, when there are no specific cases like special fonts processing, the default options will be fine. If you have any further questions, please feel free to contact us.

1 Like