Skip to content
Advertisement

Lines on printout of iText7 PDF have different length on paper

Only some of our testers report a strange look of all lines on the printout of an iText7 generated PDF (see image). The generated PDF looks perfect and the flaw only appears on paper. Most users have no issue, whatsoever.

Any suggestions regarding known issues of printers, drivers or hints on how to reproduce or localize the problem would be appreciated. Anything I could do on iText7 side?

PdfCanvas canvas = new PdfCanvas(pdfPage)
canvas.moveTo(x1,y1);
canvas.lineTo(x2,y2);
canvas.closePathStroke();

The PDF can be found here: PDF

enter image description here

Advertisement

Answer

Making prior comments an actual answer…

I could reproduce the issue with your example document:

  • using Chrome on Windows with a Brother printer I also get those extra line segments;

  • using Adobe Reader instead of Chrome I don’t.

Looking into the PDF, though, I didn’t see anything that should cause that issue.

Thus, while there is nothing wrong with your kind of line drawing to start with, I proposed drawing the rectangles as rectangles (instead of multiple lines), or using filled thin rectangles instead of lines. I hoped one of those options is supported by Chrome printing.

And indeed you commented:

I’m now printing thin rectangles instead of lines and it works flawlessly.

So, while the bug was not yours from the start, changing your code to draw the borders differently solved the issue for you.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement