I use Ghostscript/Bullzip to merge multiple reports (up to 43) into a single pdf output file.
The basis of my code is the Access example on the bioPDF website. I've modified it a bit. (Since I set this up a few/couple of years ago, they have added the option to "AppendIfExists", eliminating the need for my code to set the MergeFile. I haven't extensively tested my new code on the append/merge process yet.)
Everything works fine, except the color: my reports appear on-screen with color shading, but come out in grayscale in the pdfs. I've been searching on the web for the solution. What I've found says to add ".SetValue "icc", "yes"" to get color, but it isn't working for me. The bioPDF documentation doesn't mention the "icc" setting.
I've checked the printer settings on the computer and switched it to "color" from "Black and White", but that didn't do it. Maybe it is some other hardware setting that isn't part of the code?
Does anyone have any suggestions for where I can find the answer or know how to solve this problem? I don't know where else to look.
Many thanks!
-Dudley
The basis of my code is the Access example on the bioPDF website. I've modified it a bit. (Since I set this up a few/couple of years ago, they have added the option to "AppendIfExists", eliminating the need for my code to set the MergeFile. I haven't extensively tested my new code on the append/merge process yet.)
Everything works fine, except the color: my reports appear on-screen with color shading, but come out in grayscale in the pdfs. I've been searching on the web for the solution. What I've found says to add ".SetValue "icc", "yes"" to get color, but it isn't working for me. The bioPDF documentation doesn't mention the "icc" setting.
I've checked the printer settings on the computer and switched it to "color" from "Black and White", but that didn't do it. Maybe it is some other hardware setting that isn't part of the code?
Does anyone have any suggestions for where I can find the answer or know how to solve this problem? I don't know where else to look.
Many thanks!
-Dudley
Code:
Public Function PrintReportAsPDF(RPTName As String, ShowPDF As String, Merge As String, Optional Filename As String)
Dim iPdfPrinterIndex As Integer
Dim sCurrentPrinterName As String
Dim iCurrentPrinterIndex As Integer
Dim i As Integer
Dim sCurrentDir As String
Dim oPrinterSettings As Object
Dim oPrinterUtil As Object
Dim sPrinterName As String
DoEvents
Rem -- Create the objects to control the printer settings.
Rem -- Replace biopdf with bullzip if you have the bullzip printer installed instead
Rem -- of the biopdf printer.
Set oPrinterSettings = CreateObject("bullzip.PdfSettings")
Set oPrinterUtil = CreateObject("bullzip.PdfUtil")
Rem -- Get default printer name
sPrinterName = oPrinterUtil.DefaultPrintername
oPrinterSettings.Printername = sPrinterName
Rem -- Get the directory of the database
' sCurrentDir = GetDatabaseFolder
Rem -- Find the index of the printer that we want to use
iPdfPrinterIndex = -1
iCurrentPrinterIndex = -1
sCurrentPrinterName = Application.Printer.DeviceName
For i = 0 To Application.Printers.Count - 1
If Application.Printers.Item(i).DeviceName = sPrinterName Then
iPdfPrinterIndex = i
End If
If Application.Printers.Item(i).DeviceName = sCurrentPrinterName Then
iCurrentPrinterIndex = i
End If
Next
Rem -- Exit here if the pdf printer was not found
If iPdfPrinterIndex = -1 Then
MsgBox "The printer '" & sPrinterName & "' was not found on this computer."
Exit Function
End If
Rem -- Exit here if the current printer was not found
If iCurrentPrinterIndex = -1 Then
MsgBox "The current printer '" & sCurrentPrinterName & "' was not found on this computer." & _
" Without this printer the code will not be able to restore the original printer selection."
Exit Function
End If
Rem -- Set the printer
Application.Printer = Application.Printers(iPdfPrinterIndex)
Rem -- Configure the PDF printer
With oPrinterSettings
Rem -- Set the destination file name of the PDF document
' .SetValue "output", GetDatabaseFolder & "\out\example.pdf"
'(HM) Make LSP_Reports directory if it doesn't exist
If Dir(GetMyDocumentsDirectory & "\LSP_Reports", vbDirectory) = "" Then
MkDir GetMyDocumentsDirectory & "\LSP_Reports"
End If
Rem -- (HM) Set the destination file name of the PDF document
If IsNull(Filename) Or Len(Filename) = 0 Then
.SetValue "output", "<personal>\LSP_Reports\" & "LSP_Report_" & "<date>" & ".pdf"
' .SetValue "MergeFile", "<personal>\LSP_Reports\" & "LSP_Report_" & "<date>" & ".pdf"
Else
.SetValue "output", "<personal>\LSP_Reports\" & Filename & "_" & "<date>" & ".pdf"
' .SetValue "MergeFile", "<personal>\LSP_Reports\" & Filename & "_" & "<date>" & ".pdf"
End If
' .SetValue "MergePosition", "bottom"
.SetValue "AppendIfExists", "yes"
Rem -- Control the dialogs when printing
.SetValue "ConfirmOverwrite", "no"
.SetValue "ShowSaveAS", "never"
.SetValue "ShowSettings", "never"
.SetValue "ShowPDF", "yes"
Rem -- Set document properties
.SetValue "Target", "printer"
.SetValue "Title", "LSP PDF Report"
.SetValue "Subject", "Report generated at " & Now
Rem -- Display page thumbs when the document is opened
.SetValue "UseThumbs", "no"
Rem -- Set the zoom factor to 50% (HM-"fitall")
' .SetValue "Zoom", "50"
.SetValue "Zoom", "fitall"
Rem -- (HM) Set to print in color (I hope)
.SetValue "icc", "yes"
Rem -- Place a stamp in the lower right corner
' .SetValue "WatermarkText", "ACCESS DEMO"
' .SetValue "WatermarkVerticalPosition", "bottom"
' .SetValue "WatermarkHorizontalPosition", "right"
' .SetValue "WatermarkVerticalAdjustment", "3"
' .SetValue "WatermarkHorizontalAdjustment", "1"
' .SetValue "WatermarkRotation", "90"
' .SetValue "WatermarkColor", "#ff0000"
' .SetValue "WatermarkOutlineWidth", "1"
Rem -- Write the settings to the runonce.ini file
.WriteSettings True
End With
Rem -- Run the report
DoCmd.OpenReport RPTName
'Make sure BullZip is finished before moving on - runonce.ini is deleted
Do While Dir(Environ("APPDATA") & "\Bullzip\PDF Printer\runonce@Bullzip PDF Printer.ini") <> ""
' c = c + 1
' Sleep 200
Loop
End Function