Class PDStreamUtils

java.lang.Object
be.quodlibet.boxable.utils.PDStreamUtils

public final class PDStreamUtils extends Object

Utility methods for PDPageContentStream

Author:
hstimac, mkuehne
  • Method Details

    • write

      public static void write(PageContentStreamOptimized stream, String text, org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize, float x, float y, Color color)

      Provides ability to write on a PDPageContentStream. The text will be written above Y coordinate.

      Parameters:
      stream - The PDPageContentStream where writing will be applied.
      text - The text which will be displayed.
      font - The font of the text
      fontSize - The font size of the text
      x - Start X coordinate for text.
      y - Start Y coordinate for text.
      color - Color of the text
    • rect

      public static void rect(PageContentStreamOptimized stream, float x, float y, float width, float height, Color color)

      Provides ability to draw rectangle for debugging purposes.

      Parameters:
      stream - The PDPageContentStream where drawing will be applied.
      x - Start X coordinate for rectangle.
      y - Start Y coordinate for rectangle.
      width - Width of rectangle
      height - Height of rectangle
      color - Color of the text
    • rectFontMetrics

      public static void rectFontMetrics(PageContentStreamOptimized stream, float x, float y, org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)

      Provides ability to draw font metrics (font height, font ascent, font descent).

      Parameters:
      stream - The PDPageContentStream where drawing will be applied.
      x - Start X coordinate for rectangle.
      y - Start Y coordinate for rectangle.
      font - PDFont from which will be obtained font metrics
      fontSize - Font size
    • setLineStyles

      public static void setLineStyles(PageContentStreamOptimized stream, LineStyle line) throws IOException

      Provides ability to set different line styles (line width, dotted line, dashed line)

      Parameters:
      stream - The PDPageContentStream where drawing will be applied.
      line - The LineStyle that would be applied
      Throws:
      IOException - If the content stream could not be written or the line color cannot be retrieved.