Preventing Inaccurate or Incomplete PDF Document Previews

This article is a legacy article. It applies to previous versions of the Liferay product. While the article is no longer maintained, the information may still be applicable.

Generating Previews of PDF Documents using PDFBox can lead to the generation of incomplete or inaccurate results, such as previews without text or images.

This is due to these variables:

  1. The version of PDF Document.

    The versions where this issue is observed is version 1.4, 1.5, 1.6, and 1.7.

  2. The Font Encoding.

    The font encodings (whether embedded or unembedded): “WinAnsi”, “Custom”, and “Identity-H”

For instance, issues were encountered when using the below combinations:

  1. Version of PDF Document 1.4, 1.5, or 1.6 and font encoding “Custom” and/or “Identity-H.” The result is that previews are generated incorrectly with no text.
  2. Version of the PDF document 1.7 and any font encoding. The result is that previews are generated with no text and without images.

Resolution

The resolution for this issue is to configure Liferay to use ImageMagick + Ghostscript to generate previews of PDF Documents. In our tests, ImageMagick version 6.7.7-10 and Ghostscript version 9.14 were used. Here you can find instructions to configure Liferay to use ImageMagick and Ghostscript.

The result of these combinations is that PDF Document previews are generated correctly regardless of the Font Encoding.

这篇文章有帮助吗?
0 人中有 0 人觉得有帮助