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
John Baker wrote:
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
TR <t_NoSpam_redick@Mind_NoSpam_spring.com> wrote:
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 wrote:
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
"Albert D. Kallal" <ka****@msn.com> wrote:
>That pdf creator does not supprot automation..and thus you can't set the
>file name as far as I know...