0

I am having a pdf with barcodes. As shown in the image Barcode which I am trying to read

I am stuck on an issue and not able to proceed with my project. I am using PDFBox for parsing of the PDF and able to convert the whole pdf in the text format as shown in the code below:

public static PdfValues readPdf() throws IOException {
        System.out.println("Main Method Started");
        File file = new File("D:/po/temp/output.pdf");
        PDDocument document = PDDocument.load(file);
        PDFTextStripper pdfStripper = new PDFTextStripper();
        String text = pdfStripper.getText(document);
        text = text.trim();
        text = text.replaceAll(" +", " ");
        text = text.replaceAll("(?m)^[ \t]*\r?\n", "");
        // System.out.println(text);
        deleteIfExist();
        writeToFile(text);
        PdfValues infos = readData();
        document.close();
        System.out.println("Main Method Ended");
        return infos;
    }

But I am not getting the barcode value which means it is not a text. Can anyone help me how to parse this barcode values as an image or actual value? Thank you for reading this question.

Rahul Sah
  • 269
  • 4
  • 14
  • How is the barcode integrated into the document? Is it a bitmap image? A vector image? Text using a barcode font? – mkl Dec 04 '17 at 16:15
  • It dont know that... is there any way to know that? – Rahul Sah Dec 04 '17 at 16:24
  • @mkl: I had tried to debug the code and got to know that it is of type code39 and type content of the barcode is same as value written above it. – Rahul Sah Dec 04 '17 at 17:06
  • *"It dont know that... is there any way to know that?"* - Yes, by inspecting the objects from which the barcode is built. If you shared the actual PDF, we could determine the type. – mkl Dec 04 '17 at 17:10
  • If it is not a text then the best would be to convert to image https://stackoverflow.com/questions/23326562/apache-pdfbox-convert-pdf-to-images and then feed this image to a barcode decoder lib. – Tilman Hausherr Dec 04 '17 at 18:07

0 Answers0