Displaying PDF using GroupDocs.Viewer

Hi,

I’m totally confused about using GroupDocs.Viewer java library.
What exactly is it intended for? Conversion or rendering?

I want to display a PDF document on a webpage, and I don’t get it how to do it with GroupDocs.Viewer library. What exactly these calls do:

viewer.view(pdfViewOptions);
viewer.view(htmlViewOptions);

Are they only doing a conversion to PDF or HTML respectively, but nothing related to rendering itself?
If they are doing these conversions, then does it mean that I don’t need GroupDocs.Conversion library, cause viewer library can do it all?

I’ve downloaded demos and examples, and managed to start Spring demo. However front-end source code is not available, all I can see by inspecting a page in a browser developer tools, is that it renders plain HTML, retrieved from back-end as a string.
Is some additional library needed for displaying PDF?

@vmimic

In case you want to display PDF document on a webpage you can use GroupDocs.Conversion or GroupDocs.Viewer. Both do the same. They take document on the input and convert it to selected output format.

Viewer is limited to produce HTML, PNG, JPEG and PDF while Conversion has much broader list of conversion pairs.

The Spring demo that you downloaded consists of the two main parts:

  • Angular UI - front-end application that request document pages in HTML, PNG or JPEG formats.
  • API - handles requests from the front-end, converts document pages to HTML, PNG or JPEG and sends the result back.

To display a file using Spring demo you have to select a file using file browser or specify filename as a query string parameter e.g. ?file=resume.docx as it show on the screenshot

.

Please let us know what were you expectations at the first place?

I need to display PDF on a web page, not HTML (or PNG).

I did manage to run Spring demo, and to upload a file. But when displaying, it renders as a HTML:

  • first, API converts a file to HTML (along with other needed resources)
  • then it reads content from newly created HTML file and returns it as a plain string
  • finally, front-end renders this string as HTML

I see front-end is angular app, but minimized, and I cannot find out what components are used for this rendering; however it doesn’t matter - it is still HTML being displayed, not PDF.

P.S.
It does not seem all the formats from this link are supported - it works for .DOC, but it does not work for .DOCX

P.P.S.
Also how is it possible that GroupDocs.Viewer can convert DOC to PDF successfully, but GroupDocs.Conversion fails to do the same, with error message Font Arial was not found?

@vmimic

Yes, we convert all the supported file types to HTML, PNG or JPEG. PDF is used for printing.

Can you please attach the DOCX file that you can’t open?

Arial and other Microsoft fonts that you typically use in documents are required to be installed. Can you please clarify which OS you’re running?

In the attachment, you can find:

  • the .doc file that can be converted by GroupDocs.Viewer, but cannot be converted by GroupDocs.Conversion, throwing an error Font Arial was not found.
  • the .docx file that can’t be converter by GroupDocs.Viewer (and of course can’t be converted by GroupDocs.Conversion either)

Both files are in the same zip archive.
I’m running Ubuntu 22.04.4 LTS 64-bit
test_files.zip (18.8 KB)

@vmimic

Thank you for sharing the sample files. We’ll take a look. Please make sure to install Windows fonts - How To Install Windows Fonts on Ubuntu.

So GroupDocs does not have any possibility for displaying PDF on a web page?

P.S.
Please let us know when you find out why this DOCX cannot be converted/viewed using GroupDocs.Viewer (even after installing windows fonts).

P.P.S.
After installing windows fonts, GroupDocs.Conversion starts working.

@vmimic

Thank you for the feedback! At the moment we can display PDF documents after they are converted to HTML, PNG or JPEG formats. We do not have a solution that can display PDF file itself.

1 Like

Thank you for your answer. I really needed this confirmation.
Still, please let us know if you find out why that DOCX file cannot be converted (or if you report your internal issue, so we can track that ticket).

@vmimic

I have reproduced java.lang.NullPointerException when converting DOCX file with GroupDocs.Viewer for Java 24.8 but I cant reproduce the same issue with GroupDocs.Total. I was using this sample applications:

Can you please update conversion-sample-app.zip or attach your sample application?

I have reported the issue in our internal bug tracker. The issue ID is VIEWERJAVA-3637.

I’m using your samples, from your github repo for GroupDocs.VIewer, running Spring demo. None of the code changed, I’ve tried it as is.

The error in UI:
image.png (7.3 KB)

The error in console"
log.zip (1.7 KB)

@vmimic

Thank you for the details. It is the same issue. We’ll take a look and update you.

1 Like