PDFBoxを使用して画像をpdfに書き込んでいます。画像は純粋な赤い長方形です。
画像は次のとおりです。
私のコードは次のとおりです。
PDDocument doc = new PDDocument();
PDRectangle pageSize = new PDRectangle(CARD_WIDTH, CARD_HEIGHT);
PDPage page1 = new PDPage(pageSize);
doc.addPage(page1);
File imageFile = getRedImageFile();
PDXObjectImage pdImage = new PDPixelMap(doc, ImageIO.read(imageFile));
// write front image
PDPageContentStream contentStream = null;
try {
contentStream = new PDPageContentStream(doc, page1);
pdImage = parseImage(backImage, doc);
contentStream.drawXObject(pdImage, 0, 0, CARD_WIDTH / 2, CARD_HEIGHT / 2);
} finally {
if (contentStream != null) {
contentStream.close();
}
}
最終的な画像は次のとおりです。
はっきりしないので、拡大して別の画像をアップロードしました。
なぜそこに奇妙なピクセルがあるのですか?