Uploaded image for project: 'Magnolia DAM Module'
  1. Magnolia DAM Module
  2. MGNLDAM-559

DAM Preview module cannot create thumbnail for PDF files version 1.4+

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 2.1.4
    • 2.1.3
    • None

      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

              ngoc.nguyenthanh Ngoc Nguyenthanh
              jdiepeveen Jordie Diepeveen
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - 3d
                    3d
                    Remaining:
                    Time Spent - 2d Remaining Estimate - 1d
                    1d
                    Logged:
                    Time Spent - 2d Remaining Estimate - 1d
                    2d