pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Brendel" <bren...@krumedia.de>
Subject Image is corrupted
Date Thu, 25 Oct 2012 10:42:45 GMT
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.
Other people are having the same problem, please see  
http://stackoverflow.com/a/8598054/628696


	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();

Mime
View raw message