I am trying to insert barcode in the PDF using PDFBox2.0.13. I tried using the BufferedImage for this as given in How to add Code128 Barcode image to existing pdf using pdfbox(1.8.12) with barcode4j library? but this uses "new PDPixelMap(doc, bim)" this PDPixelMap is deprecated in 2.0.x. My question is how do we insert barcode in PDF with APIs available in PDFBox2.0.13(probably replacement of PDPixelMap)and without using PDPixelMap.? Would be great if code snippet provided.
Asked
Active
Viewed 990 times
1 Answers
0
Use LosslessFactory
like this:
PDImageXObject img = LosslessFactory.createFromImage(doc, bim);
contentStream.drawImage(img, x, y);

Tilman Hausherr
- 17,731
- 7
- 58
- 97