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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Writer and Acrobat

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,791
10
38
JP
Hi All,
Thanks heaps for al the help in getting me going in the report writer.
I have everything working in it that I wanted, but there is one more small thing I'm hoping to fix. Our default printer is Acrobat (which we have installed on the machines, so no issues about it, we just set the printer type). But when we print to Acrobat, that launches the Save dialog, which is also ok, but it always defaults the file name to the name of the reportform. Is there a way to have it use some other value (like expense title) as the default for the file name?


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Tore,
Well, we already have Acrobat, I'm trying to avoid using additional 3rd party tools.
If there is no way to do it, then we'll just tolerate it.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Indeed look at the pdf options of foxypreviewer

Acrobat: Not sure it's working with current Acrobat or needs the Distiller version, not just the

An alternative is Bullzip PDF printer - search Bullzip threads in this forum, you'll find something
Typically what's asked is to prevent the save as dialog.

In many cases, it's good the user knows where the file results. So you could simply use the output to hardwired output folder and then let users specify the final destination with PUTFILE and copy or move the output pdf file to the chosen folder and name.

Also, PDFCreator has an extensive configuration, that allows you to determine a default name put together from some tokens:
pdfcreator_iazixg.jpg

Not sure what token is easiest to influence, the thing you have under your control is the FRX name, so you could simply copy the report file with the desired name and make use of the <InputFileName> token as part of the output file name, like "Expense <InputFileName>" and "pass" over the Expense title with the FRX file name.

When you want interaction, this PDF printer driver gives you the best options, you can have such a default name and you can have a save as dialog suggesting that default name or you can also automatically save as you want and more options about mailing or viewing the result are possible (see the other tabs like Auto-Save and Actions. From that perspective, it's my favorite PDF printer.

Foxypreviwer is somewhat interesting and somewhat unfortunate in really generating the PDF file itself with a pdf DLL. This opens up many possibilities but also is limited to reports, you don't have a general PDF printer usable by users in Office or elsewhere, too.

Most often the wish is to not get a save as dialog, but then users still need to know where to get the PDF, so you likely end up automatically starting the viewer and the user saves the PDF with it's Save As function. Of course, you could also open up the folder with PDFs from your application, when you specify it, but that's just one of many aspects.

My final recommendation still is PDFCreator despite how nice Foxypreviewer is in general and despite how interesting it is to see into its source code report listener and pdf library usage.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Scott, you say you have intalled Acrobat on every machine. So you won't want to start looking for alternatives. I would only say that every PDF driver I have ever used has some way of setting the default output filename. This might be a simple parameter setting, or it might involve delving into an INI file or suchlike, but it's always been present.

Whether it is worth switching to a different system just to overcome this minor problem is up to you to decide.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
Thanks, I mean, Acrobat isn't cheap, and we have the full version. It's great because we do a lot of stuff with it beyond just VFP and it's great as a printer. The one down side I've seen so far is that for our expense report, we actually have 2 forms, one that runs a detail, and a second that prints images of the receipts. It would be great to be able to combine them as a PDF at print time, but it doesn't work that way. Then we have to combine them after using Acrobat Binder, which is an extra step, but workable. But that may drive me to go to another option, though I'm not sure that's going to solve this problem either. Wish there was a way to "continue" a report to another one that's really part of the same. When you send them to a printer, it's fine, but when they go to files and each one needs a file name, it's more painful.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Tore,
Okay, you may have convinced me to give it another try. I tried Foxypreviewer a few years back but wasn't a big fan. I think I still have the download here somewhere, and if not I'll go get another one.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott, I had a very similar requirement with an invoicing system. I had to print some of the invoices in two parts: one with a summary of jobs, and another with the details of each job. I solved it by using XFRX. That enabled me to do the reports directly in VFP, as normal FRXs, but to output them to PDFs. It all worked with no user interaction.

I don't know if this is still true, but the licensing costs for XFRX worked out much cheaper than for Acrobat, as I only needed a single developer's licence.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I vote with Mike.
Xfrx is a fantastic investment, well worth it.



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Yes, in regard of foxypreviewer it would be a waste of time to go back to the old download you have. Get the latest version of it. There is no newer VFP SP and Hotfix, so the app files of Foxpro included in the foxypreviewer download may be the same, but foxypreviewers advanced functionality are within other components like its print toolbar and that is an active project. So go get the latest.

Bye, Olaf.

Olaf Doschke Software Engineering
 
In regard of having the Acrobat Distiller product or Acrobat Writer or Acrobat PDF Server, whatever full version you mean, there should be ways to easily specify output folder at least. And if you know that you can always take the PDF file from there and prompt users for a path and name where they want to store it.

I remember even a corporation in the DAX was refusing to pay the prices of Acrobat for their server version and was looking for a solution to use the free Acrobat printer. It always boiled down to use something else that wasn't trying to make money from being the major vendor and maintainer of PDF standards. I also recommended another brand as we tested quite a lot, CIB PDF brewer was the only printer (including Acrobat), which printed Excel Sheet footers. Something perhaps not often used, but it speaks for itself. This was way back over 10 years ago, so things likely changed.

I agree there are different quality levels of PDF, in the simplest case you just put graphics output of everything including text into a PDF file and act quite like the simplest a GDI printer output which of course on paper makes no difference, but in PDF has the big impact of being able to select text or not, but even foxyPreviewers output is rendering text so you get a good output in that regard. It simply is limited to FRX printing and does not integrate as printer driver usable in other applications.

You also have the choice to let user save PDF or Word or Excel or print to a normal printer from the preview toolbar and not just by setting up the current printer, so that's a foxyPreviwer advantage. Here's the toolbars configuration dialog PDF options:
fppdf_zrnf71.jpg


I already agreed in that aspect a PDF printer is an advantage, especially of the PDF output is good and configurable up to actions done with it.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I see I'm also 5 versions behind. current foxyPreviwer is 2.99z36. Makes me wonder why this project doesn't declare v3.00 by now.

But you see there is (slight) progress in the project. The page provides a version history.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Ah, thanks for the links and comments. I'll give this a try. I can see it being helpful in simplifying the overall process. Thanks all for this.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
The alternatives already discussed above are good and you should use them if possible. However, if you must use Acrobat then please see the following example code. It only works if the application can write to the Windows Registry.

Code:
*/ Opens a Registry key
DECLARE INTEGER RegOpenKey IN Win32API ;
	Integer nHKey, String @cSubKey, Integer @nResult

*/ Sets a registry key.  Also creates the entry if it does not exist
DECLARE INTEGER RegSetValueEx IN Win32API ;
	Integer hKey, String lpszValueName, Integer dwReserved,;
	Integer fdwType, String lpbData, Integer cbData

*/ Closes a Registry key
DECLARE INTEGER RegCloseKey IN Win32API INTEGER hKey

*/ Check if Windows is 64bit
DECLARE INTEGER IsWow64Process IN Win32API INTEGER hProcess, INTEGER @Wow64Process
DECLARE INTEGER GetCurrentProcess IN Win32API

CREATE CURSOR tmp(ref N(10), firstname C(20), lastname C(20))
SELECT "tmp"
APPEND BLANK
REPLACE tmp.ref WITH 1, tmp.firstname WITH "Mickey", tmp.lastname WITH "Mouse"
APPEND BLANK
REPLACE tmp.ref WITH 2, tmp.firstname WITH "Donald", tmp.lastname WITH "Duck"
APPEND BLANK
REPLACE tmp.ref WITH 3, tmp.firstname WITH "Scrooge", tmp.lastname WITH "McDuck"

*/ For the example printing to work you need to create a report and save it as "c:\temp\report1.frx".
*/ The report itself can just have fields tmp.ref, tmp.firstname, tmp.lastname.
*/ Note that the function adobe_init has to called each time the report is run.  This is necessary because
*/ after printing, Acrobat clears the Registry entry set by adobe_init.
SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Mickey.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 1 NOCONSOLE TO PRINTER

SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Donald.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 2 NOCONSOLE TO PRINTER

SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Scrooge.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 3 NOCONSOLE TO PRINTER

*-----------------------------------------------------------------------------------

FUNCTION adobe_init
*/ In the "Adobe PDF" printer driver properties you must also set :
*/ - Spool print documents so program finishes printing faster
*/ - Start printing after last page is spooled
*/ - Print spooled documents first

LPARAMETERS lcFilePathAndName
LOCAL lnKeyRef, lcRegPath, lcExePathAndName, lnWin64

lnKeyRef = 0
lcRegPath = "Software\Adobe\Acrobat Distiller\PrinterJobControl"

lnWin64 = 0
=IsWow64Process( GetCurrentProcess(), @lnWin64)

*/ In Windows x86 we have to set the calling .exe file path and name in PrinterJobControl.  
*/ The .exe name and path will vary depending on the application.

*/ If the application doing the printing is 32 bit and running on Windows 64 bit then we have to
*/ always set the calling .exe file path and name as "C:\Windows\splwow64.exe" in PrinterJobControl. 
*/ Should Windows be installed to a different folder then change "C:\Windows\" as appropriate!
IF lnWin64 = 0
	lcExePathAndName = HOME()+"vfp9.exe"
ELSE
	lcExePathAndName = "C:\Windows\splwow64.exe"
ENDIF

RegOpenKey(2147483649,lcRegPath,@lnKeyRef)
RegSetValueEx(lnKeyRef,lcExePathAndName,0,1,lcFilePathAndName,LEN(lcFilePathAndName))

*/ Close the registry key 
RegCloseKey(2147483649)
ENDFUNC
 
If I am just mass producing PDFs without user interaction, can FoxyPreviewer still be used? An example would be as we create printed invoice copies for our shipping department to work from, we also create a PDF simultaneously from the same Foxpro report to have for our customer service agents to view when needed. The folder and file name are programatically determined on the fly.

I would be creating somewhere over 8,000 PDF's per day.

Thanks in advance.
 
Foxtrotter,
8000 PDF's per day? Meaning < 4 sec per PDF, I doubt you can do that with FP, unless you have a very fast printer and a small document to be rendered into PDF.
Better test with 10 first.
Regards,
Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top