Created
April 17, 2019 02:30
-
-
Save tresf/3925eb60da4af26a3221e6e3f6c1b9b8 to your computer and use it in GitHub Desktop.
Save QZ Tray PDF to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/qz/printer/action/PrintPDF.java b/src/qz/printer/action/PrintPDF.java | |
index 9dab76e..240218e 100644 | |
--- a/src/qz/printer/action/PrintPDF.java | |
+++ b/src/qz/printer/action/PrintPDF.java | |
@@ -32,6 +32,7 @@ import java.awt.print.PrinterJob; | |
import java.io.*; | |
import java.net.URL; | |
import java.util.ArrayList; | |
+import java.util.Calendar; | |
import java.util.List; | |
import java.util.Locale; | |
@@ -67,6 +68,16 @@ public class PrintPDF extends PrintPixel implements PrintProcessor { | |
doc = PDDocument.load(new ByteArrayInputStream(Base64.decode(data.getString("data")))); | |
} else { | |
doc = PDDocument.load(new URL(data.getString("data")).openStream()); | |
+ InputStream in = new URL(data.getString("data")).openStream(); | |
+ File targetFile = new File("C:\\Users\\owner\\Desktop\\PDF_" + Calendar.getInstance().getTimeInMillis() + ".pdf"); | |
+ OutputStream out = new FileOutputStream(targetFile); | |
+ byte[] buffer = new byte[1024]; | |
+ int len; | |
+ while ((len = in.read(buffer)) != -1) { | |
+ out.write(buffer, 0, len); | |
+ } | |
+ out.flush(); | |
+ out.close(); | |
} | |
originals.add(doc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment