Printing PDF or PNG in POS Thermal printer with java
up vote
0
down vote
favorite
I Everyone. I have a problem printing ticket with java. I generated ticket with jasper and then I need to print it in POS Thermal printer. I try to print PDF and the result got
Wrong Format
Then I convert pdf to png with pdfbox but the image print too small.
How can I print correctly? Is there any way to print PDF for POS Thremal Printer correctly or fill and increase the PNG Image?
Print PNG too small
Printing from Adobe reader directly to my POS Thermal Printer, I had the correctly ticket.
Correct from Adobe Reader
Here's part of my code:
PDDocument document = PDDocument.load(new File(pathFile+".pdf"));
PDPage pd;
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page)
pd = document.getPage(page);
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
ImageIOUtil.writeImage(bim, pathFile +".png", 300);
document.close();
FileInputStream is = new FileInputStream(pathFile+".png");
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob job = mPrinter.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
job.print(doc, null);
is.close();
java printing pdfbox thermal-printer receipt
add a comment |
up vote
0
down vote
favorite
I Everyone. I have a problem printing ticket with java. I generated ticket with jasper and then I need to print it in POS Thermal printer. I try to print PDF and the result got
Wrong Format
Then I convert pdf to png with pdfbox but the image print too small.
How can I print correctly? Is there any way to print PDF for POS Thremal Printer correctly or fill and increase the PNG Image?
Print PNG too small
Printing from Adobe reader directly to my POS Thermal Printer, I had the correctly ticket.
Correct from Adobe Reader
Here's part of my code:
PDDocument document = PDDocument.load(new File(pathFile+".pdf"));
PDPage pd;
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page)
pd = document.getPage(page);
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
ImageIOUtil.writeImage(bim, pathFile +".png", 300);
document.close();
FileInputStream is = new FileInputStream(pathFile+".png");
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob job = mPrinter.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
job.print(doc, null);
is.close();
java printing pdfbox thermal-printer receipt
1
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
There is a PDFBox printing option to fit to size, second parameter ofPDFPrintable
constructor. (Yes, that option isn't available on the command line)
– Tilman Hausherr
Nov 13 at 7:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I Everyone. I have a problem printing ticket with java. I generated ticket with jasper and then I need to print it in POS Thermal printer. I try to print PDF and the result got
Wrong Format
Then I convert pdf to png with pdfbox but the image print too small.
How can I print correctly? Is there any way to print PDF for POS Thremal Printer correctly or fill and increase the PNG Image?
Print PNG too small
Printing from Adobe reader directly to my POS Thermal Printer, I had the correctly ticket.
Correct from Adobe Reader
Here's part of my code:
PDDocument document = PDDocument.load(new File(pathFile+".pdf"));
PDPage pd;
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page)
pd = document.getPage(page);
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
ImageIOUtil.writeImage(bim, pathFile +".png", 300);
document.close();
FileInputStream is = new FileInputStream(pathFile+".png");
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob job = mPrinter.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
job.print(doc, null);
is.close();
java printing pdfbox thermal-printer receipt
I Everyone. I have a problem printing ticket with java. I generated ticket with jasper and then I need to print it in POS Thermal printer. I try to print PDF and the result got
Wrong Format
Then I convert pdf to png with pdfbox but the image print too small.
How can I print correctly? Is there any way to print PDF for POS Thremal Printer correctly or fill and increase the PNG Image?
Print PNG too small
Printing from Adobe reader directly to my POS Thermal Printer, I had the correctly ticket.
Correct from Adobe Reader
Here's part of my code:
PDDocument document = PDDocument.load(new File(pathFile+".pdf"));
PDPage pd;
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page)
pd = document.getPage(page);
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
ImageIOUtil.writeImage(bim, pathFile +".png", 300);
document.close();
FileInputStream is = new FileInputStream(pathFile+".png");
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob job = mPrinter.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
job.print(doc, null);
is.close();
java printing pdfbox thermal-printer receipt
java printing pdfbox thermal-printer receipt
asked Nov 10 at 15:11
Alvaro Chillcce
1
1
1
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
There is a PDFBox printing option to fit to size, second parameter ofPDFPrintable
constructor. (Yes, that option isn't available on the command line)
– Tilman Hausherr
Nov 13 at 7:48
add a comment |
1
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
There is a PDFBox printing option to fit to size, second parameter ofPDFPrintable
constructor. (Yes, that option isn't available on the command line)
– Tilman Hausherr
Nov 13 at 7:48
1
1
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
There is a PDFBox printing option to fit to size, second parameter of
PDFPrintable
constructor. (Yes, that option isn't available on the command line)– Tilman Hausherr
Nov 13 at 7:48
There is a PDFBox printing option to fit to size, second parameter of
PDFPrintable
constructor. (Yes, that option isn't available on the command line)– Tilman Hausherr
Nov 13 at 7:48
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240275%2fprinting-pdf-or-png-in-pos-thermal-printer-with-java%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
PDFBox allows to print PDFs directly. To see whether it works at all (there have been many troubles with tiny printers), download the pdfbox-app and try the command line utility pdfbox.apache.org/2.0/commandline.html#printpdf . If that works, get the source code and find the file Printing.java that one has several ways to print from PDF.
– Tilman Hausherr
Nov 10 at 15:21
Thanks for your suggestion. I could print through PDFBox's print method directly.The difference with adobe reader printing is that I had to fit the page format of my jasper template(receipt template) according to printing width defined in thermal printer technical manual because PDFBox doesn't fit the pdf to paper size.
– Alvaro Chillcce
Nov 12 at 18:58
There is a PDFBox printing option to fit to size, second parameter of
PDFPrintable
constructor. (Yes, that option isn't available on the command line)– Tilman Hausherr
Nov 13 at 7:48