Code so Bullzip will print reports in color (1 Viewer)

Dudley

Registered User.
Local time
Yesterday, 20:23
Joined
Apr 7, 2004
Messages
147
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

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
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 04:23
Joined
Jul 9, 2003
Messages
16,373
Hi Dudley, I was going to suggest is that you see if you could set some other values of the printer to see what happens. However it looks like your code already sets several other values, I assume successfully, so this approach would probably not be worth exploring.
 

BitFarmer

New member
Local time
Today, 05:23
Joined
Dec 4, 2013
Messages
1
Same problem here, and finally found an explanation!

First, it happens the same with PDFCreator, and both printers share GhostScript, so it is a GhostScript problem.

The fact is that, if you change some printer in your sistem from color to B&W, from this point on, GhostScript will produce B&W PDFs regardless of the color status of the PDF printer you are using!

Try finding a printer on your sistem with B&W activated, change it back to color, then try againg creating a PDF: it sohuld have color again.

I think GhostScript is not really attached to the PDF printer, and chyanging ANY printer to B&W makes GhostScript to mimic, but I am not sure.

Note: I tried to register on bullzip to comment on this, but registration on the forum is CLOSED due to spamming!!!!! What a forum is for in this case?
 

Users who are viewing this thread

Top Bottom