From a4d935e71397e3a18a81ff5951517a76a0eaf2d2 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 19 Jan 2020 08:53:18 -0500 Subject: [PATCH] fix for precision issues with PDF (5801 in 3.x) --- core/todo.txt | 4 ++-- java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/todo.txt b/core/todo.txt index fb90d9ed2..b41451b2b 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -2,6 +2,8 @@ X make edits to core so that awt can be flagged off, and lwjgl can run X https://github.com/codeanticode/processing-openjdk/commit/ac9abc18655daaa538ef16945687177334f3596e X add --disable-awt to PApplet.main() +X fix for precision issues with PDF +X https://github.com/processing/processing/issues/5801#issuecomment-466632459 before final release @@ -21,8 +23,6 @@ _ move AWT code out of PImage, and into its own PImageJava2D class _ how to handle with JavaFX? _ https://github.com/processing/processing4/issues/56 -_ possible fix for precision issues with PDF -_ https://github.com/processing/processing/issues/5801#issuecomment-466632459 high-ish diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index 5987508c6..ce72d44a1 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -29,6 +29,7 @@ import java.util.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; +import com.lowagie.text.pdf.ByteBuffer; import processing.awt.PGraphicsJava2D; import processing.core.*; @@ -121,6 +122,9 @@ public class PGraphicsPDF extends PGraphicsJava2D { // long t0 = System.currentTimeMillis(); if (document == null) { + // https://github.com/processing/processing/issues/5801#issuecomment-466632459 + ByteBuffer.HIGH_PRECISION = true; + document = new Document(new Rectangle(width, height)); boolean missingPath = false; try {