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

Details

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

    Description

      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;
        }
      	
      }
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

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