AwtCanvas

KiteCanvas backed by java.awt.Graphics2D. Pure JRE: no Skia, no Compose, no native binaries.

The right choice when:

  • you're rendering a PDF inside an AWT / Swing / JavaFX (via SwingNode) component

  • you want PNG/JPEG output via javax.imageio.ImageIO without pulling in Skia's native libs

  • server-side rendering where the JVM is already there

Pair with AwtPdfRasterizer for the common "give me a BufferedImage" use case.

Caveats: Java2D supports a subset of PDF's 16 blend modes natively. The common ones (Normal, SrcOver) are mapped to AlphaComposite. The rest (Multiply, Screen, …) require a custom java.awt.Composite. We ship a pixel-level PdfBlendComposite that implements all 16 modes for fidelity.

Constructors

Link copied to clipboard
constructor(g: Graphics2D)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: Rectangle, maskCtm: Matrix, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)

Soft mask (ISO 32000-1 §11.6.5). Content is painted on the live surface, then gated by the mask group:

Link copied to clipboard
open override fun beginPage(widthPt: Double, heightPt: Double, deviceCtm: Matrix)
Link copied to clipboard
open override fun beginTransparencyGroup(bbox: Rectangle, ctm: Matrix, isolated: Boolean, knockout: Boolean, alpha: Double, blendMode: BlendMode)

Open an offscreen layer for transparency-group compositing. Java2D has no built-in saveLayer like Skia, so we manually pixel-render into a BufferedImage and blit it back when the group ends.

Link copied to clipboard
open override fun drawGlyphs(glyphs: List<TextGlyph>, fontSize: Double, unitsPerEm: Int, hasOutlines: Boolean, fontSpec: FontSpec, textToDevice: Matrix, color: RgbColor, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun drawImage(image: ImageXObject, ctm: Matrix, alpha: Double)
Link copied to clipboard
open override fun endPage()
Link copied to clipboard
open override fun endTransparencyGroup()
Link copied to clipboard
open override fun fillPath(path: KitePath, ctm: Matrix, color: RgbColor, evenOdd: Boolean, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun fillShading(shading: KiteShading, ctm: Matrix, clipPath: KitePath?, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun popClip()
Link copied to clipboard
open override fun pushClip(path: KitePath, ctm: Matrix, evenOdd: Boolean)
Link copied to clipboard
open override fun strokePath(path: KitePath, ctm: Matrix, color: RgbColor, lineWidth: Double, alpha: Double, blendMode: BlendMode, dashArray: List<Double>?, dashPhase: Double, lineCap: Int, lineJoin: Int, miterLimit: Double)