-
Bug
-
Resolution: Fixed
-
Neutral
-
2.1.3
-
None
-
-
Empty show more show less
-
Yes
-
Saigon 31
-
5
The DAM-preview module uses PDFBox from sub which cannot parse pdf file newer then version 1.4.
The following error will be thrown:
com.sun.pdfview.PDFParseException: Expected 'xref' at start of table
in class info.magnolia.imaging.operations.load#loadSource()
By using a new library (like Apache PDFBox) and updating the ViaPDFRenderer, a preview can be created within the dam-app browser
e.g.
pom.xml
<dependency> <groupId>org.apache.pdfbox</groupId> <artifactId>pdfbox</artifactId> <version>1.8.1</version> </dependency>
Bar.java
public class ViaPdfRenderer extends FromBinaryNode { @Override protected BufferedImage doReadAndClose(InputStream inputStream) throws IOException, ImagingException { // Parse the PDF PDFParser pdfParser = new PDFParser(inputStream); pdfParser.parse(); // Get the document PDDocument document = pdfParser.getPDDocument(); // Get all pages @SuppressWarnings("unchecked") List<PDPage> pages = document.getDocumentCatalog().getAllPages(); if (pages == null || pages.size() == 0) { document.close(); return null; } // Get the first page PDPage page = pages.get(0); // Generate the image BufferedImage image = page.convertToImage(); // Close the document document.close(); return image; } }
Acceptance criteria
- is cloned by
-
MAGNOLIA-6555 Manage version of pdfbox in main
- Closed