Read QR Code from scanned PDF

北战南征 提交于 2019-12-09 16:13:55

问题


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


回答1:


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)




回答2:


I have gotten this to work:

  1. Use Imagick to converts pdfs into pngs
  2. Use Zxing \ QrReader to read the QR data


来源:https://stackoverflow.com/questions/5537167/read-qr-code-from-scanned-pdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!