public class LayerUtility extends Object
| Constructor and Description |
|---|
LayerUtility(PDDocument document)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
PDOptionalContentGroup |
appendFormAsLayer(PDPage targetPage,
PDFormXObject form,
AffineTransform transform,
String layerName)
Places the given form over the existing content of the indicated page (like an overlay).
|
PDDocument |
getDocument()
Returns the PDF document we work on.
|
PDFormXObject |
importPageAsForm(PDDocument sourceDoc,
int pageNumber)
Imports a page from some PDF file as a Form XObject so it can be placed on another page
in the target document.
|
PDFormXObject |
importPageAsForm(PDDocument sourceDoc,
PDPage page)
Imports a page from some PDF file as a Form XObject so it can be placed on another page
in the target document.
|
void |
wrapInSaveRestore(PDPage page)
Some applications may not wrap their page content in a save/restore (q/Q) pair which can
lead to problems with coordinate system transformations when content is appended.
|
public LayerUtility(PDDocument document)
document - the PDF document to modifypublic PDDocument getDocument()
public void wrapInSaveRestore(PDPage page) throws IOException
page - the pageIOException - if an I/O error occurspublic PDFormXObject importPageAsForm(PDDocument sourceDoc, int pageNumber) throws IOException
sourceDoc - the source PDF document that contains the page to be copiedpageNumber - the page number of the page to be copiedIOException - if an I/O error occurspublic PDFormXObject importPageAsForm(PDDocument sourceDoc, PDPage page) throws IOException
sourceDoc - the source PDF document that contains the page to be copiedpage - the page in the source PDF document to be copiedIOException - if an I/O error occurspublic PDOptionalContentGroup appendFormAsLayer(PDPage targetPage, PDFormXObject form, AffineTransform transform, String layerName) throws IOException
PDOptionalContentProperties.targetPage - the target pageform - the form to placetransform - the transformation matrix that controls the placementlayerName - the name for the layer/OCG to produceIOException - if an I/O error occursCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.