Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:19:54+00:00 2026-05-16T16:19:54+00:00

I am writing a note-taking application in WPF, using a FlowDocument for each individual

  • 0

I am writing a note-taking application in WPF, using a FlowDocument for each individual note. The app searches and filters notes by tags. I want to print all notes in the current filtered list as separate documents, and I only want to show a single Print Dialog at the beginning of the job.

I found a good print example in this thread, but it is geared toward printing a single FlowDocument, so it uses a CreateXpsDocumentWriter() overload that displays a Print Dialog.

So, here’s my question: Can anyone suggest some good code for printing a FlowDocument without displaying a PrintDialog? I figure I’ll display the Print Dialog at the beginning of the procedure and then loop through my notes collection to print each FlowDocument.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:19:54+00:00Added an answer on May 16, 2026 at 4:19 pm

    I have rewritten my answer to this question, because I did find a better way to print a set of FlowDocuments, while showing the Print Dialog only once. The answer comes from MacDonald, Pro WPF in C# 2008 (Apress 2008) in Chapter 20 at p. 704.

    My code bundles a set of Note objects into an IList called notesToPrint and gets the FlowDocument for each Note from a DocumentServices class in my app. It sets the FlowDocument boundaries to match the printer and sets a 1-inch margin. Then it prints the FlowDocument, using the document’s DocumentPaginator property. Here’s the code:

    // Show Print Dialog
    var printDialog = new PrintDialog();
    var userCanceled = (printDialog.ShowDialog() == false);
    if(userCanceled) return;
    
    // Print Notes
    foreach(var note in notesToPrint)
    {
        // Get next FlowDocument
        var collectionFolderPath = DataStore.CollectionFolderPath;
        var noteDocument = DocumentServices.GetFlowDocument(note, collectionFolderPath) ;
    
        // Set the FlowDocument boundaries to match the page
        noteDocument.PageHeight = printDialog.PrintableAreaHeight;
        noteDocument.PageWidth = printDialog.PrintableAreaWidth;
    
        // Set margin to 1 inch
        noteDocument.PagePadding = new Thickness(96);
    
        // Get the FlowDocument's DocumentPaginator
        var paginatorSource = (IDocumentPaginatorSource)noteDocument;
        var paginator = paginatorSource.DocumentPaginator;
    
        // Print the Document
        printDialog.PrintDocument(paginator, "FS NoteMaster Document");
    }
    

    This is a pretty simple approach, with one significant limitation: It doesn’t print asynchronously. To do that, you would have to perform this operation on a background thread, which is how I do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a little note pad app, where users can enter text notes,
Hello how can we do the note-taking application using natural handwriting in iPad like
Basically, I'm developing a note-taking app where the user can type as long as
I'm writing my first Java EE (EJB + Servlets etc.) application (please note: I'm
I'm writing an Android application that needs a menu like this: Please note, this
I feel like writing a (rich) text editor mainly to be used for note-taking,
I'm writing note software in PHP (to store notes) and most often I include
I am writing a simple keylogger program (for non-malicious purposes). Note: This is with
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing a python program, and I came up with this error while using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.