Package org.opencms.pdftools
Class CmsPdfThumbnailGenerator
- java.lang.Object
-
- org.opencms.pdftools.CmsPdfThumbnailGenerator
-
public class CmsPdfThumbnailGenerator extends java.lang.Object
Class for generating thumbnails from PDF documents using the PDFBox library.
-
-
Constructor Summary
Constructors Constructor Description CmsPdfThumbnailGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
generateThumbnail(java.io.InputStream pdfInputStream, int boxWidth, int boxHeight, java.lang.String imageFormat, int pageIndex)
Generates the image data for a thumbnail from a PDF.
-
-
-
Constructor Detail
-
CmsPdfThumbnailGenerator
public CmsPdfThumbnailGenerator()
-
-
Method Detail
-
generateThumbnail
public byte[] generateThumbnail(java.io.InputStream pdfInputStream, int boxWidth, int boxHeight, java.lang.String imageFormat, int pageIndex) throws java.lang.Exception
Generates the image data for a thumbnail from a PDF.The given width and height determine the box in which the thumbnail should fit. The resulting image will always have these dimensions, even if the aspect ratio of the actual PDF page is different from the ratio of the given width and height. In this case, the size of the rendered page will be reduced, and the rest of the image will be filled with blank space.
If one of width or height is negative, then that dimension is chosen so the resulting aspect ratio is the aspect ratio of the PDF page.
- Parameters:
pdfInputStream
- the input stream for reading the PDF databoxWidth
- the width of the box in which the thumbnail should fitboxHeight
- the height of the box in which the thumbnail should fitimageFormat
- the image format (png, jpg, gif)pageIndex
- the index of the page for which to render the thumbnail (starting at 0)- Returns:
- the image data for the thumbnail, in the given image format
- Throws:
java.lang.Exception
- if something goes wrong
-
-