Read barcode from PDF document
-
Hi, I have a question. Is there a way to convert pdf to jpg?
I need to read the images from a pdf document. I am using QZXing to read barcodes. Barcodes must be in image format (jpg, png ...)Thanks for the help.
-
Hi
You can use command lines tools to do it.
https://gist.github.com/yura/670974 -
Ok. But I want do this in my application. Your solution working on other application.
-
Hi! ImageMagick can convert PDF to JPEG. If you don't want to use it as a command-line tool, you can also use it as a library.
-
@jacekkozik
There is no good way to do this directly in Qt.
You might be able to display a pdf and screen grab it but calling external cmdline program with
QProcess will work far better.
Or as wieland suggest using ImageMagick library.There is also this
http://blog.qt.io/blog/2017/01/30/new-qtpdf-qtlabs-module/
Says "QPdfDocument can render a PDF page to a QImage"
But i have not tried it. -
@mrjj said in Read barcode from PDF document:
There is also this
http://blog.qt.io/blog/2017/01/30/new-qtpdf-qtlabs-module/
Says "QPdfDocument can render a PDF page to a QImage"Awesome! \o/
-
Ok, i downloaded ImageMagick-i686-pc-mingw32.tar.gz.
And now as I typeconvert f.pdf d.jpg
f.pdf is in the same directory as convert.exe
I get the message:
convert.exe: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/616. convert.exe: `%s' (%d) "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-21380jSugM5nyzl-T-1" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick-21380wnE6NbHjVB6v" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick-21380qrAlRMgDXCHT" @ error/utility.c/SystemCommand/2033. convert.exe: PostscriptDelegateFailed `f.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/682. convert.exe: NoImagesDefined `d.jpg' @ error/convert.c/ConvertImageCommand/3106.
-
When working with PostScript files, ImageMagick relies on another program, "Ghostscript" for the reading and conversion of PostScript and PDF files into a image format it can use. That is to read such documents, Ghostscript needs to be installed on your computer. Its latest version can be downloaded at github.