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!

Name file for PDFWriter via Registry? 1

Status
Not open for further replies.

kazl

Programmer
Dec 9, 2002
68
0
0
GB
I want to pre-name output files for Acrobat PDFWriter.

I am using the code helpfully provided by Mike Krausnick in various threads. I did also try the sample wwPDF code from Rick Strahl's page at West Wind. I'm still stuck.

I read lots more tips on PDF and on setting items in the Registry, which is unchartered territory for me.

InitPDFName ends with error code 0=Success but I always get asked Save PDF File As with the name FoxPro.PDF

REGEDIT shows HKEY_LOCAL_MACHINE with Software\Adobe and a list of Acrobat & Adobe (er) stuff and a PostScript Printer Driver.

After running InitPDFName should I be able to use REGEDIT and see a new line for Software\Adobe\Acrobat PDFWriter with an entry for the file name? (If so, there isn't one there)

Also, my REGISTRY program supports Windows 32S, NT and Windows 95. But I am using Windows 98. Is this the whole problem and if so, can I get a new REGISTRY program for use with VFP6?

Sorry this is long winded but I really want to crack this. Any help is appreciated. TIA

Kaz
 
Hi
I know nothing about registry, however you can use the code below to set your default printer to Acrobat Distller

oNet = CreateObject("WScript.Network")
oNet.SetDefaultPrinter("Acrobat Distiller")
REPORT FORM report101 TO PRINTER NOCONSOLE


I hope this helps
 
That's very odd. To answer your question, yes, you should be able to see an entry in the registry containing the filename you passed to the InitPDFName routine, provided that you don't actually print a report to PDF. In other words, if you run InitPDFName and do nothing else, you should be able to find your filename in the registry using REGEDIT.

However after you print a report to PDF, the filename entry in the registry is cleared. I think the entry is still there, but the value of the entry is a null string. In any case, once you run InitPDFName the dialog box asking for a filename should NOT appear - that's the whole point of the function.

I don't think that the fact that you're using VFP6 on Win98 should be a problem, but I'm not positive about that. I implemented InitPDFName on VFP7 running on Win2K, and it also works in VFP8. It's been a long time since I wrote the code but I can't remember having to do anything special other than call the routine. However, I'm out of the office on vacation right now and don't have access to the code. I'll re-check the code on Monday 12/1 when I return and post back.

One thing that occurs to me is that the actual name of the PDFWriter printer in your PRINTERS screen might be a factor. Also, last week I upgraded to Adobe Acrobat 6 on one of my development machines, which required me to uninstall Acrobat 5, and that resulted in the PDFWriter driver also being uninstalled. In a post I responded to in the Adobe forum I learned that in Acrobat 6, the PDFWriter printer driver was replaced by the Adobe Distiller printer driver. That driver has a different name and acts differently so maybe InitPDFName no longer works with Acrobat 6. What version of Adobe Acrobat are you using?

Lastly, just in case I didn't mention it before and to give due credit, InitPDFName is based on a Rick Strahl tutorial I read, either in Foxpro Advisor or on west-wind.com (can't remember which).



Mike Krausnick
Dublin, California
 
I am using Acrobat 5, so that should be OK.

My printing program calls InitPDFName and then suspends so I can open REGEDIT before the REPORT instruction. I then check through REGEDIT but there's no PDFWriter entry.

I just wondered if it was due to REGISTRY.PRG being too early for Win98 but I guess the names etc that it uses for Windows will probably be the same between 95 & 98.

Anyway, enjoy your vacation and I'll see what I can find. Thanks.

Kaz
 
Kaz,

I know I used to do this some time ago. As far as I can remember there is a difference between W95/98 and NT os´s.
For W95/98 you should writing the data into a ini-file, not into the registry. I will try to locate routine....
 
The REGISTRY class has been include with VFP since at least version 6. Its purpose is to write to the registry. Also, Acrobat 5 reads the registry - using an INI file won't work.

Kaz, I checked the code today and, as I thought, there is nothing additional that needs to be done. I call INITPDFNAME() which writes a registry entry by executing oReg.SetRegKey() using the VFP registry class REGISTRY.PRG.

Just off the top of my head, things you should check (you've probably already thought of these):
1. Are you specifying the folder name and key name in the INITPDFNAME call? They default to the correct values for Acrobat 5 so you don't need to specify them (maybe they are being mis-spelled in the call?)
2. Try looking in the registry for the key name rather than the filename you're trying to create. The key name is "PDFFileName" - it should definitely be present.

Lastly, what version of Acrobat are you using? Maybe, as nc1264 suggested, your version of Acrobat is looking for an INI file instead of using the registry. There are functions in REGISTRY.PRG to access INI files too, but you would have to write a wrapper for them.



Mike Krausnick
Dublin, California
 
Erm, hello. Its nine months down the line and I've just come back and completed this PDF job using the Free PDF Maker from (found via faq184-2143 and thread184-367933).

I previously had to abandon this task due to other pressures but just found this thread and realised that I'd left it hanging without any thanks for all your help. A bit rude. Sorry. :~/

I never did crack the use of REGISTRY but the PDF Maker was just the ticket for me.

Thanks very much for your support though Mike, Beauty Lover and nc1264.

Kaz
 
This is something I come across when trying to do the same thing. I have tested this and it works.


close databases

use c:\lopfi\dbases\combdet
PUBLIC hkeynum,hcreatenum
hkeynum = 0
hcreatenum = 0
#DEFINE hkey_current_user -2147483647 && BITSET(0,31)+1
#DEFINE security_access_mask 983103 && SAM value KEY_ALL_ACCESS
DECLARE RegCreateKeyEx IN ADVAPI32.DLL;
INTEGER, STRING, INTEGER, STRING, INTEGER, INTEGER, INTEGER, INTEGER @, INTEGER @
DECLARE RegSetValueEx IN ADVAPI32.DLL;
INTEGER, STRING, INTEGER, INTEGER, STRING, INTEGER
DECLARE RegCloseKey IN ADVAPI32.DLL;
INTEGER
&& Basic Parameters valid for the whole set of reports
= RegCreateKeyEx(hkey_current_user,"SOFTWARE\ADOBE\ACROBAT PDFWRITER",0,"REG_SZ",0,security_access_mask,0,@hkeynum,@hcreatenum)
= RegSetValueEx(hkeynum,"bDocInfo",0,1,"0",2) && No Document Info Dialog Box
= RegSetValueEx(hkeynum,"bEmbedAllFonts",0,1,"1",2) && Embed All Fonts
= RegSetValueEx(hkeynum,"bExecViewer",0,1,"0",2) && Do not Launch viewer after creating PDF file.
= RegSetValueEx(hkeynum,"compatibility",0,1,"1",2) && Compatible with version 2.1
= RegSetValueEx(hkeynum,"paper",0,1,"3",2) && Paper size A4
= RegSetValueEx(hkeynum,"szAuthor",0,1,"AuthorName",LEN("AuthorName")+1)
= RegSetValueEx(hkeynum,"szCreator",0,1,"CreatorName",LEN("CreatorName")+1)
= RegSetValueEx(hkeynum,"szKeyWords",0,1,"YourKeyWords",LEN("YourKeyWords")+1)
= RegSetValueEx(hkeynum,"szSubject",0,1,"DocumentSubject",LEN("DocumentSubject")+1)
= RegSetValueEx(hkeynum,"szTitle",0,1,"DocumentTitle",LEN("DocumentTitle")+1)
= RegCloseKey(hkeynum)
&& Procedure that generates your reports
SCAN
= RegCreateKeyEx(hkey_current_user,"SOFTWARE\ADOBE\ACROBAT PDFWRITER",0,"REG_SZ",0,security_access_mask,0,@hkeynum,@hcreatenum)
= RegSetValueEx(hkeynum,"PDFFILENAME",0,1,"YourPDFFileName",LEN("YourPDFFileName")+1)
= RegCloseKey(hkeynum)
* REPORT FORMAT C:\lopvfp\combchk\combine.frx TO PRINT NOCONSOLE
ENDSCAN
&& Anulation of your initial settings
= RegCreateKeyEx(hkey_current_user,"SOFTWARE\ADOBE\ACROBAT PDFWRITER",0,"REG_SZ",0,security_access_mask,0,@hkeynum,@hcreatenum)
= RegSetValueEx(hkeynum,"szAuthor",0,1,"",1)
= RegSetValueEx(hkeynum,"szCreator",0,1,"",1)
= RegSetValueEx(hkeynum,"szKeyWords",0,1,"",1)
= RegSetValueEx(hkeynum,"szSubject",0,1,"",1)
= RegSetValueEx(hkeynum,"szTitle",0,1,"",1)
= RegCloseKey(hkeynum)

*** Using the Acrobat Distiller API
&& Define distiller object
oDistPDF = createobject("PdfDistiller.Pdfdistiller.1")
&& Procedure that generates your reports
SCAN
&& I suggest to use the free downloadable Adobe PostScript Printer Driver to create the PostScript file, this results in very small PDFfiles.
REPORT FORMAT C:\lopvfp\combchk\combine TO FILE c:\temp\ps.ps NOCONSOLE && PostScript-files can become enourmous
oDistPDF.bSpoolJobs = .f. && does not return until the PDF file is created
if oDistPDF.FileToPDF("c:\temp\ps.ps","C:\temp\pdf1.pdf","PrintOptimized.joboptions") = 1
&& in the file PrintOptimized.joboptions you can save the preferred distiller settings (compression, dpi, ...)
&& Distiller creates a log file which you can delete at this time
endif
ENDSCAN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top