Customizing PrintDialog RRS feed

  • Question

  • I am working to enable printing of multiple visual objects in an application. Is there anyway to customize the PrintDialog to provide additional options for a user?

    Examples of things I would like to offer from the screen include setting margins and allowing for handouts (Powerpoint style - 4 or 6 to a page type options), etc. Is there anyway for me to do this or do I need my own custom print settings dialog that I then use the results from to help arrange my output that I end up sending throught the PrintDialog?

    I appreciate any insight people may have who have done printing in their application.
    Thursday, October 25, 2007 5:52 PM

All replies

  • Hi



    Do u solve this solution.I am also having same question.Can u send me detail to nhsubash@hotmail.com

    Monday, February 4, 2008 7:06 AM
  • The print dialog is not a WPF control and therefore cannot be customized using the powerful WPF techniques (e.g. styles, templates, etc...).


    You will have to create your own dialog and call printdialog without showing the default dialog.





    Monday, February 4, 2008 12:57 PM
  • Thanks for your reply.Designing a custom form for Print Dialog then how add the functionality that normal print dialog works.Please let help on this regards.Do u have sample code.my email nhsubash@hotmail.com

    Monday, February 4, 2008 1:08 PM
  • I don't have sample code because for now I am using the default dialog, but I may need to write this code in the future.


    The basic approach is this:


    Create a modal dialog by adding a window and modifying xaml

    in the dialog you will need code like this:


    //create a printdialog object, but don't call the ShowDialog method

    PrintDialog dlg = new PrintDialog();

    //Get the printer capabilities

    PrintCapabilities printCapabilites = dlg.PrintQueue.GetPrintCapabilities();

    double leftMargin = printCapabilites.PageImageableArea.OriginWidth;

    //Get the print ticket:

    PrintTicket printTicket = dlg.PrintTicket;

    printTicket.OutputQuality = OutputQuality.High;

    // Determine point for centering visual on page.

    Point ptcvisual =

    new Point((paperWidth - cvisual.Width) / 2,

    (paperHeight - cvisual.Height) / 2);

    // Layout the visual.

    cvisual.Arrange(new Rect(ptcvisual, sizecvisual));

    //Print visual

    dlg.PrintVisual(cvisual, "Print title");




    Monday, February 4, 2008 1:22 PM
  • What is xaml?

    Can u explain it more detail.Bcoz am new dot net.

    Tuesday, February 5, 2008 5:34 AM
  • Kindly, I want to ask you if you know how to create your own print dialog, or if we can edit the control of PrintDialog.

    Thursday, February 7, 2008 9:25 AM

    Hi Aboud Karkar,


    Thanks.I want create my own print dialog .It should be same functionlity as standard print dialog.But some controls will added in my printdialog such drop down list





    Thursday, February 7, 2008 9:58 AM
  • No, you cannot edit the control of PrintDialog.  You need to create your own dialog and call methods from Printdialog (see above).


    XAML is a VERY important component of WPF, you should read up on it before writing any WPF code (although you can right WPF without using XAML directly).  XAML is the declarative language used by WPF to define the graphical aspects of the application.





    Thursday, February 7, 2008 2:31 PM
  • Indeed XAML is a very important component of WPF, I had learned XAML language, but I need a form or a control (if you have one) that gives the same services of PrintDialog
    Thursday, February 7, 2008 4:28 PM
  • Please note subash that replies go to the forums.

    It is incorrect to ask people to send you e-mail. The replies will come to the forum and will be then visible to all interested people.

    Please don't in future post your e-mail address as part of a message.
    Friday, September 19, 2008 7:00 PM