Read QR Code from scanned PDF - java

I'm trying to insert and read qrcode's from PDF files. To create/read qr codes from images i'm using zxing project and to manipulate the pdf i'm using Big Faceless PDF.
Everything works well if i create the QR Code, insert into my pdf, and then read the images from the pdf and convert the correct one to QR Code. However, if i try to to read images from a scanned document (with a qr code sticker attach to it), i cannot obtain the qr code image from the pdf (the only image i can get, using Big Faceless PDF, is the document it self).
Does anyone knows a Java library to search in pdf files for qr codes?
Thanks for you help

The only reliable way to do this is to convert the PDF page to a bitmap, then using something like zxing to scan the entire page for the barcode. Extracting the individual images that make up the page won't work on every document: the barcode may be created using graphics operations rather than as an embedded image (that's how we do it), or if you PDF was scanned from a paper source as you've described, it will usually be one big image.
Once you've got the PDF converted to a bitmap, ZXing should be able to do this, at least in theory. Naturally I'd recommend sticking with us for the conversion to bitmap ;-)
If ZXing is having trouble finding the code, make sure it has enough white-space around it - you need 4 clear modules on all sides, so for smaller codes it should be about 10% of the width of the code in whitespace around the code, to help it scan.
Cheers... Mike (CTO#BFO)

I have gotten this to work:
Use Imagick to converts pdfs into pngs
Use Zxing \ QrReader to read the QR data

Related

How to differentiate text and images from a PDF file using java?

So i have to make an android app using Java that reads a PDF File and displays it on screen without using other programs(such as PDF Reader). How to make a distinction between text and image in that file? in other words, there is text and in between text ther is an image, how do i verify where it is text and where is an image?
PDF files don't work like that.
It is a complex format, and there is a lot more data in the files than just text and images, such as metadata and formatting.
If you want to handle PDF files in your app, you should use a PDF library, such as the ones listed here:
https://camposha.info/android-examples/android-pdf-libraries/#gsc.tab=0
How exactly to load text will depend on the specific library you choose, and you should check the relevant documentation.

Pdf to Pdf of Image with PdfBox

I'm using pdfbox (1.8) to handle pdf on Windows (7 and above). I need to take an input pdf and convert to a pdf made by the same page but used as image (no text selectable etc etc). With small file i have no problem but when i have to convert bigger file i have no clue due to massive memory use.
I will post some code if it helps but the approach i'm using is simple: create a document by all the page saved as image taken from the source pdf.
I'm searching for some more memory and time efficent way to do this (i have to handle pdf with 1 or 2 k of pages).

Using qoppa to create pdf with table structure just like we do using itext pdf library

Sample pdf
A sample pdf is shown in image. We need to create 2 column structure which can have text/images/figures etc. Moreover, we need to change the text format like font/size, auto wrapping etc. Text content will be dynamic as we don't know the content at compile time hence, it should be able to align itself after paragraph ends and we should not need to provide hard coded value for height. Giving absolute positions of components in qoppa to create pdf is not feasible for us because of dynamic content.
We've already explored qoppa library and we couldn't figure out how to make a pdf like shown in image. If anyone has worked on qoppa, Please do share the valuable resources available online related to qoppa. And Please, let me know if it is possible to create a pdf like this using qoppa.

Generate a PDF and then download as JPEG or image file

I am using iText to generate PDF and is working fine, and I can also download it via browser as PDF. However, is it possible for java or iText to convert it to JPEG or any IMAGE file and allow users to download the image file.
response.setContentType("application/pdf; charset=utf-8");
Merely changing the contentType to image/jpg is not possible. I am continuously looking for answer but struggling to find one.
Any idea would be a lot of help
I dont know more about iText. But using PDFBox we can convert pdf document into images.
After splitting you can push images to response.
Here some reference links :
http://pdfbox.apache.org/commandlineutilities/PDFToImage.html
Converting a PDF into multiple JPGs with iText or other
http://www.javatpoint.com/example-to-display-image-using-servlet
you can use iText only for generating a pdf nothing else. see the link http://itextpdf.com/itext.php . see this to convert a pdf to image. See this link as well for clearer understanding with an example.

How to extract images from pdf using Java (not using pdfbox)

I've being researching on how to extract images from a big (> 300MB) PDF file. I'm using pdfbox but for some particular reason that I can't figure out, some pages are not correctly extracted.
I'm using the PDFToImage class of pdfbox as base for my code.
So, do you know another library that may help me to do this? I know that iText may be used, but I read that it can't be used for commercial products.
I've installed the packages xpdf and xpdf-utils, and the utility called pdfimages is working perfect. But I need to solve this problem from Java and it should be portable.
I think you're talking about two different things here: extracting images from a PDF, and converting PDF pages to images. PDFToImage will output an image for every page, while pdfimages extracts all embedded images (e.g. a text document has 0 images).
Take a look at org.apache.pdfbox.tools.ExtractImages (source code) to see if it does what you want.
The most likely reason why it is hard working with 300 Mb PDF's is that you run out of memory. If it works well for smaller PDF's I would have a closer look at why it fails.
Have you tried icepdf or JPedal (both pure java)?

Categories

Resources