GibboK
GibboK

Reputation: 73998

How to print without showing the Printing Dialogue?

I have this demo app, I need to print FlowDocument without pop-up the Printing Dialogue from the operational system. Do you have any idea how to do it? Or you know other possible posolution?

private void Button_Click(object sender, RoutedEventArgs e)
{
    PrintDialog pd = new PrintDialog();
    pd.ShowDialog();
    if (pd.ShowDialog() != true) return;

    flowDocument.PageHeight = pd.PrintableAreaHeight;
    flowDocument.PageWidth = pd.PrintableAreaWidth;

    IDocumentPaginatorSource idocument = flowDocument as IDocumentPaginatorSource;

    pd.PrintDocument(idocument.DocumentPaginator, "Printing Flow Document...");
}

Upvotes: 0

Views: 2638

Answers (1)

dovid
dovid

Reputation: 6491

delete this lines:

pd.ShowDialog();
if (pd.ShowDialog() != true) return;

Upvotes: 4

Related Questions