Highlighted
Absent Member.
Absent Member.
10781 views

[archive] Create PDF with File Name Specified

[Migrated content. Thread originally posted on 23 May 2006]

I am able to create a PDF file using "Adobe PDF" as a printer.
However, it automatically goes to the "Save As" dialog when the printer is opened. I want to assign my own file name each time I run the report, then create the PDF, and exit the program. I will then use a system call to view the pdf or attach it to an email it in outlook. I cannot use the temporary file method as I am using win$printer to add a logo and line drawing. I would rather not use active x to create the entire report as that would be too tedious.

Does anyone have a method to accomplish this task? If so, can you also share your code on how you bypass the dialog, and pass the file name. If I cannot bypass the view, I could live with that.

Thanks
Patty
0 Likes
53 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

I don't know this driver in particular, but chances are that this behavior is controlled by the OS. If so, you can easily circumvent this by opening the printer driver and check the port it is set to. If it is set to FILE:, that is the explanation for the dialog.

What you can do to avoid this is to change the port to a filename, for instance: c:\myoutput.pdf

Note however, if you do this, all print outs will go to this file, thus, you may overwrite stuff you want to have.

An alternative to this, is to use the configuration entry WIN-SPOOLER-PORT, if you set this one to the desired filename prior to executing the OPEN statement, a print that goes to the current Windows printer will have its content redirected to that file.

The content of this file will be as if the print were sent to the printer. With other words, you can use this with regular printer drivers as well. Assume you have a print using an HP printer, redirect this to a file with the WIN-SPOOLER-PORT entry into c:\mydump.bin.

You can then later copy that file to the printer (assuming it is on LPT1) by; COPY /B mydump.bin LPT1:

Of course, if you ftp this file to a unix box in binary mode, you can send this to a HP printer on the unix box as well.

The WIN-SPOOLER-PORT configuration entry is available for the Windows runtime as of version 6.2.0.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

It's probably not something you're interseted in, but we purchased a 3rd party solution that gives us this ability built-in (as well as some other capabilities). It works well for us.

http://cutepdf.com/solutions/pdfwriter.asp

Rob
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Rob,
Can you give me samples or snipets from your programs? I have downloaded cutepdf pro. I need to pass the file name and turn off the save as dialog box. Also want to turn off the auto view.

Thanks
Patty
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Patty - I replied to your query on your otyher thread.
Regards
Keith
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Patty,

Here is some sample code of what does this. Keith is correct - you have to purchase the custom version from them first in order to get programmatic access.

Rob

* create key
CALL "REG_CREATE_KEY_EX" USING HKEY_CURRENT_USER,
"Software\Printer Name, NULL, REG_OPTION_NON-VOLATILE,
KEY_ALL_ACCESS, MY-REG-KEY-HANDLE,
MY-DISP-FLAG GIVING MY-REG-STATUS.
* Bypass SaveAs Dialog
MOVE "1" TO MY-REG-FIELD.
INSPECT MY-REG-FIELD REPLACING TRAILING SPACES BY NULL.
CALL "REG_SET_VALUE_EX" USING MY-REG-KEY-HANDLE,
REG_SZ, MY-REG-FIELD, 2, "BypassSaveAs"
GIVING MY-REG-STATUS.
* Set file name
MOVE "filename.pdf" TO MY-REG-FIELD.
MOVE 12 to MY-REG-TALLY. |length of name
INSPECT MY-REG-FIELD REPLACING TRAILING SPACES BY NULL.
CALL "REG_SET_VALUE_EX" USING MY-REG-KEY-HANDLE,
REG_SZ, MY-REG-FIELD, MY-REG-TALLY, "OutputFile"
GIVING MY-REG-STATUS
* close key
CALL "REG_CLOSE_KEY" USING MY-REG-KEY-HANDLE
GIVING MY-REG-STATUS
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

THANKS for the code and information about the piece I was missing. Got the "custom version", used your code, and now I am up and running.

THANKS SO VERY MUCH.

Patty
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Patty,
I was searching for a pdf solution and came over your post. It is exactly what I need to do as well. I was just wondering since your post is over a year old, if you have any later comments, Has it worked well, do you have any warnings for me before I start my development. I will be making this part of my applications which I sell to third parties.
Mike Skeen
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Dear Forum mates:

Look for the "PDF995 - virtual printer" on the Web.
It's a free and great solution.
I've been used it and it works fine.
Give it a try.

CB52 from the Pampas.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

We went with cutepdf also and have had great success. You get to name the driver and install it at your clients as your own pdf printer. In your code you put the registry entries that specify the filename. Let me know if you need help. patty@icsnews.com
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

thanks for both replys,
to cb52, I have tried other free pdf creators, but none gave me the name to programatically set the file path and name which will change each time a report is printed. I love the "free" part, do you know if the 995 product gives you this capability.

Patty, I checked on cute pdf and the price is $499!! for the custom version with programatic options. Is that what you paid?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Create PDF with File Name Specified

Mike:

The answer is YES.

More than this, check it out at:
http://www.pdf995.com

CB52
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.