Class Page
- java.lang.Object
-
- com.pdf_tools.fourheights.pdftoolbox.internal.NativeBase
-
- com.pdf_tools.fourheights.pdftoolbox.internal.NativeObject
-
- com.pdf_tools.fourheights.pdftoolbox.pdf.Page
-
public class Page extends NativeObject
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Page
copy(Document targetDocument, Page page, PageCopyOptions options)
Copy a pagestatic Page
create(Document targetDocument, Size size)
Create an empty pageAnnotationList
getAnnotations()
the list of this page's annotations.Rectangle
getArtBox()
The art box of the page.Rectangle
getBleedBox()
The bleed box of the page.Content
getContent()
the page content.LinkList
getLinks()
the list of this page's links.Rectangle
getMediaBox()
The media box of the page.Metadata
getMetadata()
the metadata of the page.Size
getSize()
the visible size of the page (crop box).Rectangle
getTrimBox()
The trim box of the page.WidgetList
getWidgets()
the list of this page's form field widgets.void
rotate(Rotation rotate)
Rotate the page by a multiple of 90 degrees.void
setMetadata(Metadata value)
the metadata of the page.void
updateSize(Rectangle rectangle)
Update the page size to a specified rectangle.-
Methods inherited from class com.pdf_tools.fourheights.pdftoolbox.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
create
public static Page create(Document targetDocument, Size size)
Create an empty page
The page is associated with the given target document but not yet part of it. It can be appended to the document's page list.- Parameters:
targetDocument
- the output document with which the returned object is associatedsize
- the page size- Returns:
- the newly created page object
- Throws:
java.lang.IllegalArgumentException
- if thetargetDocument
argument has already been closedjava.lang.IllegalArgumentException
- if thetargetDocument
argument is read-onlyjava.lang.IllegalArgumentException
- iftargetDocument
isnull
java.lang.IllegalArgumentException
- ifsize
isnull
-
copy
public static Page copy(Document targetDocument, Page page, PageCopyOptions options) throws java.io.IOException, CorruptException, ConformanceException
Copy a page
Copy a page object from an input document to the giventargetDocument
. The returned object is associated with the given target document but not yet part of it. It can be appended to the document's page list.- Parameters:
targetDocument
- the output document with which the returned object is associatedpage
- a page of a different documentoptions
- the copy options- Returns:
- the copied page, associated with the current document.
- Throws:
java.io.IOException
- Error reading from the source document or writing to the target documentCorruptException
- The source document is corruptConformanceException
- The conformance level of the source document is not compatible with the conformance level of the target document.ConformanceException
- The explicitly requested conformance level is PDF/A Level A (Conformance.PDF_A1_A
,Conformance.PDF_A2_A
, orConformance.PDF_A3_A
) and the copy optionPageCopyOptions.getCopyLogicalStructure()
is not set.java.lang.IllegalArgumentException
- if thetargetDocument
argument has already been closedjava.lang.IllegalArgumentException
- if thetargetDocument
argument is read-onlyjava.lang.IllegalArgumentException
- if thepage
object is not associated with an input documentjava.lang.IllegalArgumentException
- if the document associated with thepage
object has already been closedjava.lang.IllegalArgumentException
- if the argumentoptions
hasPageCopyOptions.getFormFields()
set toforms.FormFieldCopyStrategy.COPY
and thetargetDocument
contains form fields that have either been copied explicitly withforms.FieldNode.copy
or created withforms.CheckBox.create
,forms.ComboBox.create
,forms.CombTextField.create
,forms.GeneralTextField.create
,forms.ListBox.create
,forms.RadioButtonGroup.create
, orforms.SubForm.create
.java.lang.IllegalArgumentException
- if the argumentoptions
hasPageCopyOptions.getUnsignedSignatures()
set toCopyStrategy.COPY
and thetargetDocument
contains form fields that have either been copied explicitly withforms.FieldNode.copy
or created withforms.CheckBox.create
,forms.ComboBox.create
,forms.CombTextField.create
,forms.GeneralTextField.create
,forms.ListBox.create
,forms.RadioButtonGroup.create
, orforms.SubForm.create
.java.lang.IllegalArgumentException
- ifoptions
hasPageCopyOptions.getCopyOutlineItems()
set totrue
and thetargetDocument
contains outline items that have been copied explicitly withnavigation.OutlineItem.copy
.java.lang.IllegalArgumentException
- iftargetDocument
isnull
java.lang.IllegalArgumentException
- ifpage
isnull
-
updateSize
public void updateSize(Rectangle rectangle)
Update the page size to a specified rectangle.
Note that all page-related coordinates are normalized to the crop box of the page. Updating the page size thus changes the coordinate system, rendering all previously extracted coordinates invalid.- Parameters:
rectangle
- the rectangle to update the page size to.- Throws:
java.lang.IllegalStateException
- if the owning document has already been closedjava.lang.IllegalStateException
- if the page has already been closedjava.lang.UnsupportedOperationException
- if the page is read-onlyjava.lang.IllegalArgumentException
- ifrectangle
isnull
-
rotate
public void rotate(Rotation rotate)
Rotate the page by a multiple of 90 degrees.
- Parameters:
rotate
- the desired rotation- Throws:
java.lang.IllegalStateException
- if the owning document has already been closedjava.lang.IllegalStateException
- if the page has already been closedjava.lang.UnsupportedOperationException
- if the page is read-onlyjava.lang.IllegalArgumentException
- ifrotate
isnull
-
getSize
public Size getSize()
the visible size of the page (crop box). (Getter)
The page size corresponds to the size of the crop box. Since all coordinates are normalized to the origin of the crop box, the normalized origin of the crop box is always (0,0) and thus only the size is required.
The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed. Unlike the other boxes, the crop box has no defined meaning in terms of physical page geometry or intended use; it merely imposes clipping on the page contents. However, in the absence of additional information (such as imposition instructions specified in a JDF job ticket), the crop box determines how the page's contents shall be positioned on the output medium. The default value is the page's media box.
This property cannot be
null
.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getMediaBox
public Rectangle getMediaBox()
The media box of the page. (Getter)
The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. It may also include areas close to the edges of the medium that cannot be marked because of physical limitations of the output device. Content falling outside this boundary may safely be discarded without affecting the meaning of the PDF file.
This property cannot be
null
.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getBleedBox
public Rectangle getBleedBox()
The bleed box of the page. (Getter)
The bleed box (PDF 1.3) defines the region to which the contents of the page shall be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The actual printed page may include printing marks that fall outside the bleed box. The default value is the page's crop box.
This property is
null
if the page contains no explicit bleed box.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getTrimBox
public Rectangle getTrimBox()
The trim box of the page. (Getter)
The trim box (PDF 1.3) defines the intended dimensions of the finished page after trimming. It may be smaller than the media box to allow for production-related content, such as printing instructions, cut marks, or colour bars. The default value is the page's crop box.
This property is
null
if the page contains no explicit trim box.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getArtBox
public Rectangle getArtBox()
The art box of the page. (Getter)
The art box (PDF 1.3) defines the extent of the page's meaningful content (including potential white-space) as intended by the page’s creator. The default value is the page's crop box.
This property is
null
if the page contains no explicit art box.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getContent
public Content getContent()
the page content. (Getter)
If the page is writable, the content object can be used to apply new content on the page, for example overlays or underlays.- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getAnnotations
public AnnotationList getAnnotations()
the list of this page's annotations. (Getter)
Adding to this list results in an error:- IllegalState if the list has already been closed
- UnsupportedOperation if the document is read-only
-
IllegalArgument
-
if the given annotation is
null
- if the given annotation object has already been closed
- if the given annotation does not belong to the same document as the list
- if the given annotation is already associated with a page
-
if the given annotation is
- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getLinks
public LinkList getLinks()
the list of this page's links. (Getter)
Adding to this list results in an error:- IllegalState if the list has already been closed
- UnsupportedOperation if the document is read-only
-
IllegalArgument
-
if the given link is
null
- if the given link object has already been closed
- if the given link does not belong to the same document as the list
- if the given link is already associated with a page
-
if the given link is
- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getWidgets
public WidgetList getWidgets()
the list of this page's form field widgets. (Getter)
Adding to this list results in an error:- IllegalState if the list has already been closed
- UnsupportedOperation if the document is read-only
-
IllegalArgument
-
if the given widget is
null
- if the given widget object has already been closed
- if the given widget does not belong to the same document as the list
- if the given widget is already associated with a page
-
if the given widget is
- Throws:
java.lang.IllegalStateException
- if the page has already been closed
-
getMetadata
public Metadata getMetadata()
the metadata of the page. (Getter)
If the document is writable, the metadata object will be writable too and all changes to the metadata object are reflected in the document.
This property is
null
if the page has not metadata.- Throws:
java.lang.IllegalStateException
- if the document has already been closed
-
setMetadata
public void setMetadata(Metadata value)
the metadata of the page. (Setter)
If the document is writable, the metadata object will be writable too and all changes to the metadata object are reflected in the document.
This property is
null
if the page has not metadata.- Throws:
java.lang.IllegalStateException
- if the document has already been closedjava.lang.UnsupportedOperationException
- if the document is read-onlyjava.lang.IllegalArgumentException
- if the givenMetadata
object belongs to a different documentjava.lang.IllegalArgumentException
- if the givenMetadata
object has already been closed
-
-