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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:05:15+00:00 2026-05-31T19:05:15+00:00

Here is my scenario: I have a document, currently a FlowDocument, that I would

  • 0

Here is my scenario:

I have a document, currently a FlowDocument, that I would like to print on two different page sizes. The first is standard letter 8.5 by 11; the other is a portable printer and is 5 by as-long-as-the-spool-of-paper. It prints fine on the 5x? but it prints out on two pages of 8.5×11. I want the 8.5×11 to have two columns so the first column flows into the second column not onto a second page. I do NOT want to scale the whole thing so that it prints in one skinny column on a single sheet of 8.5×11; that is unreadable. Some scaling to fit the page in two columns is OK though. It prints fine on both sizes of paper from Xamlpad, but not from my program. So, it must be possible, however, for the life of me, I cannot figure it out.

My printer class:

public void Print(MyViewModel Data) {
    IDocumentPaginator flowDoc = RenderFlowDocumentTemplate(pathToFlowDocument, data);
    PrintDocumentImageableArea area = null;
    XpsDocumentWriter xpsDocWriter = PrintQueue.CreateXpsDocumentWriter(ref area);

    if (xpsDocWriter != null) {
        PrintFlowDocument(xpsDocWriter, flowDoc.DocumentPaginator, area);
    }
}

private IDocumentPaginator RenderFlowDocumentTemplate(string path, MyViewModel Data) {
    string rawXamlText = "";
    using (StreamReader streamReader = File.OpenText(templatePath)) {
        rawXamlText = streamReader.ReadToEnd();
    }

    FlowDocument doc = XamlReader.Load(new XmlTextReader(new StringReader(rawXamlText)) as FlowDocument;

    if (data != null) {
        doc.DataContext = data;
    }

    return doc;
}

private void PrintFlowDocument(XpsDocumentWriter writer, DocumentPaginator document, PrintDocumentImageableArea area) {
    document.PageSize = new Size(area.ExtentWidth, area.ExtentHeight);
    PrintDocumentPaginator(writer, document);
}

private void PrintDocumentPaginator(XpsDocumentWriter xpsDocWriter, DocumentPaginator document) {
    try {
        xpsDocWriter.Write(document);
    }
    catch (PrintSystemException) {}
}

And here is a very trimmed down version of my FlowDocument:

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              Background="White"
              ColumnWidth="500">
    <FlowDocument.Resources>...some resources...</FlowDocument.Resources>
    <Paragraph />
    <BlockUIContainer>
        <Grid />
    </BlockUIContainer>
    .
    .
    .
    <Section />
</FlowDocument>

I have tried messing with column width, the document page size, scaling, adding wrap panels, adding stack panels, etc… and I cannot figure this out. It is driving me nuts!! Can anyone help?

P.S. any typos in the code are induced by me since I had to copy it by hand from my other PC.

  • 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-31T19:05:16+00:00Added an answer on May 31, 2026 at 7:05 pm

    So, after a lot more digging and playing around with values and adding the FlowDocument to various viewers, I noticed that a majority of the people asking questions about FlowDocument printing have the opposite problem I have. And their solution was to set the ColumnWidth.

    I simply removed

    ColumnWidth="500"
    

    from the FlowDocument and I now have the behavior I want. Prints in two columns on A4 and Prints in a single column the length it needs on the smaller spooled paper. And for clarity, I am also not setting the ColumnWidth anywhere in code.

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

Sidebar

Related Questions

Here's my scenario - I have an SSIS job that depends on another prior
Here's the scenario: You have a Windows server that users remotely connect to via
Here's the scenario: I have a textbox and a button on a web page.
Here's my scenario: I have a page containing several links; each link is meant
Here's the scenario: I have a set of buttons that I want to bind
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
Here's my scenario: I have a simple stored procedure that removes a specific set
I have following scenario: I have a XML-Document, e.g. like this <someRootElement> <tag1> <tag2
The Scenario I have a table on a web page that is dynamically generated
So here's the scenario I have a list that loads some HTML into a

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.