I developed a JAVA application last year that took PDF files (incomming faxes) and converted them to TIFF files before storing them in a database. Unfortunately our needs have changed an I am left re-writing the way that the process is completed. I would like to incorporate this part of the process into another application that I've written in C++. My problem is that I can't figure out how make the conversion in C++.
I've run across several examples and solutions but they either make absolutely no sense to me or they require purchasing licenses to costly API's. My company is not a big one so we would like to avoid the cost of the license.
Any suggestions/guidance would be greatly appreciated.
In the JAVA app I used a library called PDFRenderer to convert the PDF to an Image. I then used the JAI library to convert the Image to a Buffered Image that was saved in the database as a TIF.
In another application I use ImageMagick's Magick++ to decode a DataMatrix barcode on the image, so I am vaguely familiar with their API. However, while I can convert PDF's to TIF's at the command line all day, I need to be able to convert them in code. We receive 20-30 faxes every day and they must be placed into the database as TIF's. (This is not my choice. These are constraints that were put into place before I was hired and I have to work with them.)
Before anyone accuses me of being too lazy to figure this out myself, I have looked for 2 days and have found hundreds of examples/tutorials for creating batch files or php scripts to do this, but nothing that can help me get this done in C++. I'm sure I am simply overlooking something and appreciate anyone's assistance in finding what it is that I'm missing.
Now I feel sheepish. I told you I was missing something simple.
Moschops, thank you very much for the input. My only issue is that when I convert directly from pdf to tif, the image is empty. I can convert to jpg just fine and then from jpg to tif but not directly from pdf to tif. Very strange. I'll see if I can figure out why as I work on converting mutliple page pdf's as well.
I still have no idea why I can't directly convert a single PDF to a TIF, however converting a mutli-page PDF seems to be working. I'm not incredibly happy with the image resolution, but I've got it working:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <Magick++.h>
usingnamespace Magick;
....
vector<Image> imageList;
readImages( &imageList, "FAX.PDF" );
for (int i = 0; i < imageList.size(); i++) {
stringstream fileName;
fileName << "FAX" << i << ".tiff";
imageList[i].write(fileName.str());
}
Thanks again for the help. Sometimes all it takes is a kick in the head to get the brain back on track.