Package com.openhtmltopdf.pdfboxout
Class PdfBoxFastOutputDevice
- java.lang.Object
-
- com.openhtmltopdf.render.AbstractOutputDevice
-
- com.openhtmltopdf.pdfboxout.PdfBoxFastOutputDevice
-
- All Implemented Interfaces:
com.openhtmltopdf.extend.OutputDevice
,PdfBoxOutputDevice
public class PdfBoxFastOutputDevice extends com.openhtmltopdf.render.AbstractOutputDevice implements com.openhtmltopdf.extend.OutputDevice, PdfBoxOutputDevice
-
-
Constructor Summary
Constructors Constructor Description PdfBoxFastOutputDevice(float dotsPerPoint, boolean testMode, boolean pdfUaConform, boolean pdfAConform)
-
Method Summary
Modifier and Type Method Description void
addMetadata(String name, String value)
Appends a name/content metadata pair to this output device.void
clip(Shape s)
void
close()
Perform any internal cleanup neededvoid
draw(Shape s)
void
drawBorderLine(Shape bounds, int side, int lineWidth, boolean solid)
void
drawImage(com.openhtmltopdf.extend.FSImage fsImage, int x, int y, boolean interpolate)
protected void
drawLine(int x1, int y1, int x2, int y2)
void
drawOval(int x, int y, int width, int height)
void
drawPdfAsImage(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject _srcObject, Rectangle contentBounds, float intrinsicWidth, float intrinsicHeight)
void
drawRect(int x, int y, int width, int height)
void
drawSelection(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.InlineText inlineText)
void
drawString(String s, float x, float y, com.openhtmltopdf.render.JustificationInfo info)
void
drawStringFast(String s, float x, float y, com.openhtmltopdf.render.JustificationInfo info, PdfBoxFontResolver.FontDescription desc, float fontSize)
void
drawWithGraphics(float x, float y, float width, float height, com.openhtmltopdf.extend.OutputDeviceGraphicsDrawer renderer)
void
endStructure(Object token)
void
fill(Shape s)
void
fillOval(int x, int y, int width, int height)
void
fillRect(int x, int y, int width, int height)
List<PagePosition>
findPagePositionsByID(com.openhtmltopdf.css.style.CssContext c, Pattern pattern)
void
finish(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.Box root)
void
finishPage()
float
getAbsoluteTransformOriginX()
float
getAbsoluteTransformOriginY()
Shape
getClip()
PdfContentStreamAdapter
getCurrentPage()
float
getDeviceLength(float length)
Given a value in dots units, converts to PDF points.float
getDotsPerPoint()
List<com.openhtmltopdf.pdfboxout.PdfBoxSlowOutputDevice.Metadata>
getMetadata()
String
getMetadataByName(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.List<String>
getMetadataListByName(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(com.openhtmltopdf.render.Box box)
Object
getRenderingHint(RenderingHints.Key key)
com.openhtmltopdf.layout.SharedContext
getSharedContext()
int
getStartPageNo()
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()
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(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.Box box)
We use paintBackground to do extra stuff such as processing links, forms and form controls.void
paintReplacedElement(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.BlockBox box)
void
popClip()
void
popTransformLayer()
void
popTransforms(List<AffineTransform> inverse)
void
pushClip(Shape s)
void
pushTransformLayer(AffineTransform transform)
List<AffineTransform>
pushTransforms(List<AffineTransform> transforms)
void
realizeImage(PdfBoxImage img)
void
setBidiReorderer(com.openhtmltopdf.bidi.BidiReorderer reorderer)
void
setClip(Shape s)
void
setColor(com.openhtmltopdf.css.parser.FSColor color)
void
setFont(com.openhtmltopdf.render.FSFont font)
void
setMetadata(String name, String value)
Replaces all copies of the named metadata with a single value.void
setPaint(Paint paint)
void
setRenderingContext(com.openhtmltopdf.render.RenderingContext result)
void
setRenderingHint(RenderingHints.Key key, Object value)
void
setRoot(com.openhtmltopdf.render.Box root)
void
setSharedContext(com.openhtmltopdf.layout.SharedContext sharedContext)
void
setStartPageNo(int startPageNo)
void
setStroke(Stroke s)
void
setWriter(org.apache.pdfbox.pdmodel.PDDocument writer)
void
start(Document doc)
Object
startStructure(com.openhtmltopdf.extend.StructureType type, com.openhtmltopdf.render.Box box)
void
translate(double tx, double ty)
-
Methods inherited from class com.openhtmltopdf.render.AbstractOutputDevice
drawDebugOutline, drawText, drawTextDecoration, drawTextDecoration, getFontSpecification, paintBackground, paintBorder, paintBorder, paintCollapsedBorder, setFontSpecification
-
-
-
-
Method Detail
-
setWriter
public void setWriter(org.apache.pdfbox.pdmodel.PDDocument writer)
- Specified by:
setWriter
in interfacePdfBoxOutputDevice
-
getWriter
public org.apache.pdfbox.pdmodel.PDDocument getWriter()
- Specified by:
getWriter
in interfacePdfBoxOutputDevice
-
initializePage
public 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.- Specified by:
initializePage
in interfacePdfBoxOutputDevice
-
finishPage
public void finishPage()
- Specified by:
finishPage
in interfacePdfBoxOutputDevice
-
paintReplacedElement
public void paintReplacedElement(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.BlockBox box)
- Specified by:
paintReplacedElement
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
paintReplacedElement
in interfacePdfBoxOutputDevice
-
paintBackground
public void paintBackground(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.Box box)
We use paintBackground to do extra stuff such as processing links, forms and form controls.- Specified by:
paintBackground
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
paintBackground
in interfacePdfBoxOutputDevice
- Overrides:
paintBackground
in classcom.openhtmltopdf.render.AbstractOutputDevice
-
getDeviceLength
public float getDeviceLength(float length)
Given a value in dots units, converts to PDF points.- Specified by:
getDeviceLength
in interfacePdfBoxOutputDevice
-
drawBorderLine
public void drawBorderLine(Shape bounds, int side, int lineWidth, boolean solid)
- Specified by:
drawBorderLine
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawBorderLine
in interfacePdfBoxOutputDevice
-
setColor
public void setColor(com.openhtmltopdf.css.parser.FSColor color)
- Specified by:
setColor
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setColor
in interfacePdfBoxOutputDevice
-
draw
public void draw(Shape s)
- Specified by:
draw
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
draw
in interfacePdfBoxOutputDevice
-
drawLine
protected void drawLine(int x1, int y1, int x2, int y2)
- Specified by:
drawLine
in classcom.openhtmltopdf.render.AbstractOutputDevice
-
drawRect
public void drawRect(int x, int y, int width, int height)
- Specified by:
drawRect
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawRect
in interfacePdfBoxOutputDevice
-
drawOval
public void drawOval(int x, int y, int width, int height)
- Specified by:
drawOval
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawOval
in interfacePdfBoxOutputDevice
-
fill
public void fill(Shape s)
- Specified by:
fill
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
fill
in interfacePdfBoxOutputDevice
-
fillRect
public void fillRect(int x, int y, int width, int height)
- Specified by:
fillRect
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
fillRect
in interfacePdfBoxOutputDevice
-
fillOval
public void fillOval(int x, int y, int width, int height)
- Specified by:
fillOval
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
fillOval
in interfacePdfBoxOutputDevice
-
translate
public void translate(double tx, double ty)
- Specified by:
translate
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
translate
in interfacePdfBoxOutputDevice
-
getRenderingHint
public Object getRenderingHint(RenderingHints.Key key)
- Specified by:
getRenderingHint
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
getRenderingHint
in interfacePdfBoxOutputDevice
-
setRenderingHint
public void setRenderingHint(RenderingHints.Key key, Object value)
- Specified by:
setRenderingHint
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setRenderingHint
in interfacePdfBoxOutputDevice
-
setFont
public void setFont(com.openhtmltopdf.render.FSFont font)
- Specified by:
setFont
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setFont
in interfacePdfBoxOutputDevice
-
drawString
public void drawString(String s, float x, float y, com.openhtmltopdf.render.JustificationInfo info)
- Specified by:
drawString
in interfacePdfBoxOutputDevice
-
drawStringFast
public void drawStringFast(String s, float x, float y, com.openhtmltopdf.render.JustificationInfo info, PdfBoxFontResolver.FontDescription desc, float fontSize)
- Specified by:
drawStringFast
in interfacePdfBoxOutputDevice
-
getCurrentPage
public PdfContentStreamAdapter getCurrentPage()
- Specified by:
getCurrentPage
in interfacePdfBoxOutputDevice
-
getPage
public org.apache.pdfbox.pdmodel.PDPage getPage()
- Specified by:
getPage
in interfacePdfBoxOutputDevice
-
normalizeY
public float normalizeY(float y, float pageHeight)
Converts a top down unit to a bottom up PDF unit for the specified page height.- Specified by:
normalizeY
in interfacePdfBoxOutputDevice
-
setStroke
public void setStroke(Stroke s)
- Specified by:
setStroke
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setStroke
in interfacePdfBoxOutputDevice
-
clip
public void clip(Shape s)
- Specified by:
clip
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
clip
in interfacePdfBoxOutputDevice
-
getClip
public Shape getClip()
- Specified by:
getClip
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
getClip
in interfacePdfBoxOutputDevice
-
popClip
public void popClip()
- Specified by:
popClip
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
popClip
in interfacePdfBoxOutputDevice
-
pushClip
public void pushClip(Shape s)
- Specified by:
pushClip
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
pushClip
in interfacePdfBoxOutputDevice
-
setClip
public void setClip(Shape s)
- Specified by:
setClip
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setClip
in interfacePdfBoxOutputDevice
-
getStroke
public Stroke getStroke()
- Specified by:
getStroke
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
getStroke
in interfacePdfBoxOutputDevice
-
realizeImage
public void realizeImage(PdfBoxImage img)
- Specified by:
realizeImage
in interfacePdfBoxOutputDevice
-
drawImage
public void drawImage(com.openhtmltopdf.extend.FSImage fsImage, int x, int y, boolean interpolate)
- Specified by:
drawImage
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawImage
in interfacePdfBoxOutputDevice
-
drawPdfAsImage
public void drawPdfAsImage(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject _srcObject, Rectangle contentBounds, float intrinsicWidth, float intrinsicHeight)
- Specified by:
drawPdfAsImage
in interfacePdfBoxOutputDevice
-
getDotsPerPoint
public float getDotsPerPoint()
- Specified by:
getDotsPerPoint
in interfacePdfBoxOutputDevice
-
start
public void start(Document doc)
- Specified by:
start
in interfacePdfBoxOutputDevice
-
finish
public void finish(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.Box root)
- Specified by:
finish
in interfacePdfBoxOutputDevice
-
getPageRefY
public int getPageRefY(com.openhtmltopdf.render.Box box)
- Specified by:
getPageRefY
in interfacePdfBoxOutputDevice
-
addMetadata
public void addMetadata(String name, String value)
Appends a name/content metadata pair to this output device. A name or content value of null will be ignored.- Specified by:
addMetadata
in interfacePdfBoxOutputDevice
- Parameters:
name
- the name of the metadata element to add.
-
getMetadataByName
public String getMetadataByName(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.- Specified by:
getMetadataByName
in interfacePdfBoxOutputDevice
- Parameters:
name
- the metadata element name to locate.- Returns:
- the content value of the first found metadata element; otherwise null.
-
getMetadataListByName
public List<String> getMetadataListByName(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.- Specified by:
getMetadataListByName
in interfacePdfBoxOutputDevice
- Parameters:
name
- the metadata element name to locate.- Returns:
- an ArrayList with matching content values; otherwise an empty list.
-
setMetadata
public void setMetadata(String name, 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.- Specified by:
setMetadata
in interfacePdfBoxOutputDevice
- Parameters:
name
- the metadata element name to locate.
-
getMetadata
public List<com.openhtmltopdf.pdfboxout.PdfBoxSlowOutputDevice.Metadata> getMetadata()
- Specified by:
getMetadata
in interfacePdfBoxOutputDevice
- Returns:
- All metadata entries
-
getSharedContext
public com.openhtmltopdf.layout.SharedContext getSharedContext()
- Specified by:
getSharedContext
in interfacePdfBoxOutputDevice
-
setSharedContext
public void setSharedContext(com.openhtmltopdf.layout.SharedContext sharedContext)
- Specified by:
setSharedContext
in interfacePdfBoxOutputDevice
-
setRoot
public void setRoot(com.openhtmltopdf.render.Box root)
- Specified by:
setRoot
in interfacePdfBoxOutputDevice
-
getStartPageNo
public int getStartPageNo()
- Specified by:
getStartPageNo
in interfacePdfBoxOutputDevice
-
setStartPageNo
public void setStartPageNo(int startPageNo)
- Specified by:
setStartPageNo
in interfacePdfBoxOutputDevice
-
drawSelection
public void drawSelection(com.openhtmltopdf.render.RenderingContext c, com.openhtmltopdf.render.InlineText inlineText)
- Specified by:
drawSelection
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawSelection
in interfacePdfBoxOutputDevice
-
isSupportsSelection
public boolean isSupportsSelection()
- Specified by:
isSupportsSelection
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
isSupportsSelection
in interfacePdfBoxOutputDevice
-
isSupportsCMYKColors
public boolean isSupportsCMYKColors()
- Specified by:
isSupportsCMYKColors
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
isSupportsCMYKColors
in interfacePdfBoxOutputDevice
-
drawWithGraphics
public void drawWithGraphics(float x, float y, float width, float height, com.openhtmltopdf.extend.OutputDeviceGraphicsDrawer renderer)
- Specified by:
drawWithGraphics
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
drawWithGraphics
in interfacePdfBoxOutputDevice
-
findPagePositionsByID
public List<PagePosition> findPagePositionsByID(com.openhtmltopdf.css.style.CssContext c, Pattern pattern)
- Specified by:
findPagePositionsByID
in interfacePdfBoxOutputDevice
-
setRenderingContext
public void setRenderingContext(com.openhtmltopdf.render.RenderingContext result)
- Specified by:
setRenderingContext
in interfacePdfBoxOutputDevice
-
setBidiReorderer
public void setBidiReorderer(com.openhtmltopdf.bidi.BidiReorderer reorderer)
- Specified by:
setBidiReorderer
in interfacePdfBoxOutputDevice
-
popTransforms
public void popTransforms(List<AffineTransform> inverse)
- Specified by:
popTransforms
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
popTransforms
in interfacePdfBoxOutputDevice
-
pushTransforms
public List<AffineTransform> pushTransforms(List<AffineTransform> transforms)
- Specified by:
pushTransforms
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
pushTransforms
in interfacePdfBoxOutputDevice
-
getAbsoluteTransformOriginX
public float getAbsoluteTransformOriginX()
- Specified by:
getAbsoluteTransformOriginX
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
getAbsoluteTransformOriginX
in interfacePdfBoxOutputDevice
-
getAbsoluteTransformOriginY
public float getAbsoluteTransformOriginY()
- Specified by:
getAbsoluteTransformOriginY
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
getAbsoluteTransformOriginY
in interfacePdfBoxOutputDevice
-
setPaint
public void setPaint(Paint paint)
- Specified by:
setPaint
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
setPaint
in interfacePdfBoxOutputDevice
-
isPDF
public boolean isPDF()
- Specified by:
isPDF
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
isPDF
in interfacePdfBoxOutputDevice
- Overrides:
isPDF
in classcom.openhtmltopdf.render.AbstractOutputDevice
-
close
public void close()
Perform any internal cleanup needed- Specified by:
close
in interfacePdfBoxOutputDevice
-
pushTransformLayer
public void pushTransformLayer(AffineTransform transform)
- Specified by:
pushTransformLayer
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
pushTransformLayer
in interfacePdfBoxOutputDevice
-
popTransformLayer
public void popTransformLayer()
- Specified by:
popTransformLayer
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
popTransformLayer
in interfacePdfBoxOutputDevice
-
isFastRenderer
public boolean isFastRenderer()
- Specified by:
isFastRenderer
in interfacecom.openhtmltopdf.extend.OutputDevice
- Specified by:
isFastRenderer
in interfacePdfBoxOutputDevice
-
startStructure
public Object startStructure(com.openhtmltopdf.extend.StructureType type, com.openhtmltopdf.render.Box box)
- Specified by:
startStructure
in interfacecom.openhtmltopdf.extend.OutputDevice
-
endStructure
public void endStructure(Object token)
- Specified by:
endStructure
in interfacecom.openhtmltopdf.extend.OutputDevice
-
-