Ticket Q139325
Visible to All Users

Preset PrinterSettings

created 16 years ago

Hi,
i need to preset printer-settings in my application (printername, landscape, color, count and maybe more)
I use the printDialog, the pageSetupDialog (printDocument) to collect the values.
Finaly i set the printingSystem1 and the richTextBoxLink1 to initialize.
It work ́s but i have now a problem with the color-printing. How can i activate the color-printing in the printingSystem?
I tried to set the DefaultPageSettings bevor calling printingSystem1.PrintDlg().
     if (printDocument1.PrinterSettings.IsValid)
          if (printDocument1.PrinterSettings.SupportsColor) {
               printDocument1.DefaultPageSettings.Color = true;
               pageSetupDialog1.PageSettings.Color = true;
          }
Image1 shows the success of setting the values. Image2 shows that printingSystem1 (PrintDlg) ignore these values (there is also no color on the paper ;-)) - it does ́n work!
It seams that all presetings where cleared - why ?
And what can i do to get my color without user-interaction?

Show previous comments (1)

    I am not using the common Windows dialogs (and also the PrintDocument) for printing. I use it only to get the presettings for the printer.
    For printing i use the PrintingSystem from DevExP (for printing DevExpress.XtraGrid.GridControl and RTF-Text)
         richTextBoxLink1.RichTextBox.Rtf = rtfText;
         richTextBoxLink1.CustomPaperSize = new System.Drawing.Size(0, 0);
         richTextBoxLink1.Landscape = true;
         richTextBoxLink1.PaperKind = System.Drawing.Printing.PaperKind.A4;
         richTextBoxLink1.PrintingSystem = this.printingSystem1;
         richTextBoxLink1.VerticalContentSplitting = DevExpress.XtraPrinting.VerticalContentSplitting.Smart;
         richTextBoxLink1.PrintingSystem = this.printingSystem1;
         printingSystem1.PageSettings.PaperKind = paperkind;
         printingSystem1.PageSettings.Landscape = landscape;
         richTextBoxLink1.CreateDocument();
         printingSystem1.Print();
         or
         printableComponentLink1.Component = this.objGrid;
            printableComponentLink1.CustomPaperSize = new System.Drawing.Size(0, 0);
         printableComponentLink1.Landscape = true;
         printableComponentLink1.PaperKind = System.Drawing.Printing.PaperKind.A4;
         printableComponentLink1.PrintingSystem = this.printingSystem1;
         printableComponentLink1.VerticalContentSplitting = DevExpress.XtraPrinting.VerticalContentSplitting.Smart;

    printableComponentLink1.PrintingSystem = this.printingSystem1;
         printingSystem1.PageSettings.PaperKind = paperkind;
         printingSystem1.PageSettings.Landscape = landscape;
         printableComponentLink1.CreateDocument();
         printingSystem1.Print();
    My problem ist that i can not set the values oft the "printingSystem1.PrintDlg()".
    Your solution shows me that ́s posible to set these values, but i have no idea how i can do this with the PrintingSystem.
    Can you give me an example with the PrintingSystem ?
    Thanks.

    DevExpress Support Team 16 years ago

      Hello Thomas,
      You might need to subscribe to the PrintingSystem.StartPrint event prior to calling the PrintDlg() method.
      Refer to this sample code snippet:

      C#
      richTextBoxLink1.RichTextBox.Rtf = rtfText; richTextBoxLink1.CustomPaperSize = new System.Drawing.Size(0, 0); richTextBoxLink1.Landscape = true; richTextBoxLink1.PaperKind = System.Drawing.Printing.PaperKind.A4; richTextBoxLink1.PrintingSystem = this.printingSystem1; this.printingSystem1.StartPrint += new DevExpress.XtraPrinting.PrintDocumentEventHandler(PrintingSystem_StartPrint); .. void PrintingSystem_StartPrint(object sender, DevExpress.XtraPrinting.PrintDocumentEventArgs e) { if (e.PrintDocument.PrinterSettings.SupportsColor) e.PrintDocument.DefaultPageSettings.Color = true; }

      Let me know whether this helps.
      Thank you,
      Alex.

        Hello Alex,
        That ́s it - it work ́s !
        Thanks for all (great, fast support)!
        Thomas

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.