Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate PDF Reports

Status
Not open for further replies.

lifesupport

Programmer
May 18, 2004
64
US
I'm trying to programmatically concatenate PDF reports. The first call seems to work, but saves it to the name of the project preceeded by "Project Manager". This file is always blank. The second call is triggered because the file DEMREPT.PDF doesn't exist. This time it prints correctly as well as the remaining reports that are attached. How can I get the report to print correctly the first time without having to call it twice. This will be confusing to users.

The pdf driver installs programmatically and correctly.
consol is off
set print is on
lcReport="DEMREPT.FRX"
IF pdfconcatenate
Report FORM (lcReport) NEXT NOCONSOLE NOPAGEEJECT &&prints to a file named 'Project manager - [name of project]'

pcmyfile="c:\output\"+ALLTRIM(lcreport)+".PS"
lcmyfile2="c:\yelpage\"+ALLTRIM(lcreport)+".PS"
IF NOT FILE(pcmyfile) and NOT FILE(lcmyfile2)
Report FORM (lcReport) NEXT (mtopcnt) NOCONSOLE NOPAGEEJECT &&if the report DEMREPT.PDF doesn't exsist, try again.
endif

 
You need to test for the presence of PCMyFile and PCMyFile2 before you do the first print. If these files don't exist, do the first report without NOPAGEEJECT. If they do exist, do the first report with NOPAGEEJECT and the second without.

In other words, you must always issue the final REPORT FORM for a print job without NOPAGEEEJCT (otherwise the job doesn't get closed properly).

As for why you are seeing that strange print job name, that's a matter for the PDF printer driver. There's presumably a setting somewhere where you can specify a filename. Check the driver's documentation.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks for your response Mike.

I mis-spoke above. It initially creates a post script file not a PDF. That is why the file has a 'nopageeject' so that I can continue to add reports before I close the file and convert it to a PDF.

Report #1 doesn't work. The lcreport is simply the report name and is correct and exists. mtopcnt is simply the # of records to print. pcmyfile and lcmyfile2 do not exist, which is why report #2 is triggered.

Report #2 does work. The lcreport is simply the report name and is correct and exists.


IF pdfconcatenate

#1 Report FORM (lcReport) NEXT NOCONSOLE NOPAGEEJECT &&prints to a file named 'Project manager - [name of project]'

pcmyfile="c:\output\"+ALLTRIM(lcreport)+".PS"
lcmyfile2="c:\yelpage\"+ALLTRIM(lcreport)+".PS"
IF NOT FILE(pcmyfile) and NOT FILE(lcmyfile2)

#2 Report FORM (lcReport) NEXT (mtopcnt) NOCONSOLE NOPAGEEJECT &&if the report DEMREPT.PDF doesn't exsist, try again.
endif
 
A couple of questions...

"saves it to the name of the project proceeded by "Project Manager""
This is usually an issue associated with the PDF 'printer' and how it is configured.

I find that it is much easier to configure the PDF "printer" to always output to a single, specific filename at a single, specific location.
I then use VFP to get that file and Rename and/or Move it as necessary for use however I want.

So are you really trying to "programmatically concatenate PDF reports"?
Or are you trying to create a single PDF file from 2 (or more) VFP Report Forms?

Generally I find that by preparing my Report Table/Cursor well in advance and using the Print When... expressions within the Report Form, I can get multi-page reports relatively easily and then I send the Report Form to my PDF printer to create a single document.

Good Luck
 
Lifesupport,

I'm not clear why you are creating an intermediate Postscript file. Is there any reason why you can't simply print the reports to PDF, using a PDF printer driver? I do this all the time, and it works fine.

You could then use NOPAGEEECT as per previous reply (that is, add it to every REPORT FORM except the last).

Alternatively, you can find a printer driver that concatenates the reports for you. As an example, I use the Docucom driver. When I tell it to output a report to the same filename as one that already exists, it lets me choose whether to overwrite the existing file or to concatenate. I would think other drivers offer a similar facility.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top