Hi,
Matthias Brendel <[email protected]> hat am 25. Oktober 2012 um 12:42 geschrieben: > The following example demonstrates that the contentStream conflicts with > the image. The more elementes are written to the content stream the more > the image shows garbage. This is a known issue > Other people are having the same problem, please see > http://stackoverflow.com/a/8598054/628696 It also mentions a possible solution for the issue. You have to create the Image, a PDPixelMap in your case, before opening the contentstream. I know it is just a workaround, but it works so far. > PDDocument document = new PDDocument(); > > PDPage page = new PDPage(PDPage.PAGE_SIZE_A4); > document.addPage(page); > PDPageContentStream contentStream = new PDPageContentStream(document, > page); > > for (int i = 0; i < 1000; ++i) { // the more elements the more the image > damages > contentStream.drawLine(0, 0, 100, 0); > } > > BufferedImage bufferedImage = new BufferedImage(100, 100, > BufferedImage.TYPE_INT_RGB); > PDXObjectImage xObjectImage = new PDPixelMap(document, bufferedImage); > contentStream.drawImage(xObjectImage, 0, 0); > > contentStream.close(); > document.save("Example.pdf"); > document.close(); BR Andreas Lehmkühler

