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 7778671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:27:22+00:00 2026-06-01T18:27:22+00:00

I want to create a document with several pages and with one wpf window

  • 0

I want to create a document with several pages and with one wpf window depicted on each page.

I managed to print one window using PrintDialog and PrintVisual. However this seem to only work with one single page? Any ideas how I can build a document with several pages and print the complete set.

Can I insert that visual (referred in code) and insert it as a page in a document and print it after that?

Is approach really bad? Is there som other way to solve this problem?

      Sub Print (Dim ele As FrameWorkElement)
            Dim margin As Double = 30
            Dim titlePadding As Double = 10

            Dim printDlg As PrintDialog = New PrintDialog()
            printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape
            If (printDlg.ShowDialog() <> True) Then Return

            Dim formattedText As FormattedText = New FormattedText(Name, CultureInfo.GetCultureInfo("en-us"),
                                                            FlowDirection.LeftToRight, New Typeface("Verdana"), 25, Brushes.Black)

            formattedText.MaxTextWidth = printDlg.PrintableAreaWidth

            Dim scale As Double = Math.Min(printDlg.PrintableAreaWidth / (ele.ActualWidth + (Margin * 2)),
                                    (printDlg.PrintableAreaHeight - (formattedText.Height + titlePadding)) / (ele.ActualHeight + (Margin * 2)))

            Dim visual As DrawingVisual = New DrawingVisual()
            Using context As DrawingContext = visual.RenderOpen()

                Dim brush As VisualBrush = New VisualBrush(ele)
                context.DrawRectangle(brush, Nothing, New Rect(New Point(margin, margin + formattedText.Height + titlePadding),
                                                            New Size(ele.ActualWidth, ele.ActualHeight)))

                context.DrawText(formattedText, New Point(margin, margin))
            End Using
            visual.Transform = New ScaleTransform(scale, scale)
            printDlg.PrintVisual(visual, "")
     End Sub
  • 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-06-01T18:27:23+00:00Added an answer on June 1, 2026 at 6:27 pm

    You want to create a FixedDocument with multiple FixedPages.

    Example:

    How to create a new document and single page.

    var pageSize = new Size(8.26 * 96, 11.69 * 96); // A4 page, at 96 dpi
    var document = new FixedDocument();
    document.DocumentPaginator.PageSize = pageSize;
    
    // Create FixedPage
    var fixedPage = new FixedPage();
    fixedPage.Width = pageSize.Width;
    fixedPage.Height = pageSize.Height;
    // Add visual, measure/arrange page.
    fixedPage.Children.Add((UIElement)visual);
    fixedPage.Measure(pageSize);
    fixedPage.Arrange(new Rect(new Point(), pageSize));
    fixedPage.UpdateLayout();
    
    // Add page to document
    var pageContent = new PageContent();
    ((IAddChild)pageContent).AddChild(fixedPage);
    document.Pages.Add(pageContent);
    
    // Send to the printer.
    var pd = new PrintDialog();
    pd.PrintDocument(document.DocumentPaginator, "My Document");
    

    Written in C#, however you should be able to convert to VB.

    HTH,

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

Sidebar

Related Questions

I'd like to create a Word document using Python, however, I want to re-use
I want to create a small document management system. There are several users who
I want to create dynamic PDF document pages as per my record. Please help
We want to create a common document library on a certain site level and
i want to create a new '.b' div appendTo document.body, and it can dragable
I want to create a Google Docs document from within Haskell, so basically I
I have a document and want to create it as a twocolumn-document. That works
I have the following problem: Within a stylesheet document I want to create an
I want to read, write and create Spreadsheets in the Open Document Format with
I want to create a Document Package bundle so I added appropriate information to

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.