Package org.apache.pdfbox.tools
Class ExtractImages.ImageGraphicsEngine
java.lang.Object
org.apache.pdfbox.contentstream.PDFStreamEngine
org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
org.apache.pdfbox.tools.ExtractImages.ImageGraphicsEngine
- Enclosing class:
- ExtractImages
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3) Append a rectangle to the current path.voidclip(int windingRule) Modify the current clipping path by intersecting it with the current path.voidCloses the current path.voidcurveTo(float x1, float y1, float x2, float y2, float x3, float y3) Draws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.voidDraw the image.voidendPath()Ends the current path without filling or stroking it.voidfillAndStrokePath(int windingRule) Fills and then strokes the path.voidfillPath(int windingRule) Fill the path.Returns the current point of the current path.private booleanvoidlineTo(float x, float y) Draws a line from the current point to (x,y).voidmoveTo(float x, float y) Starts a new path at (x,y).private voidprocessColor(PDColor color) voidrun()voidshadingFill(COSName shadingName) Fill with Shading.protected voidCalled when a glyph is to be processed.voidStroke the path.private voidwrite2file(PDImage pdImage, String prefix, boolean directJPEG, boolean noColorConvert) Writes the image to a file with the filename prefix + an appropriate suffix, like "Image.jpg".Methods inherited from class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
getPageMethods inherited from class org.apache.pdfbox.contentstream.PDFStreamEngine
addOperator, applyTextAdjustment, beginMarkedContentSequence, beginText, decreaseLevel, endMarkedContentSequence, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, registerOperatorProcessor, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showFontGlyph, showForm, showGlyph, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
-
Constructor Details
-
ImageGraphicsEngine
-
-
Method Details
-
run
- Throws:
IOException
-
drawImage
Description copied from class:PDFGraphicsStreamEngineDraw the image.- Specified by:
drawImagein classPDFGraphicsStreamEngine- Parameters:
pdImage- The image to draw.- Throws:
IOException- if something went wrong.
-
appendRectangle
Description copied from class:PDFGraphicsStreamEngineAppend a rectangle to the current path.- Specified by:
appendRectanglein classPDFGraphicsStreamEngine- Parameters:
p0- point P0 of the rectangle.p1- point P1 of the rectangle.p2- point P2 of the rectangle.p3- point P3 of the rectangle.- Throws:
IOException- if something went wrong.
-
clip
Description copied from class:PDFGraphicsStreamEngineModify the current clipping path by intersecting it with the current path. The clipping path will not be updated until the succeeding painting operator is called.- Specified by:
clipin classPDFGraphicsStreamEngine- Parameters:
windingRule- The winding rule which will be used for clipping.- Throws:
IOException- if something went wrong.
-
moveTo
Description copied from class:PDFGraphicsStreamEngineStarts a new path at (x,y).- Specified by:
moveToin classPDFGraphicsStreamEngine- Parameters:
x- x-coordinate of the target point.y- y-coordinate of the target point.- Throws:
IOException- if something went wrong.
-
lineTo
Description copied from class:PDFGraphicsStreamEngineDraws a line from the current point to (x,y).- Specified by:
lineToin classPDFGraphicsStreamEngine- Parameters:
x- x-coordinate of the end point of the line.y- y-coordinate of the end point of the line.- Throws:
IOException- if something went wrong.
-
curveTo
Description copied from class:PDFGraphicsStreamEngineDraws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.- Specified by:
curveToin classPDFGraphicsStreamEngine- Parameters:
x1- x-coordinate of the first control point.y1- y-coordinate of the first control point.x2- x-coordinate of the second control point.y2- y-coordinate of the second control point.x3- x-coordinate of the end point of the curve.y3- y-coordinate of the end point of the curve.- Throws:
IOException- if something went wrong.
-
getCurrentPoint
Description copied from class:PDFGraphicsStreamEngineReturns the current point of the current path.- Specified by:
getCurrentPointin classPDFGraphicsStreamEngine- Returns:
- the current point.
- Throws:
IOException- if something went wrong.
-
closePath
Description copied from class:PDFGraphicsStreamEngineCloses the current path.- Specified by:
closePathin classPDFGraphicsStreamEngine- Throws:
IOException- if something went wrong.
-
endPath
Description copied from class:PDFGraphicsStreamEngineEnds the current path without filling or stroking it. The clipping path is updated here.- Specified by:
endPathin classPDFGraphicsStreamEngine- Throws:
IOException- if something went wrong.
-
showGlyph
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException Description copied from class:PDFStreamEngineCalled when a glyph is to be processed. This method is intended for overriding in subclasses, the default implementation does nothing.- Overrides:
showGlyphin classPDFStreamEngine- Parameters:
textRenderingMatrix- the current text rendering matrix, Trmfont- the current fontcode- internal PDF character code for the glyphdisplacement- the displacement (i.e. advance) of the glyph in text space- Throws:
IOException- if the glyph cannot be processed
-
strokePath
Description copied from class:PDFGraphicsStreamEngineStroke the path.- Specified by:
strokePathin classPDFGraphicsStreamEngine- Throws:
IOException- If there is an IO error while stroking the path.
-
fillPath
Description copied from class:PDFGraphicsStreamEngineFill the path.- Specified by:
fillPathin classPDFGraphicsStreamEngine- Parameters:
windingRule- The winding rule this path will use.- Throws:
IOException- if something went wrong.
-
fillAndStrokePath
Description copied from class:PDFGraphicsStreamEngineFills and then strokes the path.- Specified by:
fillAndStrokePathin classPDFGraphicsStreamEngine- Parameters:
windingRule- The winding rule this path will use.- Throws:
IOException- if something went wrong.
-
shadingFill
Description copied from class:PDFGraphicsStreamEngineFill with Shading.- Specified by:
shadingFillin classPDFGraphicsStreamEngine- Parameters:
shadingName- The name of the Shading Dictionary to use for this fill instruction.- Throws:
IOException- if something went wrong.
-
processColor
- Throws:
IOException
-
write2file
private void write2file(PDImage pdImage, String prefix, boolean directJPEG, boolean noColorConvert) throws IOException Writes the image to a file with the filename prefix + an appropriate suffix, like "Image.jpg". The suffix is automatically set depending on the image compression in the PDF.- Parameters:
pdImage- the image.prefix- the filename prefix.directJPEG- if true, force saving JPEG/JPX streams as they are in the PDF file.noColorConvert- if true, images are extracted with their original colorspace if possible.- Throws:
IOException- When something is wrong with the corresponding file.
-
hasMasks
- Throws:
IOException
-