Class PageResizer

java.lang.Object
com.itextpdf.kernel.pdf.PageResizer

public class PageResizer extends Object
The PageResizer class provides functionality to resize PDF pages to a specified target page size using various resizing methods. It adjusts page dimensions, content, annotations, and resources accordingly, also supports configuration options for maintaining the aspect ratio during the resize operation.
  • Constructor Details

    • PageResizer

      public PageResizer (PageSize size, PageResizer.ResizeType type)
      Constructs a new PageResizer instance with the specified page size and resize type.
      Parameters:
      size - the target page size to which the content should be resized
      type - the resizing method to be applied, such as maintaining the aspect ratio
  • Method Details

    • getHorizontalAnchorPoint

      public PageResizer.HorizontalAnchorPoint getHorizontalAnchorPoint()
      Retrieves the horizontal anchor point of the PageResizer.
      Returns:
      the horizontal anchor point, which determines the horizontal alignment (e.g., LEFT, CENTER, RIGHT).
    • setHorizontalAnchorPoint

      public void setHorizontalAnchorPoint (PageResizer.HorizontalAnchorPoint anchorPoint)
      Sets the horizontal anchor point, which determines how the horizontal alignment is handled (e.g., LEFT, CENTER, RIGHT).
      Parameters:
      anchorPoint - the horizontal anchor point to set; it specifies the horizontal alignment type for resizing operations
    • getVerticalAnchorPoint

      public PageResizer.VerticalAnchorPoint getVerticalAnchorPoint()
      Retrieves the vertical anchor point of the PageResizer.
      Returns:
      the vertical anchor point, which determines the vertical alignment (e.g., TOP, CENTER, BOTTOM).
    • setVerticalAnchorPoint

      public void setVerticalAnchorPoint (PageResizer.VerticalAnchorPoint anchorPoint)
      Sets the vertical anchor point, which determines how the vertical alignment is handled (e.g., TOP, CENTER, BOTTOM).
      Parameters:
      anchorPoint - the vertical anchor point to set; it specifies the vertical alignment type for resizing operations
    • resize

      public void resize (PdfPage page)
      Resizes a given PDF page based on the specified dimensions and resize type. Depending on the resize type, the aspect ratio may be maintained during scaling. Updates the page's content, annotations, and resources to reflect the new size.
      Parameters:
      page - the PDF page to be resized