Package com.openhtmltopdf.pdfboxout
Interface PdfBoxOutputDevice
-
- All Superinterfaces:
OutputDevice
- All Known Implementing Classes:
PdfBoxFastOutputDevice
,PdfBoxSlowOutputDevice
public interface PdfBoxOutputDevice extends OutputDevice
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMetadata(java.lang.String name, java.lang.String value)
Appends a name/content metadata pair to this output device.void
clip(java.awt.Shape s)
void
close()
Perform any internal cleanup neededvoid
draw(java.awt.Shape s)
void
drawBorderLine(java.awt.Shape bounds, int side, int lineWidth, boolean solid)
void
drawImage(FSImage fsImage, int x, int y, boolean interpolate)
void
drawOval(int x, int y, int width, int height)
void
drawPdfAsImage(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject _src, java.awt.Rectangle contentBounds, float intrinsicWidth, float intrinsicHeight)
void
drawRect(int x, int y, int width, int height)
void
drawSelection(RenderingContext c, InlineText inlineText)
void
drawString(java.lang.String s, float x, float y, JustificationInfo info)
void
drawStringFast(java.lang.String s, float x, float y, JustificationInfo info, PdfBoxFontResolver.FontDescription desc, float fontSize)
void
drawWithGraphics(float x, float y, float width, float height, OutputDeviceGraphicsDrawer renderer)
Draw something using a Graphics2D at the given rectangle.void
fill(java.awt.Shape s)
void
fillOval(int x, int y, int width, int height)
void
fillRect(int x, int y, int width, int height)
java.util.List<PagePosition<Box>>
findPagePositionsByID(CssContext c, java.util.regex.Pattern pattern)
void
finish(RenderingContext c, Box root)
void
finishPage()
float
getAbsoluteTransformOriginX()
float
getAbsoluteTransformOriginY()
java.awt.Shape
getClip()
PdfContentStreamAdapter
getCurrentPage()
float
getDeviceLength(float length)
Given a value in dots units, converts to PDF points.float
getDotsPerPoint()
java.util.List<PdfBoxSlowOutputDevice.Metadata>
getMetadata()
java.lang.String
getMetadataByName(java.lang.String name)
Searches the metadata name/content pairs of the current document and returns the content value from the first pair with a matching name.java.util.List<java.lang.String>
getMetadataListByName(java.lang.String name)
Searches the metadata name/content pairs of the current document and returns any content values with a matching name in an ArrayList.org.apache.pdfbox.pdmodel.PDPage
getPage()
int
getPageRefY(Box box)
java.lang.Object
getRenderingHint(java.awt.RenderingHints.Key key)
SharedContext
getSharedContext()
int
getStartPageNo()
java.awt.Stroke
getStroke()
org.apache.pdfbox.pdmodel.PDDocument
getWriter()
void
initializePage(org.apache.pdfbox.pdmodel.PDPageContentStream currentPage, org.apache.pdfbox.pdmodel.PDPage page, float height)
Start a page.boolean
isFastRenderer()
The new (2018) fast renderer is in use.boolean
isPDF()
boolean
isSupportsCMYKColors()
boolean
isSupportsSelection()
float
normalizeY(float y, float pageHeight)
Converts a top down unit to a bottom up PDF unit for the specified page height.void
paintBackground(RenderingContext c, Box box)
We use paintBackground to do extra stuff such as processing links, forms and form controls.void
paintReplacedElement(RenderingContext c, BlockBox box)
void
popClip()
Reverts the last clip on the stack.void
popTransformLayer()
Reverts the transform on the stack.void
popTransforms(java.util.List<java.awt.geom.AffineTransform> inverse)
void
pushClip(java.awt.Shape s)
Applies a clip on the output device.void
pushTransformLayer(java.awt.geom.AffineTransform transform)
Applies a transform on the output device.java.util.List<java.awt.geom.AffineTransform>
pushTransforms(java.util.List<java.awt.geom.AffineTransform> transforms)
Apply the given transform on top of the current one in the PDF graphics stream.void
realizeImage(PdfBoxImage img)
void
setBidiReorderer(BidiReorderer reorderer)
void
setClip(java.awt.Shape s)
void
setColor(FSColor color)
void
setFont(FSFont font)
void
setMetadata(java.lang.String name, java.lang.String value)
Replaces all copies of the named metadata with a single value.void
setPaint(java.awt.Paint paint)
void
setRenderingContext(RenderingContext result)
void
setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object value)
void
setRoot(Box root)
void
setSharedContext(SharedContext sharedContext)
void
setStartPageNo(int startPageNo)
void
setStroke(java.awt.Stroke s)
void
setWriter(org.apache.pdfbox.pdmodel.PDDocument writer)
void
start(org.w3c.dom.Document doc)
void
translate(double tx, double ty)
-
Methods inherited from interface com.openhtmltopdf.extend.OutputDevice
drawDebugOutline, drawLinearGradient, drawText, drawTextDecoration, drawTextDecoration, endStructure, paintBackground, paintBorder, paintBorder, paintCollapsedBorder, startStructure
-
-
-
-
Method Detail
-
setWriter
void setWriter(org.apache.pdfbox.pdmodel.PDDocument writer)
-
getWriter
org.apache.pdfbox.pdmodel.PDDocument getWriter()
-
initializePage
void initializePage(org.apache.pdfbox.pdmodel.PDPageContentStream currentPage, org.apache.pdfbox.pdmodel.PDPage page, float height)
Start a page. A new PDF page starts a new content stream so all graphics state has to be set back to default.
-
finishPage
void finishPage()
-
paintReplacedElement
void paintReplacedElement(RenderingContext c, BlockBox box)
- Specified by:
paintReplacedElement
in interfaceOutputDevice
-
paintBackground
void paintBackground(RenderingContext c, Box box)
We use paintBackground to do extra stuff such as processing links, forms and form controls.- Specified by:
paintBackground
in interfaceOutputDevice
-
getDeviceLength
float getDeviceLength(float length)
Given a value in dots units, converts to PDF points.
-
drawBorderLine
void drawBorderLine(java.awt.Shape bounds, int side, int lineWidth, boolean solid)
- Specified by:
drawBorderLine
in interfaceOutputDevice
-
setColor
void setColor(FSColor color)
- Specified by:
setColor
in interfaceOutputDevice
-
draw
void draw(java.awt.Shape s)
- Specified by:
draw
in interfaceOutputDevice
-
drawRect
void drawRect(int x, int y, int width, int height)
- Specified by:
drawRect
in interfaceOutputDevice
-
drawOval
void drawOval(int x, int y, int width, int height)
- Specified by:
drawOval
in interfaceOutputDevice
-
fill
void fill(java.awt.Shape s)
- Specified by:
fill
in interfaceOutputDevice
-
fillRect
void fillRect(int x, int y, int width, int height)
- Specified by:
fillRect
in interfaceOutputDevice
-
fillOval
void fillOval(int x, int y, int width, int height)
- Specified by:
fillOval
in interfaceOutputDevice
-
translate
void translate(double tx, double ty)
- Specified by:
translate
in interfaceOutputDevice
-
getRenderingHint
java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
- Specified by:
getRenderingHint
in interfaceOutputDevice
-
setRenderingHint
void setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object value)
- Specified by:
setRenderingHint
in interfaceOutputDevice
-
setFont
void setFont(FSFont font)
- Specified by:
setFont
in interfaceOutputDevice
-
drawString
void drawString(java.lang.String s, float x, float y, JustificationInfo info)
-
drawStringFast
void drawStringFast(java.lang.String s, float x, float y, JustificationInfo info, PdfBoxFontResolver.FontDescription desc, float fontSize)
-
getCurrentPage
PdfContentStreamAdapter getCurrentPage()
-
getPage
org.apache.pdfbox.pdmodel.PDPage getPage()
-
normalizeY
float normalizeY(float y, float pageHeight)
Converts a top down unit to a bottom up PDF unit for the specified page height.
-
setStroke
void setStroke(java.awt.Stroke s)
- Specified by:
setStroke
in interfaceOutputDevice
-
clip
void clip(java.awt.Shape s)
- Specified by:
clip
in interfaceOutputDevice
-
getClip
java.awt.Shape getClip()
- Specified by:
getClip
in interfaceOutputDevice
-
popClip
void popClip()
Description copied from interface:OutputDevice
Reverts the last clip on the stack. The fast renderer MUST usepushClip
andpopClip
in preference toclip
andsetClip
. NOTE: The current implementation shares a stack between transforms and clips, so calls toOutputDevice.pushTransformLayer(AffineTransform)
,OutputDevice.popTransformLayer()
,OutputDevice.pushClip(Shape)
andOutputDevice.popClip()
MUST be nested correctly.- Specified by:
popClip
in interfaceOutputDevice
-
pushClip
void pushClip(java.awt.Shape s)
Description copied from interface:OutputDevice
Applies a clip on the output device. This is a cumulative operation. The fast renderer MUST usepushClip
andpopClip
in preference toclip
andsetClip
. NOTE: The current implementation shares a stack between transforms and clips, so calls toOutputDevice.pushTransformLayer(AffineTransform)
,OutputDevice.popTransformLayer()
,OutputDevice.pushClip(Shape)
andOutputDevice.popClip()
MUST be nested correctly.- Specified by:
pushClip
in interfaceOutputDevice
-
setClip
void setClip(java.awt.Shape s)
- Specified by:
setClip
in interfaceOutputDevice
-
getStroke
java.awt.Stroke getStroke()
- Specified by:
getStroke
in interfaceOutputDevice
-
realizeImage
void realizeImage(PdfBoxImage img)
-
drawImage
void drawImage(FSImage fsImage, int x, int y, boolean interpolate)
- Specified by:
drawImage
in interfaceOutputDevice
-
getDotsPerPoint
float getDotsPerPoint()
-
start
void start(org.w3c.dom.Document doc)
-
finish
void finish(RenderingContext c, Box root)
-
addMetadata
void addMetadata(java.lang.String name, java.lang.String value)
Appends a name/content metadata pair to this output device. A name or content value of null will be ignored.- Parameters:
name
- the name of the metadata element to add.
-
getMetadataByName
java.lang.String getMetadataByName(java.lang.String name)
Searches the metadata name/content pairs of the current document and returns the content value from the first pair with a matching name. The search is case insensitive.- Parameters:
name
- the metadata element name to locate.- Returns:
- the content value of the first found metadata element; otherwise null.
-
getMetadataListByName
java.util.List<java.lang.String> getMetadataListByName(java.lang.String name)
Searches the metadata name/content pairs of the current document and returns any content values with a matching name in an ArrayList. The search is case insensitive.- Parameters:
name
- the metadata element name to locate.- Returns:
- an ArrayList with matching content values; otherwise an empty list.
-
setMetadata
void setMetadata(java.lang.String name, java.lang.String value)
Replaces all copies of the named metadata with a single value. A a new value of null will result in the removal of all copies of the named metadata. UseaddMetadata
to append additional values with the same name.- Parameters:
name
- the metadata element name to locate.
-
getSharedContext
SharedContext getSharedContext()
-
setSharedContext
void setSharedContext(SharedContext sharedContext)
-
setRoot
void setRoot(Box root)
-
getStartPageNo
int getStartPageNo()
-
setStartPageNo
void setStartPageNo(int startPageNo)
-
drawSelection
void drawSelection(RenderingContext c, InlineText inlineText)
- Specified by:
drawSelection
in interfaceOutputDevice
-
isSupportsSelection
boolean isSupportsSelection()
- Specified by:
isSupportsSelection
in interfaceOutputDevice
-
isSupportsCMYKColors
boolean isSupportsCMYKColors()
- Specified by:
isSupportsCMYKColors
in interfaceOutputDevice
-
drawWithGraphics
void drawWithGraphics(float x, float y, float width, float height, OutputDeviceGraphicsDrawer renderer)
Description copied from interface:OutputDevice
Draw something using a Graphics2D at the given rectangle.- Specified by:
drawWithGraphics
in interfaceOutputDevice
-
findPagePositionsByID
java.util.List<PagePosition<Box>> findPagePositionsByID(CssContext c, java.util.regex.Pattern pattern)
-
setRenderingContext
void setRenderingContext(RenderingContext result)
-
setBidiReorderer
void setBidiReorderer(BidiReorderer reorderer)
-
popTransforms
void popTransforms(java.util.List<java.awt.geom.AffineTransform> inverse)
- Specified by:
popTransforms
in interfaceOutputDevice
-
pushTransforms
java.util.List<java.awt.geom.AffineTransform> pushTransforms(java.util.List<java.awt.geom.AffineTransform> transforms)
Description copied from interface:OutputDevice
Apply the given transform on top of the current one in the PDF graphics stream. This is a cumulative operation. You should popTransform after the box and children are painted.- Specified by:
pushTransforms
in interfaceOutputDevice
- Returns:
- the list of inverse transforms to undo the effect of this transform
-
getAbsoluteTransformOriginX
float getAbsoluteTransformOriginX()
- Specified by:
getAbsoluteTransformOriginX
in interfaceOutputDevice
-
getAbsoluteTransformOriginY
float getAbsoluteTransformOriginY()
- Specified by:
getAbsoluteTransformOriginY
in interfaceOutputDevice
-
setPaint
void setPaint(java.awt.Paint paint)
- Specified by:
setPaint
in interfaceOutputDevice
-
isPDF
boolean isPDF()
- Specified by:
isPDF
in interfaceOutputDevice
-
close
void close()
Perform any internal cleanup needed
-
pushTransformLayer
void pushTransformLayer(java.awt.geom.AffineTransform transform)
Description copied from interface:OutputDevice
Applies a transform on the output device. This is a cumulativew operation. NOTE: The current implementation shares a stack between transforms and clips, so calls toOutputDevice.pushTransformLayer(AffineTransform)
,OutputDevice.popTransformLayer()
,OutputDevice.pushClip(Shape)
andOutputDevice.popClip()
MUST be nested correctly.- Specified by:
pushTransformLayer
in interfaceOutputDevice
-
popTransformLayer
void popTransformLayer()
Description copied from interface:OutputDevice
Reverts the transform on the stack. NOTE: The current implementation shares a stack between transforms and clips, so calls toOutputDevice.pushTransformLayer(AffineTransform)
,OutputDevice.popTransformLayer()
,OutputDevice.pushClip(Shape)
andOutputDevice.popClip()
MUST be nested correctly.- Specified by:
popTransformLayer
in interfaceOutputDevice
-
isFastRenderer
boolean isFastRenderer()
Description copied from interface:OutputDevice
The new (2018) fast renderer is in use.- Specified by:
isFastRenderer
in interfaceOutputDevice
-
getPageRefY
int getPageRefY(Box box)
-
getMetadata
java.util.List<PdfBoxSlowOutputDevice.Metadata> getMetadata()
-
drawPdfAsImage
void drawPdfAsImage(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject _src, java.awt.Rectangle contentBounds, float intrinsicWidth, float intrinsicHeight)
-
-