public class PDFFactory extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PDF_RESOLUTION
Resolution of the User Space coordinate system (72dpi).
|
Constructor and Description |
---|
PDFFactory(PDFDocument document)
Creates a new PDFFactory.
|
Modifier and Type | Method and Description |
---|---|
Object |
createPDFEncoding(SingleByteEncoding encoding,
String fontName)
Creates a PDFEncoding instance from a CodePointMapping instance.
|
PDFDocument |
getDocument()
Returns the parent PDFDocument associated with this factory.
|
PDFAction |
getExternalAction(String target,
boolean newWindow)
Create/find and return the appropriate external PDFAction according to the target
|
String |
getGoToReference(String pdfPageRef,
float yoffset)
Create or find a PDF GoTo with the given page reference string and Y offset,
and return its PDF object reference
|
PDFGoTo |
getPDFGoTo(String pdfPageRef,
Point2D position)
Finds and returns a PDFGoTo to the given page and position.
|
protected PDFDestination |
getUniqueDestination(PDFDestination newdest)
Registers and returns newdest if it is unique.
|
PDFAnnotList |
makeAnnotList()
Make an annotation list object
|
PDFArray |
makeArray(int[] values)
Make an Array object (ex.
|
PDFDestination |
makeDestination(String idRef,
Object goToRef)
Make a named destination.
|
PDFDests |
makeDests(List destinationList)
Make a the head object of the name dictionary (the /Dests object).
|
void |
makeDPart(PDFPage page,
String pageMasterName) |
PDFDPartRoot |
makeDPartRoot() |
PDFEncoding |
makeEncoding(String encodingName)
make a /Encoding object
|
PDFFont |
makeFont(String fontname,
String basefont,
String encoding,
FontMetrics metrics,
FontDescriptor descriptor)
Make a Type1 /Font object.
|
AbstractPDFStream |
makeFontFile(FontDescriptor desc,
String fontPrefix)
Embeds a font.
|
PDFFunction |
makeFunction(List domain,
List range,
float[] cZero,
float[] cOne,
double interpolationExponentN)
make a type Exponential interpolation function
(for shading usually)
|
PDFGState |
makeGState(Map settings,
PDFGState current)
make an ExtGState for extra graphics options
This tries to find a GState that will setup the correct values
for the current context.
|
PDFICCBasedColorSpace |
makeICCBasedColorSpace(PDFResourceContext res,
String explicitName,
PDFICCStream iccStream)
Makes a new ICCBased color space and registers it in the resource context.
|
protected PDFInfo |
makeInfo(String prod)
make an /Info object
|
PDFLayer |
makeLayer(String id) |
PDFLink |
makeLink(Rectangle2D rect,
PDFAction pdfAction)
Create a PDF link to an existing PDFAction object
|
PDFLink |
makeLink(Rectangle2D rect,
String dest,
boolean isNamedDestination)
Make an internal link.
|
PDFLink |
makeLink(Rectangle2D rect,
String destination,
int linkType,
float yoffset)
Make a
PDFLink object |
PDFLink |
makeLink(Rectangle2D rect,
String page,
String dest)
Make an internal link.
|
PDFMetadata |
makeMetadata(org.apache.xmlgraphics.xmp.Metadata meta,
boolean readOnly)
Make a Metadata object.
|
PDFNames |
makeNames()
Make a names dictionary (the /Names object).
|
PDFNameTreeNode |
makeNameTreeNode()
Make a name tree node.
|
PDFNavigator |
makeNavigator(String id) |
PDFOutline |
makeOutline(PDFOutline parent,
String label,
PDFAction pdfAction,
boolean showSubItems)
Make an outline object and add it to the given parent
|
PDFOutline |
makeOutline(PDFOutline parent,
String label,
PDFReference actionRef,
boolean showSubItems)
Make an outline object and add it to the given parent
|
PDFOutline |
makeOutline(PDFOutline parent,
String label,
String destination,
float yoffset,
boolean showSubItems)
Make an outline object and add it to the given outline
|
PDFOutputIntent |
makeOutputIntent()
Make a OutputIntent dictionary.
|
PDFPage |
makePage(PDFResources resources,
int pageWidth,
int pageHeight)
Make a /Page object.
|
PDFPage |
makePage(PDFResources resources,
int pageWidth,
int pageHeight,
int pageIndex)
Make a /Page object.
|
PDFPage |
makePage(PDFResources resources,
int pageIndex,
Rectangle2D mediaBox,
Rectangle2D cropBox,
Rectangle2D bleedBox,
Rectangle2D trimBox)
Make a /Page object.
|
PDFPageLabels |
makePageLabels()
Make a names dictionary (the /PageLabels object).
|
PDFPages |
makePages()
Make a /Pages object.
|
PDFPattern |
makePattern(PDFResourceContext res,
int thePatternType,
PDFResources theResources,
int thePaintType,
int theTilingType,
List theBBox,
double theXStep,
double theYStep,
List theMatrix,
List theXUID,
StringBuffer thePatternDataStream)
Make a tiling pattern
|
PDFICCStream |
makePDFICCStream()
Create a PDFICCStream
|
PDFResources |
makeResources()
Make a /Resources object.
|
PDFRoot |
makeRoot(PDFPages pages)
Make a /Catalog (Root) object.
|
PDFSeparationColorSpace |
makeSeparationColorSpace(PDFResourceContext res,
org.apache.xmlgraphics.java2d.color.NamedColorSpace ncs)
Create a new Separation color space.
|
PDFSetOCGStateAction |
makeSetOCGStateAction(String id) |
PDFStream |
makeStream(String type,
boolean add)
Make a stream object
|
PDFTransitionAction |
makeTransitionAction(String id) |
PDFFunction |
registerFunction(PDFFunction function)
Registers a function against the document
|
PDFPattern |
registerPattern(PDFResourceContext res,
PDFPattern pattern) |
PDFShading |
registerShading(PDFResourceContext res,
PDFShading shading)
Registers a shading object against the document
|
void |
setEventBroadcaster(EventBroadcaster eventBroadcaster) |
public static final int DEFAULT_PDF_RESOLUTION
public PDFFactory(PDFDocument document)
document
- the parent PDFDocument needed to register the generated
objectspublic final PDFDocument getDocument()
public PDFRoot makeRoot(PDFPages pages)
pages
- the pages pdf object that the root points topublic PDFPages makePages()
public PDFResources makeResources()
protected PDFInfo makeInfo(String prod)
prod
- string indicating application producing the PDFpublic PDFMetadata makeMetadata(org.apache.xmlgraphics.xmp.Metadata meta, boolean readOnly)
meta
- the DOM Document containing the XMP metadata.readOnly
- true if the metadata packet should be marked read-onlypublic PDFOutputIntent makeOutputIntent()
public PDFPage makePage(PDFResources resources, int pageIndex, Rectangle2D mediaBox, Rectangle2D cropBox, Rectangle2D bleedBox, Rectangle2D trimBox)
resources
- resources object to usepageIndex
- index of the page (zero-based)mediaBox
- the MediaBox areacropBox
- the CropBox areableedBox
- the BleedBox areatrimBox
- the TrimBox areapublic PDFPage makePage(PDFResources resources, int pageWidth, int pageHeight, int pageIndex)
resources
- resources object to usepageWidth
- width of the page in pointspageHeight
- height of the page in pointspageIndex
- index of the page (zero-based)public PDFPage makePage(PDFResources resources, int pageWidth, int pageHeight)
resources
- resources object to usepageWidth
- width of the page in pointspageHeight
- height of the page in pointspublic PDFFunction makeFunction(List domain, List range, float[] cZero, float[] cOne, double interpolationExponentN)
domain
- List objects of Double objects.
This is the domain of the function.
See page 264 of the PDF 1.3 Spec.range
- List of Doubles that is the Range of the function.
See page 264 of the PDF 1.3 Spec.cZero
- This is a vector of Double objects which defines the function result
when x=0.
This attribute is optional.
It's described on page 268 of the PDF 1.3 spec.cOne
- This is a vector of Double objects which defines the function result
when x=1.
This attribute is optional.
It's described on page 268 of the PDF 1.3 spec.interpolationExponentN
- This is the inerpolation exponent.
This attribute is required.
PDF Spec page 268public PDFFunction registerFunction(PDFFunction function)
function
- The function to registerpublic PDFShading registerShading(PDFResourceContext res, PDFShading shading)
res
- The PDF resource contextshading
- The shading object to be registeredpublic PDFPattern makePattern(PDFResourceContext res, int thePatternType, PDFResources theResources, int thePaintType, int theTilingType, List theBBox, double theXStep, double theYStep, List theMatrix, List theXUID, StringBuffer thePatternDataStream)
res
- the PDF resource context to add the shading, may be nullthePatternType
- the type of pattern, which is 1 for tiling.theResources
- the resources associated with this patternthePaintType
- 1 or 2, colored or uncolored.theTilingType
- 1, 2, or 3, constant spacing, no distortion, or faster tilingtheBBox
- List of Doubles: The pattern cell bounding boxtheXStep
- horizontal spacingtheYStep
- vertical spacingtheMatrix
- Optional List of Doubles transformation matrixtheXUID
- Optional vector of Integers that uniquely identify the patternthePatternDataStream
- The stream of pattern data to be tiled.public PDFPattern registerPattern(PDFResourceContext res, PDFPattern pattern)
protected PDFDestination getUniqueDestination(PDFDestination newdest)
newdest
- a new, as yet unregistered destinationpublic PDFDestination makeDestination(String idRef, Object goToRef)
idRef
- ID Reference for this destination (the name of the destination)goToRef
- Object reference to the GoTo Actionpublic PDFNames makeNames()
public PDFPageLabels makePageLabels()
public PDFDests makeDests(List destinationList)
destinationList
- a list of PDFDestination instancespublic PDFNameTreeNode makeNameTreeNode()
public PDFLink makeLink(Rectangle2D rect, PDFAction pdfAction)
rect
- the hotspot position in absolute coordinatespdfAction
- the PDFAction that this link refers topublic PDFLink makeLink(Rectangle2D rect, String page, String dest)
rect
- the hotspot position in absolute coordinatespage
- the target page reference valuedest
- the position destinationpublic PDFLink makeLink(Rectangle2D rect, String dest, boolean isNamedDestination)
rect
- the hotspot position in absolute coordinatesdest
- the position destinationisNamedDestination
- set to true if dest param is a named destinationpublic PDFLink makeLink(Rectangle2D rect, String destination, int linkType, float yoffset)
PDFLink
objectrect
- the clickable rectangledestination
- the destination filelinkType
- the link typeyoffset
- the yoffset on the page for an internal linkpublic PDFAction getExternalAction(String target, boolean newWindow)
target
- The external target. This may be a PDF file name
(optionally with internal page number or destination) or any type of URI.newWindow
- boolean indicating whether the target should be
displayed in a new windowpublic String getGoToReference(String pdfPageRef, float yoffset)
pdfPageRef
- the PDF page reference, e.g. "23 0 R"yoffset
- the distance from the bottom of the page in pointspublic PDFGoTo getPDFGoTo(String pdfPageRef, Point2D position)
pdfPageRef
- the PDF page referenceposition
- the (X,Y) position in pointspublic PDFOutline makeOutline(PDFOutline parent, String label, PDFReference actionRef, boolean showSubItems)
parent
- the parent PDFOutline object (may be null)label
- the title for the new outline objectactionRef
- the action reference string to be placed after the /AshowSubItems
- whether to initially display child outline itemspublic PDFOutline makeOutline(PDFOutline parent, String label, PDFAction pdfAction, boolean showSubItems)
parent
- the parent PDFOutline object (may be null)label
- the title for the new outline objectpdfAction
- the action that this outline item points to - must not be null!showSubItems
- whether to initially display child outline itemspublic PDFOutline makeOutline(PDFOutline parent, String label, String destination, float yoffset, boolean showSubItems)
parent
- parent PDFOutline object which may be nulllabel
- the title for the new outline objectdestination
- the reference string for the action to go toyoffset
- the yoffset on the destination pageshowSubItems
- whether to initially display child outline itemspublic PDFEncoding makeEncoding(String encodingName)
encodingName
- character encoding scheme namepublic PDFFont makeFont(String fontname, String basefont, String encoding, FontMetrics metrics, FontDescriptor descriptor)
fontname
- internal name to use for this font (eg "F1")basefont
- name of the base font (eg "Helvetica")encoding
- character encoding scheme used by the fontmetrics
- additional information about the fontdescriptor
- additional information about the fontpublic Object createPDFEncoding(SingleByteEncoding encoding, String fontName)
encoding
- the code point mapping (encoding)fontName
- ...public AbstractPDFStream makeFontFile(FontDescriptor desc, String fontPrefix)
desc
- FontDescriptor of the font.public PDFStream makeStream(String type, boolean add)
type
- the type of stream to be createdadd
- if true then the stream will be added immediatelypublic PDFICCStream makePDFICCStream()
PDFImageXObject
,
PDFDeviceColorSpace
public PDFICCBasedColorSpace makeICCBasedColorSpace(PDFResourceContext res, String explicitName, PDFICCStream iccStream)
res
- the PDF resource context to add the shading, may be nullexplicitName
- the explicit name for the color space, may be nulliccStream
- the ICC stream to associate with this color spacepublic PDFSeparationColorSpace makeSeparationColorSpace(PDFResourceContext res, org.apache.xmlgraphics.java2d.color.NamedColorSpace ncs)
res
- the resource context (may be null)ncs
- the named color space to map to a separation color spacepublic PDFArray makeArray(int[] values)
values
- the int array valuespublic PDFGState makeGState(Map settings, PDFGState current)
settings
- the settings required by the callercurrent
- the current GState of the current PDF contextpublic PDFAnnotList makeAnnotList()
public PDFSetOCGStateAction makeSetOCGStateAction(String id)
public PDFTransitionAction makeTransitionAction(String id)
public PDFNavigator makeNavigator(String id)
public PDFDPartRoot makeDPartRoot()
public void setEventBroadcaster(EventBroadcaster eventBroadcaster)
Copyright © 2023 Apache Software Foundation. All rights reserved.