Class ExtractImages.ImageGraphicsEngine

Enclosing class:
ExtractImages

private class ExtractImages.ImageGraphicsEngine extends PDFGraphicsStreamEngine
  • Constructor Details

    • ImageGraphicsEngine

      protected ImageGraphicsEngine(PDPage page)
  • Method Details

    • run

      public void run() throws IOException
      Throws:
      IOException
    • drawImage

      public void drawImage(PDImage pdImage) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Draw the image.
      Specified by:
      drawImage in class PDFGraphicsStreamEngine
      Parameters:
      pdImage - The image to draw.
      Throws:
      IOException - if the image could not be drawn
    • appendRectangle

      public void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Append a rectangle to the current path.
      Specified by:
      appendRectangle in class PDFGraphicsStreamEngine
      Parameters:
      p0 - starting coordinate of the rectangle
      p1 - second coordinate of the rectangle
      p2 - third coordinate of the rectangle
      p3 - last coordinate of the rectangle
      Throws:
      IOException - if the rectangle could not be appended
    • clip

      public void clip(int windingRule) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Modify 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:
      clip in class PDFGraphicsStreamEngine
      Parameters:
      windingRule - The winding rule which will be used for clipping.
      Throws:
      IOException - if the clipping path could not be modified
    • moveTo

      public void moveTo(float x, float y) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Starts a new path at (x,y).
      Specified by:
      moveTo in class PDFGraphicsStreamEngine
      Parameters:
      x - the x-coordinate to move to
      y - the y-coordinate to move to
      Throws:
      IOException - if the something went wrong when moving to the given coordinate
    • lineTo

      public void lineTo(float x, float y) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Draws a line from the current point to (x,y).
      Specified by:
      lineTo in class PDFGraphicsStreamEngine
      Parameters:
      x - the X-coordinate of the ending-point of the line to be drawn
      y - the Y-coordinate of the ending-point of the line to be drawn
      Throws:
      IOException - if the line could not be drawn
    • curveTo

      public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Draws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.
      Specified by:
      curveTo in class PDFGraphicsStreamEngine
      Parameters:
      x1 - the X coordinate of the first Bézier control point
      y1 - the Y coordinate of the first Bézier control point
      x2 - the X coordinate of the second Bézier control point
      y2 - the Y coordinate of the second Bézier control point
      x3 - the X coordinate of the final end point
      y3 - the Y coordinate of the final end point
      Throws:
      IOException - if the curve could not be drawn
    • getCurrentPoint

      public Point2D getCurrentPoint() throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Returns the current point of the current path.
      Specified by:
      getCurrentPoint in class PDFGraphicsStreamEngine
      Returns:
      the current point or null
      Throws:
      IOException - if the something went wrong when providing the current point
    • closePath

      public void closePath() throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Closes the current path.
      Specified by:
      closePath in class PDFGraphicsStreamEngine
      Throws:
      IOException - if the current path could not be closed
    • endPath

      public void endPath() throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Ends the current path without filling or stroking it. The clipping path is updated here.
      Specified by:
      endPath in class PDFGraphicsStreamEngine
      Throws:
      IOException - if the current path could not be ended
    • showGlyph

      protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException
      Description copied from class: PDFStreamEngine
      Called when a glyph is to be processed. This method is intended for overriding in subclasses, the default implementation does nothing.
      Overrides:
      showGlyph in class PDFStreamEngine
      Parameters:
      textRenderingMatrix - the current text rendering matrix, Trm
      font - the current font
      code - internal PDF character code for the glyph
      displacement - the displacement (i.e. advance) of the glyph in text space
      Throws:
      IOException - if the glyph cannot be processed
    • strokePath

      public void strokePath() throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Stroke the path.
      Specified by:
      strokePath in class PDFGraphicsStreamEngine
      Throws:
      IOException - If there is an IO error while stroking the path.
    • fillPath

      public void fillPath(int windingRule) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Fill the path.
      Specified by:
      fillPath in class PDFGraphicsStreamEngine
      Parameters:
      windingRule - The winding rule this path will use.
      Throws:
      IOException - if the path could not be filled
    • fillAndStrokePath

      public void fillAndStrokePath(int windingRule) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Fills and then strokes the path.
      Specified by:
      fillAndStrokePath in class PDFGraphicsStreamEngine
      Parameters:
      windingRule - The winding rule this path will use.
      Throws:
      IOException - if the path could not be filled and stroke
    • shadingFill

      public void shadingFill(COSName shadingName) throws IOException
      Description copied from class: PDFGraphicsStreamEngine
      Fill with Shading.
      Specified by:
      shadingFill in class PDFGraphicsStreamEngine
      Parameters:
      shadingName - The name of the Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - if the path could not be filled using the given shading
    • processColor

      private void processColor(PDColor color) throws IOException
      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

      private boolean hasMasks(PDImage pdImage) throws IOException
      Throws:
      IOException