Report to PDF and TIF

Hi there:

I am putting together a new VFP application where I will need to create a new multi-page PDF and combine it with another multi-page PDF, creating one new multi-page PDF.

Then, using the new multi-page PDF, I need to convert it to a multi-page TIFF file and keep both the PDF and TIF files.

Do any of the newer XFRX versions do this sort of thing, or do you have any insights into how I can accomplish this?

Please help.

Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PDF is a document format and TIFF is an image like JPEG ,PNG or BMP.Typically,each PDF page can be exported as one Image file(eg:-TIFF).I think you may need to think about work around to accomplish what you need.

You can use to print multipage pdf into a multipaged single TIFF.Alterantively ,you could try to combine multiple TIFFs  -exported per page from PDF-into single TIFF
XFRX cannot combine two PDFs but it can append the PDF output to some already existing PDF file.

XFRX cannot convert PDF file to a TIFF file but it can produce multipage TIFF as the report output format.

So to create both PDF and TIFF you will need to run the report twice or you may store the report output to XFRX internal XFF format and do whatever you need later.

The latest XFRX documentation is available here:
Unfortunately this documentation does not cover the latest XFRX version...
Joe WinogradDeveloperCommented:
Hi Cathie,
To give a different perspective on an earlier comment in this thread, I would say that PDF and TIFF are similar, in that both are document formats, both may contain images, and both may be multi-page. I know nothing about FoxPro, but since VFP is a procedural programming language, I'm sure it can make command line calls. So I would recommend the latest version of IrfanView, which is excellent (free!) imaging software that I've been using for many years. If you already have it installed, make sure it is at least version 4.36, which is the first version to support the "/multipdf" command line parameter (previous versions had only the "/multitif" command line parameter). If you don't have it installed, then install the latest version, 4.37, from here:

Click the Download link on the left to download IrfanView and click the PlugIns link on the left to download the PlugIns, which are needed to give you PDF capability. Install IrfanView first, then install the PlugIns.

The command line documentation is in a file called <i_options.txt> in the IrfanView program files folder, probably <c:\Program Files (x86)\IrfanView\> or <c:\Program Files\IrfanView\>. I have also attached it as a PDF for you.

Once you've created the new multi-page PDF, here's the command line syntax to combine it with the existing PDF to create a combined PDF:

i_view32.exe /multipdf=(c:\path\combined.pdf,c:\path\existing.pdf, c:\path\new.pdf)

That is, the first file is the result (combined) PDF file, while all subsequent files (there may be any number) are the input files (and wildcards are allowed for the input file names).

After creating the combined PDF, here's the command line syntax to create a multi-page TIF from the multi-page PDF:

i_view32.exe /multitif=(c:\path\combined.tif,c:\path\combined.pdf) /killmesoftly /silent /tifc=4

The "/multitif" syntax is similar to the "/multipdf" syntax. You'll want the "/killmesoftly" and "/silent" params for calling it in a program. The "tifc" param is for the TIFF file compression. Its values may be:

3=ITU-T Group 3
4=ITU-T Group 4

I have experimented extensively with them and unless you have a reason for picking something else, I strongly recommend ITU-T (previously known as CCITT) Group 4.

This should do it for you. Regards, Joe
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

IrfanView sounds feasible. I've never used it for PDF/TIFF concatenation just batch JPEG conversions.

And yes, VFP can execute command line by RUN command or by ShellExecute Win32 API call.
Joe WinogradDeveloperCommented:
Yes, it works well for PDF and TIFF merging. An article I wrote here at EE, How To Combine-Merge-Append a Large Batch of TIFF Files discusses it in detail, including source code for a program that calls it. And thanks for letting me know that VFP can execute a command line – I suspected as much, but it's good to have the confirmation.

Depending on the logic in your VFP program, you may be able to combine the two calls I mentioned in my last post into one call, as follows:

i_view32.exe /multitif=(c:\path\combined.tif,c:\path\existing.pdf,c:\path\new.pdf) /killmesoftly /silent /tifc=4

Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe,
Irfanview seems most promising....I downloaded and installed program and plug-ins, and am running test command lines from within VFP. I received an error that it could not open a PDF (attempting multipdf first). I looked at the Irfanview <i_options.txt> file and it said to download a program called Ghostscript. I downloaded and installed Ghostscript but it's not found - still get the same error. Any thoughts?
Joe WinogradDeveloperCommented:
Hi Cathie,
Make sure you installed the 32-bit Ghostscript (even if your OS is 64-bit), because IrfanView is a 32-bit program and needs the 32-bit Ghostscript. If you installed the 64-bit GS, uninstall it and install the 32-bit one, which is available at SourceForge:

The download button at that page gets you the latest 32-bit version, <gs909w32.exe>. I'm nearly certain this will fix your problem, but let me know if it doesn't and I'll walk you through how to modify IrfanView's configuration file to tell it where the 32-bit Ghostscript DLL is installed. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
OK - Ghostscript looks OK now. Thanks.
Now, if I run this command (VFP command to run outside program) "RUN", then,
Irfanview opens up but says no file is loaded.
I was only able to do this by copying i_view32,exe to the folder where my VFP program will run from. I will need to do this for the install, it is not possible to install Irfanview on any and all possible workstations that will run my program which will be stored on a server.
I am running VFP9 on Windows-7.  The final app will need to run on Win-XP and Win-7.
Any thoughts?
Joe WinogradDeveloperCommented:
Hi Cathie,
A few suggestions: (1) Put a space between [.exe] and [/multipdf]. (2) Add the parameters [/killmesoftly /silent]. (3) Fully qualify the path to IrfanView on your server. So the line is something like this (assuming the H drive is mapped to your server – or use UNC):

H:\server_programs_folder\IrfanView\i_view32.exe /multipdf=(c:\path\combined.pdf,c:\path\12345.pdf,c:\path\67890.pdf) /killmesoftly /silent

In other words, install IrfanView on your server. It uses a configuration file called <i_view32.ini>. In a normal W7 install, it's better to put <i_view32.ini> in %APPDATA% rather than %ProgramFiles%. In fact, <i_view32.ini> in %ProgramFiles%\IrfanView would just be this:


However, for an install on your server, just leave <i_view32.ini> in the same folder with <i_view32.exe> and make sure it does not have the INI_Folder redirection as shown above.

Then install the 32-bit Ghostscript on your server, such as in:


So if you install the current 9.09, the link to the DLL will be:


Now, put this section in <i_view32.ini>:


Now this should work for both XP and W7. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
I guess I wasn't clear, in development mode I am not using a server. Irfanview and gs are installed in Program Files (x86) (Win-7),
I have removed i_view32.exe from my program folder, and put the Ghostscript section into i_view32.ini (in Program Files (x86)\Irfanview) and used this command:
RUN "c:\Program Files (x86)\IrfanView\i_view32.exe /multipdf=(c:\myfolder\combined.pdf, c:\myfolder\12345.pdf, c:\myfolder\67890.pdf) /killmesoftly /silent"
(The quotations are because of the spaces in the command, required by VFP.)
I now get an error that says "program is not recognized as an internal or external command, operable program or batch file".
I think that it's because of a path issue but I'm not sure what else to do. Also, I'm not sure what you mean by %ProgramFiles% and %APPDATA%.
The correct command should be:

RUN /N "c:\Program Files (x86)\IrfanView\i_view32.exe" "/multipdf=(c:\myfolder\combined.pdf, c:\myfolder\12345.pdf, c:\myfolder\67890.pdf) /killmesoftly /silent"
Joe WinogradDeveloperCommented:
Hi Cathie,

> I have removed i_view32.exe from my program folder

Why did you do this? In any case, it doesn't matter where IrfanView is installed, but you must, of course, call the executable wherever it is.

> put the Ghostscript section into i_view32.ini (in Program Files (x86)\Irfanview)

That's good, but then why did you remove <i_view32.exe> from there?

> used this command: RUN "c:\Program Files (x86)\IrfanView\i_view32.exe /multipdf=(c:\myfolder\combined.pdf, c:\myfolder\12345.pdf, c:\myfolder\67890.pdf) /killmesoftly /silent"

I see that pcelba has recommended the "/N" parameter for your VFP call. As I don't know the syntax of VFP, I can't comment on that. The article I mentioned earlier shows the Run command (RunWait, actually) in a different language and it works perfectly.

> I now get an error that says "program is not recognized as an internal or external command, operable program or batch file".

That's because you removed <i_view32.exe> from <c:\Program Files (x86)\IrfanView\>, yet that's exactly what your Run command is calling.

> I'm not sure what you mean by %ProgramFiles% and %APPDATA%.

These are environment variables in Windows. Do a "set" command in a command prompt and you will see the values of your environment variables. %ProgramFiles% is typically <C:\Program Files> and %APPDATA% is typically <C:\Users\username\AppData\Roaming>. I was just using the variables as a shorthand way of specifying those folders. Regards, Joe
More important are double quotes.

The /N parameter means direct Windows app call (without cmd window).
Joe WinogradDeveloperCommented:
Ah, got it! She had one set of double quotes around everything, rather than a set around the EXE name and another set around the params. Good catch!

As a follow-up to my last comment in my previous post, being a 32-bit program, IrfanView is typically installed in <c:\Program Files (x86)\IrfanView\> on 64-bit Windows, not in <c:\Program Files\IrfanView\>.

Regards, Joe
ramramcatprogrammerAuthor Commented:
Thanks to you both.  BTW, I didn't remove the <i_view32.exe> from c:\Program Files (x86)\IrfanView\, I had put a copy in my software development folder and then removed it from there.
The double-quotes helped. Now, when I run the command line (as shown above by pcelba), I get a dialogue box called "Save PDF". I believe it's part of Irfanview. It has 8 tabs and is open to the "layout" tab. The "Save" button on the bottom is greyed-out. Nothing seems to activate "Save". Any ideas? BTW - HAPPY NEW YEAR!!
Joe WinogradDeveloperCommented:
Hi Cathie,

> I believe it's part of Irfanview.

It's from a PlugIn called ImPDF, which allows IrfanView to write PDF files. Here's how to stop the dialog box. Look for a section in <i_view32.ini> called:


It will have many parameters. One will be:


Change that to:


Now you won't get that dialog box. You'll see a green progress bar that looks like this:

ImPDFBut it will automatically go away when the new PDF file is created. That should do it!

Happy New Year to you, too! Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
OK - here's what happened. I went to edit <i_view32.ini>. There was no [ImPDF] section.
I added a line to the end: [ImPDF], and then a line: ImpdfPreviewOn=0
When I ran the command I got a dialogue box asking for a password.  I feel like I'm missing a lot of lines in the <i_view32.ini> file.
When I (temporarily) removed the /killmesoftly /silent parameters, I got a message from Irfanview that it could not load my (input) PDF files. I tested this with multiple PDFs that I have from multiple sources. It could not load any of them. Acrobat-X can open all of them.
I never got the green progress bar, above.
Joe WinogradDeveloperCommented:

Two ideas. First, if you don't have an [ImPDF] section, it may mean that you don't have the IrfanView PlugIns installed where IrfanView is. As I mentioned earlier, IrfanView may be installed anywhere, but the <Plugins> folder must be an immediate subfolder of the IrfanView folder.

Yes, there are a lot of ImPDF lines in the typical IrfanView config file. Here's what mine looks like:


Now for the second idea. I normally don't recommend IrfanView for combining PDF docs. In fact, until recently, IV didn't have the "/multipdf" option. I did it in this case because you ultimately want a TIFF file and I do often recommend IV for that – the "/multitif" option has been around for a long time. I figured as long as you need IV for the TIFF conversion, you might as well use it for PDF combining, too. But since that's been so problematic for you, another approach for merging the PDFs is the PDF Toolkit (PDFtk), an excellent (also free!) product that has numerous features to manipulate PDFs. It comes in both command line and GUI versions. The command line version is called PDFtk Server and may be downloaded here:

Don't be misled by "Server" in the name. I don't know why they called it that, but it's just an executable (pdftk.exe, with a supporting DLL, libiconv2.dll) that runs on XP, Vista, W7, and W8 (it does not have to run on a "server" also runs on Mac, but I've never used it on that). It comes with an installer, but at the end of the day, all you really to do is simply put the <pdftk.exe> and <libiconv2.dll> files in the same folder wherever you want them.

Here's the PDFtk command line for combining two files into a third:

pdftk input1.pdf input2.pdf cat output combined.pdf

The "cat" operation "catenates" (joins/merges/combines) the input files into the output file. Here's the Man Page describing the entire syntax:

And here are usage examples:

If you want to see PDFtk used in a real-world app, see this EE article that I wrote:

It is a long article and program, but you may focus just on the usage of PDFtk. The tool has worked perfectly in all programs I've written that call it.

After using PDFtk to combine the PDF files, you may then use IV to convert from PDF to TIFF, as I mentioned in my first post:

i_view32.exe /multitif=(c:\path\combined.tif,c:\path\combined.pdf) /killmesoftly /silent /tifc=4

Since IV won't be writing a PDF, it won't need the ImPDF PlugIn, so you'll avoid those problems (to read PDFs, it will need just Ghostscript, which is working for you now). Just another idea. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
Something came up that I've had to take care of before continuing on the PDF/TIF project. It'l be another day or two. Thank you so much for all of your suggestions - I'm looking forward to trying the PDF Toolkit solution.
Joe WinogradDeveloperCommented:
Hi Cathie,
No problem. Take your time. I'll be here. Hope your New Year is off to a good start! Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
Well, I finally got to try PDFtk. . . . .and it worked!! First time!! Thank you.
Now, here's an interesting problem. . . the multitif option of IV isn't working correctly either. I was able to create a TIF, but it is empty / blank. I get the same result using the (new) PDF and using a JPG that I had. I'm thinking that the PlugIns are not loading properly because my i_view32.ini file looks like this:

Save Compression=4

That's it! I even uninstalled and reinstalled Irfanview and Irfanview PlugIns v4.37. I searched my computer for any "hiding" ini files and found none. I feel like something is missing. What to do? Thanks.
Joe WinogradDeveloperCommented:
Hi Cathie,
I'm glad to hear that PDFtk worked the first time. Re IrfanView, I don't think the INI file is the problem. For starters, try it outside the VFP program, just in a simple command prompt. If it doesn't work, please post the exact command that you're using. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
Sadly it didn't work from a command prompt either; same result - empty/blank tif file. This is the command:

l:\samples\i_view32.exe /multitif=(l:\samples\test.tif,l:\samples\test.pdf) /killmesoftly /silent /tifc=4

Joe WinogradDeveloperCommented:
Is IrfanView installed in <l:\samples\>? In order for your command above to work, <i_view32.exe> must be in <l:\samples\>, probably along with the <Plugins> subfolder. My IrfanView install folder looks like this:

IrfanView install folderI'm sure the install folder can be anywhere you want, but it probably is looking for the Plugins (and other subfolders) under the install root folder. So either move the Plugins folder there (if it isn't) or try a "normal" install of IrfanView, i.e., let it install in <c:\Program Files (x86)\IrfanView\> for a 64-bit OS or <c:\Program Files\IrfanView\> for a 32-bit OS. Then change your command to:

c:\Program Files (x86)\IrfanView\i_view32.exe /multitif=(l:\samples\test.tif,l:\samples\test.pdf) /killmesoftly /silent /tifc=4


c:\Program Files\IrfanView\i_view32.exe /multitif=(l:\samples\test.tif,l:\samples\test.pdf) /killmesoftly /silent /tifc=4

One other thing. I just had a thought about your description of <i_view32.ini>. That could be a problem, since it has to find the Ghostscript DLL. Normally, IrfanView finds it automatically and I thought you were OK on that front after installing the 32-bit version (you said, "Ghostscript looks OK now"). But if the TIF file is blank, that may mean it's not finding Ghostscript, which is required to read the PDF file, so you may need to put the Ghostscript section in <i_view32.ini>, as we discussed earlier:


Also, remember that the <i_view32.ini> that's in the IrfanView install root folder may simply be pointing to the "real" <i_view32.ini>, which is where you need to put the Ghostscript section. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
Thanks for all of your patience and help.
I put the (entire) \Irfanview folder and the \gs folder into my \samples folder and renamed the original IV and GS folders in \program files. I will not be able to install any software on workstations at my client's site, only to the server.
I copied your ghostscript lines (above) to my <i_view32.ini> file in \samples\irfanview and modified the path for gsdll32.dll.
I ran this statement from a command prompt:
l:\samples\irfanview\i_view32.exe /multitif=(l:\samples\test.tif, l:\samples\test.pdf) /killmesoftly /silent /tifc=4
I still get a blank/empty tif file.
My irfanview folder looks like yours (above) except that my <i_view32.ini> is only 1KB.
Joe WinogradDeveloperCommented:
Please attach your <i_view32.ini> file and <test.pdf> file. Thanks, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
Attached are my <i_view32.ini> file and <test.pdf> files. Please remember that the multitif didn't work using a JPG (a photo) either. The Tif was empty/blank.

Also, I noticed a strange file called <libiconv2.dll> that somehow got into my folder. Do you know what that is?  Its presence or removal does not affect the multitif problem.
Joe WinogradDeveloperCommented:
Hi Cathie,
The problem is the space after the comma in your command line. Right after "(l:\samples\test.tif," you have a space before the "l:\samples\test.pdf)". Remove that space and it will work. Your <i_view32.ini> is fine. Attached is the TIF file converted by IrfanView using a duplicate of your <l:\samples> file structure and your <i_view32.ini> file.

<libiconv2.dll> is the DLL required for <pdftk.exe>.

Regards, Joe

P.S. It's 2am in my neck of the woods, so I'm headed for some shut-eye. I'll check back in here first thing in my morning to see how you're doing, but I'm pretty sure you'll be good-to-go by then, as I feel very confident about the fix above.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ramramcatprogrammerAuthor Commented:
Y E S !!!!!
IV Multitif worked through the Command prompt!!

Now, I will run PDFtk and IV through VFP and I'm on my way to getting my project done!!

I'll let you know how that turns out.

Thanks a million, Joe, your help has been invaluable.

Joe WinogradDeveloperCommented:
That's great news! You're very welcome. Looking forward to hearing how the next phase of the project goes. Regards, Joe
ramramcatprogrammerAuthor Commented:
Hi Joe:
The PDFtk and IV-multitif commands work perfectly through VFP! There are no quotes (") required, most likely due to no more spaces (I would use them if there are spaces in filenames).
The multitif command is:
RUN /N7 l:\MyDir\irfanview\i_view32.exe /multitif=(l:\MyDir\combined.tif,l:\MyDir\combined.pdf) /killmesoftly /silent /tifc=4
Thanks again!
ramramcatprogrammerAuthor Commented:
Joe is very patient and provides really clear and detailed explanations for his solutions.
He is a fabulous asset to Experts-Exchange!
Joe WinogradDeveloperCommented:
I'm delighted to hear that PDFtk and IrfanView are working for you and that you've completed the project. Excellent news...Congratulations! And thanks for the kind words...I truly appreciate it! Have a great week. Regards, Joe
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.