Am 07.04.2021 um 09:12 schrieb Andrin Meier:
Yes, the file is created using Vega/d3.js, exported to SVG and then put into a
word document with Aspose. Aspose also has a print functionality. They don't
have this bug but they have other bugs. That's why I resorted to pdfbox. Isn't
there a native way of printing PDFs on Windows 10 without having to use any
library?
Not on windows AFAIK.
I tested a PDFBox change that results in your file getting rendered
properly (put "if (!context.getCurrentPoint().equals(pos))" before the
lineTo call in LineTo.java) but this change ruins the rendering of the
2nd page of the PDFBOX-2302-mori-cvpr01.pdf file. One would have to also
check whether the previous path command was a lineTo and this means lots
of little changes in the code and a slight performance loss on
vector-heavy PDFs. But the change I mention would be useful for you if
you only have this type of files.
Alternatively, maybe some tool that cleans up the SVG file?
I will send a bug report to Oracle and see how they react. This usually
takes a few days and sometimes they don't react at all.
Tilman
________________________________
Von: Tilman Hausherr <[email protected]>
Gesendet: Dienstag, 6. April 2021 19:21
An: [email protected] <[email protected]>
Betreff: Re: Jagged lines in Graph when printing with PDFBox 2.0.23
The chart has double lines, i.e. lines that go to itself. This brings
that weird effect in java, but not in Adobe Reader. It's related to the
miter limit.
I wonder if this is a java bug.
Did you create the file yourself?
Tilman
public class JaggedLines
{
public static void main(String[] args) throws IOException
{
BufferedImage bim = new BufferedImage(500, 500,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bim.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setBackground(Color.white);
g.clearRect(0, 0, bim.getWidth(), bim.getHeight());
GeneralPath path;
AffineTransform at = g.getTransform();
g.setColor(Color.red);
g.transform(AffineTransform.getTranslateInstance(0, -1400));
g.transform(AffineTransform.getScaleInstance(10, 10));
path = new GeneralPath();
path.moveTo(24.954517, 159);
path.lineTo(21.097446, 157.5);
path.lineTo(17.61364, 162);
path.lineTo(13.756569, 163.5);
path.lineTo(11.890244, 160.5);
g.draw(path);
g.setTransform(at);
g.setColor(Color.blue);
path = new GeneralPath();
g.transform(AffineTransform.getTranslateInstance(0, -1300));
g.transform(AffineTransform.getScaleInstance(10, 10));
path.moveTo(24.954517, 159);
path.lineTo(21.097446, 157.5);
path.lineTo(21.097446, 157.5); // this repeats the previous one
path.lineTo(17.61364, 162);
path.lineTo(17.61364, 162); // this repeats the previous one
path.lineTo(13.756569, 163.5);
path.lineTo(13.756569, 163.5); // this repeats the previous one
path.lineTo(11.890244, 160.5);
g.draw(path);
g.dispose();
ImageIO.write(bim, "png", new File("huhu.png"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]