Need help printing to PDF - multiple reports 1 directory

Discussions specific to Team Developer 5.1.

Need help printing to PDF - multiple reports 1 directory

Postby judith_jane » Mon Oct 24, 2011 1:32 pm

I'm stumped and need help please and being that I am the ONLY one in my corporation that develops in this language, I have no one else to turn to :( .

We have a reporting program that allows you to select the reports you want to print or view. While I have the reports printing fine to PDF to a directory of the users choosing, I'd like to change it to do the following because have to sit and specify the same place for each file to save to is a little annoying:

- prompt the user to select where they'd like to save the reports
- cycle through all the reports selected and print them to PDF to the specified directory with a predefined file name.

The problem is that each report is a form and each form has its own "ReportToFile" function. This is what I've tried:

-Main Form- print button: Save Dialog box prompts user and saves file path to global variable. Problem, it won't save the file path without a file name. The problem with this is that I'd prefer to save a different file name per report
- Report forms: Specifies strFileName, uses "SalPrintToFileEx" to print to pdf.Problem, if more than one file is selected, the first report is printed to pdf in the directory specified, then the second report will do the same, overwritting the first report.

Yes I realize that there are far better ways of doing this but this application has been around since the early 2000's and has been migrated from one version of Team Developer to the next, all the while retaining processes that were as a result of technical limitations. (Yes, today I'd design it differently but this is what I have to work with).

There has to be a better way of doing this. Can anyone help me please?
judith_jane
 
Posts: 8
Joined: Mon Oct 24, 2011 12:57 pm

Re: Need help printing to PDF - multiple reports 1 directory

Postby FRBhote » Mon Oct 24, 2011 10:36 pm

The first part is quite easy: don't use SalDlgSaveFile - have a data field with the path name and another with the file name (if necessary - this cold solve your second problem) and append the two to give the full name.
User avatar
FRBhote
 
Posts: 977
Joined: Mon Jul 07, 2008 7:38 am
Location: Hyderabad, India

Re: Need help printing to PDF - multiple reports 1 directory

Postby judith_jane » Wed Oct 26, 2011 7:08 am

Thanks FRBhote. Your suggestion would only work if the file path was either hard coded in or typed into a field by the user. My users range from barely knowing how to operate the application to advanced so having them navigate TO a file path would be the easiest.

The second part is, I don't know how to specify to "SalPrintToFileEx" where to print the file to. Am I missing something? Even when I had it so that "SalDlgSaveFile" was in the same function as "SalPrintToFileEx", I don't understand how the latter knows where to save it to. (I just recycled this function that was previously commented out - original developer no longer around to ask)
judith_jane
 
Posts: 8
Joined: Mon Oct 24, 2011 12:57 pm

Re: Need help printing to PDF - multiple reports 1 directory

Postby Charlie » Mon Oct 31, 2011 4:13 am

The "first time" a user goes to print a report to PDF, take the result of "SalDlgSaveFile" (i.e. the path) and save that to a configuration file (*.INI) for the user.

Before subsequent calls to SalDlgSaveFile, load the previously used path from the configuration file, and set the "strPath" return string (in your call to SalDlgSaveFile), then the user can just specify whatever name they want for the report.

Then, call SalReportPrintToFile.

Is this what you're looking to do? Or have I misread and you're doing this already and it isn't working out? (Haven't had my coffee yet ...)
Image

Come join us at Dave Rabelink's "Team Developer Community Forum"!
All users of OpenText™ Gupta Development Tools and Databases welcome!
http://tdforum.daverabelink.net/index.php
Charlie
 
Posts: 345
Joined: Mon Mar 10, 2008 5:04 am
Location: New Brunswick, Canada

Re: Need help printing to PDF - multiple reports 1 directory

Postby tfahey » Mon Oct 31, 2011 8:47 am

Let me offer another solution: There are several free or cheap PDF writers that have some great features. One is Bullzip (http://www.bullzip.com/). What we like about this is that it has a sophisticated 'append' feature that allows the programmer to bundle all those separate report into one .pdf file.
That's great for our customers who need to take several .qrp reports about a tenant and make one big file that is digitally stored or e-mailed to another client. An especially powerful feature in Bullzip is that it has a 'silent mode'. So when the user invokes it, by selecting it as a printer, we just send all their reports to their desktop as a file that they can then e-mail or digitally store to wherever they want.
From SqlWindows we store their current printer, let them print to pdf and return the printer to the original setting when they exit the module.
One note that you need to know about any .pdf option tha involves appending reports - you must introduce a delay between SalReport calls. The system needs a pause or else the 'bundle' of separate reports will be missing pages. I believe I use the forbidden call SalPause()

Here are some useful calls:
Everyone prints to the same named file on their desktop."sBatchFileName "
Locating and deleting a previous file on the desktop:
Call VisFileDelete(VisDosGetEnvString( 'USERPROFILE' ) || "\\desktop\\" || sBatchFileName )

Store the default printer settings early in your program.
Call SalPrtGetDefault( sgPrintDefault, sgDriverDefault, sgPortDefault ) ! Retain this because you should flip it back when they are done with batch printing
then they can choose the PDF printer
Call SalPrtSetup( sBatchPrinter, sBatchDriver, sBatchPort, FALSE ) ! Let them change the printer.
This call also saves this choice as the default printer from this point on.
and set it back later
Call SalPrtSetDefault( sgPrintDefault, sgDriverDefault, sgPortDefault ) ! Reset because they may have left the program printing to the batch printer.

Tom Fahey
HAB Inc
tfahey
 
Posts: 93
Joined: Wed Jan 07, 2009 1:14 am

Re: Need help printing to PDF - multiple reports 1 directory

Postby judith_jane » Tue Nov 01, 2011 7:56 am

Thank you everyone for your help.

I'll try both suggestions and get back to you. I'm really leaning towards the last solution because this is what the users want - multiple reports in one pdf which means they only have to physically print one file (if needed later down the road). Thank you!!
judith_jane
 
Posts: 8
Joined: Mon Oct 24, 2011 12:57 pm

Re: Need help printing to PDF - multiple reports 1 directory

Postby judith_jane » Wed Nov 02, 2011 1:15 pm

With further thought, is there a way to invoke the "Print to PDF" available in Microsoft Office 2007 within my 5.1 application? We have MANY users and I would prefer to make use of something we already have corporate licenses for.

I would like to use the idea that Tom had suggested (switch default printers) and have it switch to the Microsoft Office 2007 "Print to PDF" functionality.

Help please :).
judith_jane
 
Posts: 8
Joined: Mon Oct 24, 2011 12:57 pm

Re: Need help printing to PDF - multiple reports 1 directory

Postby tfahey » Wed Nov 02, 2011 2:56 pm

Hi Judith_jane
You lost me on this one. I would not know how to do that. Have you checked out all the capabilities of SalReportPrintToFile()? It does have the option to print to a .pdf. (But you can't append pages - at least up to TD5.1)
We just give our users a separate button besides "Print", we have "Print to PDF". How's that?

Tom
tfahey
 
Posts: 93
Joined: Wed Jan 07, 2009 1:14 am

Re: Need help printing to PDF - multiple reports 1 directory

Postby judith_jane » Fri Nov 04, 2011 7:10 am

tfahey wrote:Hi Judith_jane
You lost me on this one. I would not know how to do that. Have you checked out all the capabilities of SalReportPrintToFile()? It does have the option to print to a .pdf. (But you can't append pages - at least up to TD5.1)
We just give our users a separate button besides "Print", we have "Print to PDF". How's that?

Tom

Yes, I have a button that says "Print to PDF". Here's the current workflow:

Option 1
Select reports (one or more)
- Click "Print to PDF"
- For each report
    - Open Save Dialog box
    - File name is suggested
    - SalPrintToFileEx is envoked and PDF is printed
- Results in one to many PDF reports in the correct directory
- Downside: user has to click ok for every report


Option 2
- Select reports (one or more)
- Click "Print to PDF"
- Open Save Dialog Box (attempting to capture one directory)
- Can't just save directory, file name is required - user types in file name
- For each report
    - SalPrintToFileEx is envoked and PDF is printed to directory chosen and file name given
    - since you can't specify a specific file name per report (or at least I don't know how it's done), the next report overrides the previous report
- Results in one PDF report in the correct directory of the last report that is run
- Downside, only one PDF of the last report

I would know how to do this in .NET, it wouldn't be an issue but it seems very difficult to do in TD. I wish there was a property to append to PDFs, that would solve my whole issue without a whole lot of work.

My preferred solution would be Option 2, if I could get it to work the way I'd like it to. Highlights in the above are were I require assistance please.

I hope this makes sense. I'm getting really frustrated and it doesn't help that I'm the only developer that uses TD5.1 in an IT shop that's ALL .NET :(.

Thanks for the patience.
judith_jane
 
Posts: 8
Joined: Mon Oct 24, 2011 12:57 pm

Re: Need help printing to PDF - multiple reports 1 directory

Postby tfahey » Tue Nov 08, 2011 1:20 pm

I think the problem is summed up by your quote: " I wish there was a property to append to PDFs, that would solve my whole issue without a whole lot of work." That would be nice! But they do have a 'print to pdf' option in SalReportPrintToFile().
I think you need to nail down if the users are okay with the output of several reports being bundled into one .pdf file. Are they okay with that? If so where do you put that file?
We use to ask the user for a location, but with many clients using TermServer/Citrix we've now switched to placing the .pdf file on to their desktop. The file name is always the same and they are trained to use that file before they make another one. So some clients drop it into their dcument imaging systems, others e-mail it, others store it at locations that they are allowed to store docs.

I see you have many users, and so the Bullzip option could be trouble for you. It needs to be installed on each machine and your code needs to remember (safeguard) the 'real' default printer, so that they are not stuck printing to PDF when they don't want to.

Maybe some others would like offer solutions?

Tom
tfahey
 
Posts: 93
Joined: Wed Jan 07, 2009 1:14 am


Return to Team Developer 5.1

Who is online

Users browsing this forum: No registered users and 1 guest

cron