Class PdfToImageRenderer

java.lang.Object
com.itextpdf.pdfrender.PdfToImageRenderer

public class PdfToImageRenderer extends Object
The main class for rendering PDF files as images.
  • Method Details

    • renderPdf

      public static void renderPdf (File pdfFile, File outImagesDirectory) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfFile - the PDF file to be rendered
      outImagesDirectory - the directory, in which pdfRender will place the rendered images. Their names will respect the following format: "image%d" and %d will be replaced with the number of the page. PdfRenderImageType.JPEG, which will be the extension of the images, will be added automatically
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, File outImagesDirectory, RenderingProperties properties) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfFile - the PDF file to be rendered
      outImagesDirectory - the directory, in which pdfRender will place the rendered images. Their names will respect the following format: "image%d" and %d will be replaced with the number of the page. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, File outImagesDirectory) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImagesDirectory - the directory, in which pdfRender will place the rendered images. Their names will respect the following format: "image%d" and %d will be replaced with the number of the page. PdfRenderImageType.JPEG, which will be the extension of the images, will be added to the names automatically
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, File outImagesDirectory, RenderingProperties properties) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImagesDirectory - the directory, in which pdfRender will place the rendered images. Their names will respect the following format: "image%d" and %d will be replaced with the number of the page. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, String outImageFilePattern) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfFile - the PDF file to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. PdfRenderImageType.JPEG, which will be the extension of the images, will be added to the filename automatically
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, String outImageFilePattern, com.itextpdf.kernel.utils.PageRange range) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.

      Only pages, specified in the provided range, will be rendered.

      Parameters:
      pdfFile - the PDF file to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. PdfRenderImageType.JPEG, which will be the extension of the images, will be added to the filename automatically
      range - the range of pages which will be rendered
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, String outImageFilePattern) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes to images.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. PdfRenderImageType.JPEG, which will be the extension of the images, will be added to the filename automatically
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, String outImageFilePattern, com.itextpdf.kernel.utils.PageRange range) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes to images.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. PdfRenderImageType.JPEG, which will be the extension of the images, will be added to the filename automatically
      range - the range of pages which will be rendered
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, String outImageFilePattern, RenderingProperties properties) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes to images.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, String outImageFilePattern, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes to images.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      range - the range of pages which will be rendered
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, String outImageFilePattern, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.ImageFileReadyListener imageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes to images.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfStream - the stream of the PDF to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      range - the range of pages which will be rendered
      imageReadyListener - the event listener which is called when the image is ready.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, String outImageFilePattern, RenderingProperties properties) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.
      Parameters:
      pdfFile - the PDF file to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, String outImageFilePattern, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfFile - the PDF file to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      range - the range of pages which will be rendered
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, String outImageFilePattern, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.ImageFileReadyListener imageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided path to images.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfFile - the PDF file to be rendered
      outImageFilePattern - the string which defines the path and the format of the resultant images. The format specifier is of a form similar to the C printf format. In the most simple case just place a template '%d' in the filename which pdfRender will replace with the page number. The image extension is added automatically based on the PdfRenderImageType provided with RenderingProperties. By default it is PdfRenderImageType.JPEG
      properties - the properties which will define rendering process
      range - the range of pages which will be rendered
      imageReadyListener - the event listener which is called when the image is ready.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input or output file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.
      Parameters:
      pdfFile - the PDF file to be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfFile - the PDF file to be rendered
      range - the range of pages which will be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, RenderingProperties properties, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.
      Parameters:
      pdfFile - the PDF file to be rendered
      properties - the properties which will define rendering process. Note that imageType property will not be taken into account.
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (File pdfFile, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in a file with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfFile - the PDF file to be rendered
      properties - the properties which will define rendering process. Note that imageType property will not be taken into account.
      range - the range of pages which will be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, RenderingProperties properties, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.
      Parameters:
      pdfStream - the stream of the PDF to be rendered
      properties - the properties which will define rendering process. Note that imageType property will not be taken into account.
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfStream - the stream of the PDF to be rendered
      range - the range of pages which will be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed
    • renderPdf

      public static void renderPdf (InputStream pdfStream, RenderingProperties properties, com.itextpdf.kernel.utils.PageRange range, PdfToImageRenderer.BufferedImageReadyListener bufferedImageReadyListener) throws RenderingException, IOException
      Renders a PDF stored in the provided bytes with the provided PdfToImageRenderer.BufferedImageReadyListener to BufferedImage.

      Only pages specified in the provided range will be rendered.

      Parameters:
      pdfStream - the stream of the PDF to be rendered
      properties - the properties which will define rendering process. Note that imageType property will not be taken into account.
      range - the range of pages which will be rendered
      bufferedImageReadyListener - the event listener which is called when the image is rendered to BufferedImage.
      Throws:
      RenderingException - an error occurred while rendering the PDF. It could be caused by different reasons: for example, when the PDF contains unsupported features (XFA) or some arguments are invalid (for example, too big page scaling is passed).
      IOException - input file could not be accessed