Package com.itextpdf.kernel.pdf
Class PageResizer
java.lang.Object
com.itextpdf.kernel.pdf.PageResizer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the horizontal anchor point used in the resizing and alignment of a page or content.static enumEnum representing the available types of resizing strategies when modifying the dimensions of a PDF page.static enumRepresents the vertical alignment points used for resizing or aligning elements, particularly in the context of page rescaling. -
Constructor Summary
ConstructorsConstructorDescriptionPageResizer(PageSize size, PageResizer.ResizeType type) Constructs a new PageResizer instance with the specified page size and resize type. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the horizontal anchor point of the PageResizer.Retrieves the vertical anchor point of the PageResizer.voidResizes a given PDF page based on the specified dimensions and resize type.voidSets the horizontal anchor point, which determines how the horizontal alignment is handled (e.g., LEFT, CENTER, RIGHT).voidsetVerticalAnchorPoint(PageResizer.VerticalAnchorPoint anchorPoint) Sets the vertical anchor point, which determines how the vertical alignment is handled (e.g., TOP, CENTER, BOTTOM).
-
Constructor Details
-
PageResizer
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
Retrieves the horizontal anchor point of the PageResizer.- Returns:
- the horizontal anchor point, which determines the horizontal alignment (e.g., LEFT, CENTER, RIGHT).
-
setHorizontalAnchorPoint
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
Retrieves the vertical anchor point of the PageResizer.- Returns:
- the vertical anchor point, which determines the vertical alignment (e.g., TOP, CENTER, BOTTOM).
-
setVerticalAnchorPoint
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
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
-