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!

Setting location and filename for PDF file 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi,

For a while now I've been trying to find out how I can get the file path and file name set when printing directly to the acrobat distiller virtual printer from a powerbuilder application.
I do not want to use the option to select the filename and path, but whould like to set them in advance from the printing application. Setting the port and options for the acrobat distiller virtual printer is not a desired solution, and I can't find any calls to set them from the application itself.
When setting a path and filename in the win.ini file results in an severe-error on the second print action, so that's not an option. (Or is it?)

Any ideas?

Coretta van Nijnatten
Powerbuilder programmer
 
Unfortunately I don't have an answer for you - I'm just repeating your question. I'm trying to accomplish the same automation with Distiller - though I'm going it from VB rather than PowerBuilder. I'll post here if I find an answer. If you've found one since you posted this would you please tell me how to do it.
Thanks,
 
I couldn't find a way to do it either, so I scrapped the idea of using Distiller, and went with PDFWriter instead. If you use Open# on the file c:\windows\system\pdfwritr.ini and use Print# to add the line &quot;PDFFileName= <full path and filename that you want&quot; to the end of it, and then have the application print to the PDFWriter, it will generate the pdf file where you want it, and it won't create a log file. It is faster too.
 
I'm using Acrobat 5.0 and windows 2000 and I can't find the file &quot;pdfwrit.ini&quot;, do you have another sugestion?
 
The pdfwritr.ini file is only for Windows 95 and 98. For Windows 2000 (which is NT based) try the file _pdf.ini in the Windows printers directory. Sorry I couldn't be more help, I'm sitting in front of a 98 machine, and don't have access to a NT or 2000 machine to test it out.
 
It's a bit hidden on NT4
I found it in c:\winnt\system32\spool\drivers\w32x86\2
I don't know if it is always in that folder though Peter Meachem
peter@accuflight.com
 
I couldn't find neither the pdfwrit.ini or _pdf.ini files, in fact I didn't find any *pdf*.ini. I've read somewhere that we should set a registry value with the output file name, does anybody know the key path?
 
A good news :
At the internet address
partners.adobe.com/asn/developer/acrosdk/docs/PDF_Creation_APIs/ PDFWriterAPIReference.pdf
we find the Api Reference of PDFWriter with all the informations about the key name forPDFWriter.

A bad one :
It doesn't work in my program written C#
in a Win 2000 PC !.

Hi !
 
Well I don't know much about C, but I've had some problems with getting VB to work consistently with the .ini file as well. The only other way I've had success with doing it is to print the file through distiller, and then open the created .pdf file, save it to a location that I want, and then delete the original .pdf and the .log file. (you can do this all through code, but it takes a lot longer to process.)
I also read about doing it through the registry, but they are talking about the Acrobat registry, which is controlled by that .ini file.
The only thing further I can recommend for you Win2k guys is to either view or download the Acrobat SDK and look under the PDFWriter API reference for information. It never mentions Win2k specifically, but it does have some information on NT.
 
Ok, finally hunted down a Win2k machine with Adobe Acrobat 5. It isn't in an .ini file at all. It is in the Windows Registry under H_Key_Current_User\Software\Adobe\Acrobat PDFWriter add a string value called &quot;PDFFileName&quot; and assign the full path and filename that you want as the value. The string value goes away after it prints, so you will have to recreate it everytime.
 
I tried to create the value but I always get a &quot;permission denied&quot; message, should a create the value before send to the printer or after? Because after I send something to the printer it prompts the dialog box.
I also tried to use the distiller printer but it creates a value under the key &quot;HKEY_CURRENT_USER\Software\ADOBE\Acrobat Distiller\PrinterJobControl&quot; but the value doesn't have a fixed name, it is different for each job.
 
I have all the rights, I already used the network manager login...
And it's strange because I can edit the registry using the regedit.
 
Unfortunately, I don't have much experience poking around in the Window's registry through code. Try doing it manually, going through Regedit, adding the string and the value, then printing something to the PDFWriter, see if that works, if it does, then you know that you are on the right tract at least. Wish I could be more help on this.
 
This is a question to NebA: Can you please post a sample of the code you used to print the file through distiller, and then open the created .pdf file, save it to a location that I want, and then delete the original .pdf and the .log file.
Thank you
 
Yes I can. This is some code that was used to print an excel sheet through distiller.

The first thing you need to do is to go into your control panel, and setup where the default path for distiller to &quot;dump&quot; it's files is located. When I was testing this method, I set it up as c:\windows\desktop\ so I could see everything easier.

Dim XlsPath As String
Dim XlsTest As Excel.Workbook
Dim XlsOutPath As String
Dim XlsPdfPath As String
Dim XlsLogPath As String
Dim Xls2Pdf As CAcroPDDoc 'variable type for pdf files
Dim SavePath As String


XlsPath = &quot;c:\my documents\test.xls&quot;
Set XlsTest = Excel.Application.Workbooks.Open(XlsPath)

XlsTest.Parent.ActivePrinter = &quot;Acrobat Distiller&quot;
XlsTest.ActiveSheet.PrintOut
XlsOutPath = &quot;c:\windows\desktop\test&quot;

DoEvents 'This is because it will sometimes start processing the next part while the Distiller is still creating the pdf, causing an error

XlsPdfPath = XlsOutPath & &quot;.pdf&quot;
xlslotpath = XlsOutPath & &quot;.log&quot;
Set Xls2Pdf = CreateObject(&quot;AcroExch.PDDoc&quot;)
Ok1 = Xls2Pdf.Open(XlsPdfPath)
SavePath = &quot;Whatever you want it to be&quot;
Ok2 = Xls2Pdf.Save(SavePath)
Ok3 = Xls2Pdf.Close

DoEvents

Kill XlsPdfPath
Kill XlsLogPath

 
Incidentally, if anyone's looking through this thread, the &quot;PDFFileName =&quot; key can also be inserted into the win.ini file, under &quot;[PDFWriter]&quot; (you can add this if you don't have it. The confusion over ini files versus registry entries is because both are correct -- the PDF Writer will look at either or both places depending on OS. Also, it's worthwhile to know that the PDF Writer may eventually be phased out, so it's probably worth spending the time to learn the Distiller API.
 
NebA thank you very much.
I've tried to apply this example to my case: I need to print an Access report into .pdf from within the Access DB and did not succeed. Have you ever done it from Access? If yes, please post the code sample.

Thank you

20132
 
I got it to work in the same way as the Excel method. The only difference was setting the name of the pdf file to open to be the same as the name of the report, and not the name of the database. I have always had problems running reports from Access through code, (docmd doesn't always work) so bear with me if I completely missed the mark on that.
 
Here is some code I use to print with Distiller. It passes the file name to from the spread sheet. works for me... What I really need is code to use writer from Power Point... Any help there from anyone ????

Sub SetupAndPrint()
Application.ScreenUpdating = False
Location = Sheets(&quot;Song Charts&quot;).Range(&quot;O45&quot;).Value
Sheets(Array(&quot;Song Charts&quot;, &quot;Pareto Summary&quot;, &quot;Activity Acceptance&quot;, _
&quot;6 Mo. Acceptance&quot;, &quot;12 Mo. Acceptance&quot;, &quot;Supplier Activity and 6 Mo. QR&quot;)). _
Select
If Dir$(Location & &quot;.pdf&quot;) <> &quot;&quot; Then
'erase previously created file names
Kill (Location & &quot;.pdf&quot;)
End If
Application.SendKeys (&quot;X:\pqa\1PQA_mSong_Website\Link_Metrics_Song\PerfSum_Charts\QualityChart\q_defects_dppm_song&quot; & &quot;.pdf~&quot;)
ActiveWindow.SelectedSheets.PrintOut ActivePrinter:=&quot;Acrobat Distiller&quot;

Application.ScreenUpdating = True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top