Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Programming to "Print" using CUTE PDF!

280 views
Skip to first unread message

John Baker

unread,
Apr 29, 2004, 5:02:15 PM4/29/04
to
HI;

I feel like a fool..I put CUTE FTP in my last request for help --it should have been CUTE
PDF! I have FTP on my mind because I have been working on a web based application, and
somehow my brain got stuck on it..sorry!

Hi:

I need some help writing code that will "print" a report using Cute PDF.

Specifically, I need to set up a "Button" which, when clicked, will:


a. Create an PDF "Print" file of the report using Cute PDF. The file needs to be given a
unique name based on data that will be in the report and on the query that generates the
report.

b. Store the result in a predefined folder..

I really would appreciate some pointers as to how to do this using MS Access 2000. The
application will be running on W98, 2000 and WXP!

Thanks in advance for any help you can give me.

Regards

John Baker


Albert D. Kallal

unread,
Apr 29, 2004, 6:39:17 PM4/29/04
to
That pdf creator does not supprot automation..and thus you can't set the
file name as far as I know...

--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
pleasenono...@msn.com
http://www.attcanada.net/~kallal.msn


John Baker

unread,
Apr 29, 2004, 7:52:21 PM4/29/04
to
Thanks for that info.

Do you know if any of the other PDF writers support automation? If so which one? I gather
some version of Adobe does, but am uncertain how this works or which version.

Any follow up info you could provide would be appreciated. If I have to buy a PDF writer I
certainly want to support automation with it.

Best Regards

John Baker

Tony Toews

unread,
Apr 29, 2004, 10:18:58 PM4/29/04
to
John Baker <Bake...@Verizon.net> wrote:

>Do you know if any of the other PDF writers support automation? If so which one? I gather
>some version of Adobe does, but am uncertain how this works or which version.

There's a list of such Creating PDF files from within Microsoft Access
http://www.granite.ab.ca/access/pdffiles.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm

Steve Jorgensen

unread,
Apr 29, 2004, 11:33:03 PM4/29/04
to
Cool - I didn't know about the new GPL PDF Creator. I've used
RedMon/Ghostscript successfully, but it does take some time to set up
properly.

TR

unread,
Apr 30, 2004, 9:11:44 AM4/30/04
to
FinePrint's PDFFactory can be printed to prgammatially from Access. Not really via automation,
but you can use VBA to set registry values to provide filenames/locations and print 'silently'
without user intervention. Works very well.
www.fineprint.com

John Baker

unread,
Apr 30, 2004, 9:33:26 AM4/30/04
to
TR:

Thanks for that info.

Have you used PDFFactory that way? Are there detailed code instructions as to how to set
it up? I'm not highly skilled in VBA, and need a "cook book" to do things like that.
PDFFactory appears to be the least expensive solution that is capable of being controlled
through Access ($109.95), but I want to be certain I can set it up properly before I
invest in it.

Regards

John Baker

John Baker

unread,
Apr 30, 2004, 9:34:29 AM4/30/04
to
Thanks Tony, a very useful site. However some of the downloads don't appear to work, which
is a snag.

Best

John

TR

unread,
Apr 30, 2004, 11:32:43 AM4/30/04
to
There is some information here:
http://www.fineprint.com/developers/index.html

Basically you are just setting registry values, and then your report can be preset to print to
PDFFactory (the basic version is only 49.95?)
Here is a function that I have used. I edited out some stuff specific to my use, and it calls some
registry functions from the Access Developers Handbook that I have not included(but you could
substitute any similar functions, there are many examples available on the net). Hopefully you can
get an idea of whats involved from this.

Private Function PrintToPDF()
'Purpose : uses a recordset to print individual reports to pdf files
'Comments : requires Fineprint PDF printer,
' and a report with Fineprint PDF printer set,
' selected items are written out to the selected items table
' a recordset is used to group the selected item on the appropriate field
' so that a seperate report can be printed.
'Parameters:
'Sets :
'Returns :
'Created by:
'Created : 03/25/2002 4:05:12 PM
'Modified : 03/25/2002 4:05:12 PM

On Error GoTo PrintToPDF_ERR

Dim dbs As Database
Dim rstFaxList As Recordset
Dim strSQL As String
Dim tblPickedItems As String
Dim strScheduleTable As String
Dim intFaxCount As Integer
Dim intFaxDone As Integer
Dim lngRetVal As adhRegErrors
Dim strRegValue As Variant
Dim strCurrentPDFOutput As String
Dim varCurrentPDFShowDlg As Variant
Dim strUserPDFOutput As String
Dim strDefOutputFile As String
Dim strNewOutputFile As String

'save users current default pdf output path
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strRegValue, Len(strRegValue))
If lngRetVal = adhcAccErrSuccess Then
strCurrentPDFOutput = strRegValue
Else
'no defined output, assume no pdf factory installed
MsgBox "You do not have PDF Factory installed, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If

'save users current default pdf output view
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", strRegValue, Len(strRegValue))
If lngRetVal = adhcAccErrSuccess Then
varCurrentPDFShowDlg = Asc(Mid(strRegValue, 1, 1))
Else
'no defined output, assume no pdf factory installed
MsgBox "You do not have PDF Factory installed, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If

'set output path for pdf files
strUserPDFOutput = GetPathPart_TSB(CStr(CurrentDb.Name)) & "PDF_" & CurrentUser() & "_" &
Format(Now(), "yyyymmdd_hhnnss")
MkDir strUserPDFOutput
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strUserPDFOutput, adhcREG_SZ)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set required parameters, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If

'set dialog mode to silent
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", 4, adhcREG_DWORD)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set required parameters, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If

'get recordset of sites to print
Set dbs = CurrentDb()
strSQL = "SELECT DISTINCT siteno From tblSites "
Set rstFaxList = dbs.OpenRecordset(strSQL, dbOpenSnapshot, dbReadOnly)
If Not rstFaxList.EOF And Not rstFaxList.BOF Then
rstFaxList.MoveLast
rstFaxList.MoveFirst
intFaxCount = rstFaxList.RecordCount
End If
intFaxDone = 0
' for each siteno in recordset
Do Until rstFaxList.EOF
'set output filename via pdfFacory key
'the key is erased by pdfFactory after file is created
'print report for siteno
strNewOutputFile = strUserPDFOutput & "\Site_Scheduler_Report(Site " & rstFaxList!siteno &
").PDF"
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"OutputFile", strNewOutputFile, adhcREG_SZ)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set output file (" & strNewOutputFile & "), cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
DoCmd.OpenReport "rptScheduler_PDF", acViewNormal, , "siteno = '" & rstFaxList!siteno & "'"

DoEvents
'there is some time lag between printing, and erasing the ouput file key
'loop here until outputfile key no longer found
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adhcAccErrSuccess
Do Until lngRetVal <> adhcAccErrSuccess
DoEvents
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"OutputFile", strRegValue, Len(strRegValue))
Loop
'next site
intFaxDone = intFaxDone + 1
rstFaxList.MoveNext
Loop
'restore user's pdf settings for default output path and show dialog
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strCurrentPDFOutput, adhcREG_SZ)
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", varCurrentPDFShowDlg, adhcREG_DWORD)

PrintToPDF_EXIT:
On Error Resume Next
If Not (rstFaxList Is Nothing) Then rstFaxList.Close: Set rstFaxList = Nothing
If Not (dbs Is Nothing) Then Set dbs = Nothing
Exit Function

PrintToPDF_ERR:
Select Case Err
Case 0 'insert Errors you wish to ignore here
Resume Next
Case Else 'All other errors will trap
Msgbox "Error: " & Err & ", " & Error,vbExclamation,"Error in PrintToPDF"
Resume PrintToPDF_EXIT
End Select
End Function

TR

unread,
Apr 30, 2004, 11:34:02 AM4/30/04
to
Also, I believe you can download a trial version and try this out as well.

John Winterbottom

unread,
Apr 30, 2004, 11:44:36 AM4/30/04
to
"John Baker" <Bake...@Verizon.net> wrote in message
news:de5390h3k2ipa7e8o...@4ax.com...

> Thanks for that info.
>
> Do you know if any of the other PDF writers support automation? If so
which one? I gather
> some version of Adobe does, but am uncertain how this works or which
version.
>
> Any follow up info you could provide would be appreciated. If I have to
buy a PDF writer I
> certainly want to support automation with it.
>


pdf995 stores output file name and folder info in an .ini file. All you need
to do is edit the .ini file in code. It's simple and very inexpensive..


John Winterbottom

unread,
Apr 30, 2004, 11:47:27 AM4/30/04
to
"John Winterbottom" <assa...@hotmail.com> wrote in message
news:c6ts95$g62ac$1...@ID-185006.news.uni-berlin.de...


http://www.pdf995.com


Steve Jorgensen

unread,
Apr 30, 2004, 11:55:31 AM4/30/04
to
On Fri, 30 Apr 2004 11:47:27 -0400, "John Winterbottom" <assa...@hotmail.com>
wrote:

One of my clients has used pdf995 from Access this way and had good things to
say about it.

John Winterbottom

unread,
Apr 30, 2004, 12:23:01 PM4/30/04
to
"Steve Jorgensen" <nos...@nospam.nospam> wrote in message
news:t0u4901pjevr6s53h...@4ax.com...


I think it's a good solution. It's certainly the most cost-effective one
that I've found. Quality is acceptable. The only problem I've found is when
running under terminal services; there is only one .ini file - you can't
specify a different .ini file for each user, even if you have multiple
licenses. So you have to make sure only one person is generating pdf's at
any one time or else there can be a clash.


Steve

unread,
May 1, 2004, 4:47:56 PM5/1/04
to
On Thu, 29 Apr 2004 23:52:21 GMT, John Baker <Bake...@Verizon.net>
wrote:

>Do you know if any of the other PDF writers support automation? If so which one? I gather
>some version of Adobe does, but am uncertain how this works or which version.

I use WIn2PDF and automate the generation of PDFs from both Access and
Excel, including assiging the file name, using Registry entries.
However, it does require Windows XP, NT, or 2000.

See


http://www.daneprairie.com/products/win2pdf.htm


Steven Zuch
Cogent Management Inc.


John Baker

unread,
May 2, 2004, 6:53:30 AM5/2/04
to
Thansk to you all.

This sounds like a great solution.

Could someone give me a sample of the code that i would uise to edit the .ini file? I have
never done much in Code in Access, concentarting mosty on macros.

Thanks a lot

John

Sean O

unread,
May 2, 2004, 2:15:55 PM5/2/04
to
I have downloaded the Win2PDF. It installed easily and the simple
commands work fine.

For example:
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", PathName

works just fine, but the commands that set the registry items are not
working. I pasted their code in, but when I call the routines:

SaveWin2PDFDword "file options", 0x02

It either does not work at all or says it's the wrong type. How do
you get the hex to work?

Their samples are VB, is that the problem? It would be great if
someone had some sample code similar to that which the earlier poster
put up for pdfFactory.

Thanks,

Tony

st...@nospam.com (Steve) wrote in message news:<40940ad0...@news.westnet.com>...

SA

unread,
May 19, 2004, 10:32:48 AM5/19/04
to
John:

Our PDF and Mail Library for Access may be an option. It supports
outputting PDF files using any of the following drivers:

Adobe drivers (versions 3-6)
Win2PDF
pdfFactory
PDF 995
PDF 4 U
Amyuni PDF Converter

Certainly one could spend hours getting the programming right with any
particular driver, our library provides a quick, in-expensive solution to
"automate" output with any of those drivers, including securing files (PDF
Pro Plus edition), merging files, adding book marks etc. Code is as simple
as:

Const PDFENGINE_ADOBE_PDF = 2

Dim objPDF as New PDFClass
With objPDF
.ReportName = "Your Report"
.ReportWhere = "Some SQL Filter"
.PDFEngine = PDFENGINE_ADOBE_PDF
.OutputFile = "c:\some dir\some file.pdf"
.PrintImage
Debug.print .Result
End With

You'll find the library on our web site in the developer tools area.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

"John Baker" <Bake...@Verizon.net> wrote in message
news:de5390h3k2ipa7e8o...@4ax.com...

0 new messages