[
https://issues.apache.org/jira/browse/PDFBOX-5601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17722392#comment-17722392
]
Tilman Hausherr commented on PDFBOX-5601:
-----------------------------------------
I can't help much here, because I don't own a mac. Please play with this code
to find out if there is something that works for printers on all systems.
{code}
public class PDFBox5601BadPrint implements Printable
{
public static void main(String[] args) throws PrinterException
{
new PDFBox5601BadPrint().doStuff();
}
PDFBox5601BadPrint()
{
}
void doStuff() throws PrinterException
{
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
job.setPrintable(this);
if (job.printDialog())
{
job.print();
}
}
@Override
public int print(Graphics graphics, PageFormat pageFormat, int index)
{
if (index == 0)
{
Graphics2D g2d = (Graphics2D) graphics;
try
{
// TYPE_INT_ARGB with hints bad
// TYPE_INT_ARGB without hints bad
// TYPE_4BYTE_ABGR with hints good but blurry
// TYPE_4BYTE_ABGR without rendering hints all good
// TYPE_4BYTE_ABGR with VALUE_RENDER_QUALITY blurry
// TYPE_4BYTE_ABGR with VALUE_INTERPOLATION_BICUBIC blurry
// g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
// g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
BufferedImage bim = ImageIO.read(new
URL("https://issues.apache.org/jira/secure/attachment/13058029/PDFBOX-5601-original-barcode.png").openStream());
BufferedImage bim2 = new BufferedImage(bim.getWidth(),
bim.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bim2.getGraphics();
g.drawImage(bim, 0, 0, null);
g.dispose();
bim = bim2;
System.out.println(bim);
g2d.drawImage(bim, AffineTransform.getScaleInstance(2, 2),
null);
g2d.transform(new AffineTransform(1, 0, 0, -1, 0, 100));
g2d.scale(0.01, 0.001);
AffineTransform at = new AffineTransform(0, -1410, 277.5, 0,
221.25, 3036.25);
g2d.drawImage(bim, at, null);
}
catch (IOException ex)
{
ex.printStackTrace();
System.exit(-1);
}
return Printable.PAGE_EXISTS;
}
return Printable.NO_SUCH_PAGE;
}
}
{code}
> Barcode corrupted when printing document
> ----------------------------------------
>
> Key: PDFBOX-5601
> URL: https://issues.apache.org/jira/browse/PDFBOX-5601
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.27, 2.0.28, 3.0.0 PDFBox
> Reporter: Tres Finocchiaro
> Priority: Major
> Labels: print, printing
> Attachments: 234457694-edit.pdf,
> PDFBOX-5601-badbarcodeprint-reduced.pdf, PDFBOX-5601-original-barcode.png,
> jpeg.jpg, preview.png, screenshot-1.png
>
>
> When printing the attached document, the barcode on the left side is
> corrupted. Please see preview of desired versus actual.
> !preview.png!
> * This does not occur when printing with other applications
> * This issue also occurs on the latest 3.0 alpha version
> {code:java}
> java -jar pdfbox-app-2.0.27.jar PrintPDF 234457694-edit.pdf
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]