I've looked through the forum and have not seen an answer for this. I would like to be able to import a pdf document in which each page contains an QR code. I want to then use the Barcode reader function to identify specific pages. Is there a way to convert the PDF pages into images within Mathematica. I have been able to use Acrobat to convert the PDF into images outside of Mathematica - but it would be nice not to have to pre-process each file.
Is there a way to convert the PDF pages into images within Mathematica
Yes, just do
f = Import["my_file.pdf", "Pages"]; and now
f is a list, each is one page. Then use
Export["f.png",f[]] to export the first page as
Here is MWE
SetDirectory[NotebookDirectory]; f = Import["my_file.pdf", "Pages"]; Export["page" <> ToString[#] <> ".png", f[[#]]] & /@ Range[Length[f]]
Just an alternative:
f = Import["my_file.pdf", "Pages"]; MapIndexed[Export["page"<>IntegerString[First@#2,10,2]<>".png",#1]&,f]
The use of
IntegerString allows left padding with zero which may useful in ordering files. In this case 2 -> 01,02,..99. This could be modified for large number.