np.
np.

Reputation: 2379

Print in c# with specific options

I am wondering if it is possible to print a few images with specific options in c#. We have bunch of images in our db. The options also will be coming from db. For ex: Option 1: FileName1, A3 Size, Landscape, Print Quality = Best, Pages persheet = 1, 600 DPI, whole page. Will appreciate any input. Thanks, N

Upvotes: 1

Views: 2450

Answers (1)

Ray Burns
Ray Burns

Reputation: 62909

Yes. Use PrintTicket, for example:

  PrintDialog printDialog = new PrintDialog();
  if(printDialog.ShowDialog()==true)
  {
    PrintTicket ticket = new PrintTicket();
    ticket.PageOrientation = MyDocument.PaperSize.PageOrientation;
    ticket.PageMediaSize = MyDocument.PaperSize.PageMediaSize;

    XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
    writer.WritingPrintTicketRequired += (s, printTicketEvent) => { printTicketEvent.CurrentPrintTicket = ticket; };
    MyDocument.PrintTo(writer);
  }

You can also set the PrintTicket more directly and not use the event, but I had some trouble with driver compatibility that caused me to do it this way instead.

Upvotes: 4

Related Questions