Force SectionReport to print in black and white

Posted by: jyoder on 10 January 2018, 6:55 pm EST

    • Post Options:
    • Link

    Posted 10 January 2018, 6:55 pm EST

    Is this even possible? Given a section report…

    Dim oSectionReport As GrapeCity.ActiveReports.SectionReport

    … that’s been setup correctly in memory (yet may have color images) is there any way to tell it to only print in black and white when you actually print it, regardless of the printer you send it to?

  • Posted 11 January 2018, 1:42 am EST

    Hello,

    In order to achieve your requirement, you need to use the following lines of code:

    
    Dim rpt As GrapeCity.ActiveReports.SectionReport = New GrapeCity.ActiveReports.SectionReport()
        Dim xtr As System.Xml.XmlTextReader = New System.Xml.XmlTextReader(Application.StartupPath & "\..\..\SectionReport1.rpx")
        rpt.LoadLayout(xtr)
        rpt.Document.Printer.DefaultPageSettings.Color = False
        rpt.Run()
        rpt.Document.Print(False, False)
    
    

    Hope it helps.

    Thanks,

    Mohit

  • Posted 11 January 2018, 11:04 am EST

    Thanks, but it doesn’t work. We have code in our report that prints a value in red if it’s negative…

    if (txtBalance.Value != System.DBNull.Value) {

    if (System.Convert.ToDouble((txtBalance).Value) < 0)

    { txtBalance.ForeColor = System.Drawing.Color.Red; }

    else { txtBalance.ForeColor = System.Drawing.Color.FromArgb(-16777216); }

    }

    But when I add the code above you gave me, in an attempt to overwrite it, the value still prints in red when it’s negative. As another test, I added a color image to a report and printed it with the code you gave me, but it still prints the image in color rather than black and white.

    Is this a bug?

  • Posted 12 January 2018, 2:43 am EST

    Hello,

    I am unable to replicate the issue on my end using the above code with AR11(11.2.10750) and AR12(11.0.11689.0). Section report is printed in “Black and White”. Also, on analysing I found that “DefaultPageSettings.Color” property change the ‘ColorMode’ field in “Printing Preferences” of the printer. Please refer the attached images. I am using the “Canon iR-ADV C2220/2230 UFR II” network printer at my end.

    Could you please confirm the following thing:

    1: User has sufficient permission to change the printer properties.

    2: The Exact version of AR that you are using.

    3: Please check the “DefaultPageSettings.Color” property will change the ‘ColorMode’ field(depending on the printer) in “Printing Preferences” of the printer.

    4: How are you giving print from your application?

    Thanks,

    Mohit

    prj_ColorPrint.zip

  • Posted 16 January 2018, 4:37 pm EST

    Thanks so much for the example to help determine what’s going on. In running your program, you say it worked for you, but it’s not working for me. To answer your questions…

    1. I must have permissions, since I can manually go into “Devices and Printers” and set my printer to B&W or color without problems – it retains the color value after I close it.

    2. My version is slightly older, but I doubt it makes a difference: 11.0.9313.0 (I changed your attached program to that version.)

    3. When running your program, I’ve attached an image to show it doesn’t change the default color on my printer.

    Is it possible certain printers work with this code but others won’t? Any chance you can try your code with the printer I’m using, which, as the image shows, is a “Kyocera TASKalfa 250ci KX”?

  • Posted 17 January 2018, 3:25 am EST

    Hello,

    It is not possible for us to check with the same printer. Also, issue is not replicate on my end even with 11.0.9313.0 build. Could you please try after using the following line of code:

    
    Dim rpt As GrapeCity.ActiveReports.SectionReport = New GrapeCity.ActiveReports.SectionReport()
            Dim xtr As System.Xml.XmlTextReader = New System.Xml.XmlTextReader(Application.StartupPath + "\..\..\SectionReport1.rpx")
            rpt.LoadLayout(xtr)
            rpt.Document.Printer.DefaultPageSettings.Color = False
            rpt.Document.Printer.PrinterSettings.DefaultPageSettings.Color = False
            rpt.Run()
            rpt.Document.Print()
    
    

    We are assuming that you are simply printing section report on your local machine.

    Please, confirm if the assumption is correct.

    Thanks,

    Mohit

  • Posted 18 January 2018, 12:30 pm EST

    The extra line made no difference.

    I’m running the code on my local machine, and printing to a network printer.

  • Posted 19 January 2018, 7:25 am EST

    Hello,

    I am able to replicate the issue on my end after installing “Kyocera TASKalfa 250ci KX” driver. On analysing, I found that same behaviour is shown by the PrintDocument of Microsoft. Hence, it is printer specific issue. However, I have escalated this to our developer team(Tracking ID 253223) and will revert once we got any information from them.

    Thanks,

    Mohit

  • Posted 19 January 2018, 7:52 am EST

    Hello,

    Sorry to mention that it is an external issue.Hence, it is not possible to fix the issue at our end. I recommend you to forward your issue with PrintDocument sample to the manufacturer of the printer driver.

    Also, if “Kyocera TASKalfa 250ci KX” printer supports Escape commands(page eject code for certain printer (see manual for printer’s sequences)) for Color property then you could try the following method:

    http://help.grapecity.com/activereports/webhelp/AR12/webframe.html#GrapeCity.ActiveReports.v12~GrapeCity.ActiveReports.SystemPrinter~Escape.html

    Hope it helps.

    Thanks,

    Mohit

  • Posted 23 January 2018, 11:08 am EST

    Thanks for the replies. Appreciate you trying and looking into it.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels