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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:36:07+00:00 2026-06-08T02:36:07+00:00

I’m trying to print a WPF FlowDocument. The layout needs to be in the

  • 0

I’m trying to print a WPF FlowDocument. The layout needs to be in the form of 4 documents per page, laid out as follows:

 Doc1 | Doc2
-------------
 Doc3 | Doc4

(Sorry, I couldn’t come up with a better way of illustrating the layout).

The page needs to fill, so if Doc1 & 2 are blank or just one or two characters, it still needs to print them the same size as Doc3 & 4.

The code I’m using is as follows (sorry it’s long, I’ve tried to abridge where feasible):

PrintDialog printDialog = new PrintDialog();
if ((bool)printDialog.ShowDialog().GetValueOrDefault())
{
    FlowDocument flowDocument = new FlowDocument();
    flowDocument.PageHeight = printDialog.PrintableAreaHeight;
    flowDocument.PageWidth = printDialog.PrintableAreaWidth;
    flowDocument.PagePadding = new Thickness(25);

    flowDocument.ColumnGap = 0;

    flowDocument.ColumnWidth = (flowDocument.PageWidth -
                                   flowDocument.ColumnGap -
                                   flowDocument.PagePadding.Left -
                                   flowDocument.PagePadding.Right);


    Table myTable = new Table();
    myTable.BorderThickness = new Thickness(3);

    AddCols(myTable);         // Add 2 cols

    TableRowGroup rg = new TableRowGroup();
    TableRow row = new TableRow();

    AddRows(myTable);         // Adds 2 rows

    TableCell cell = new TableCell(new Paragraph(new Run("Doc1")));                
    cell.BorderThickness = new Thickness(1);
    cell.BorderBrush = Brushes.Black;          
    // Repeat 4 times      

    row.Cells.Add(cell);

    myTable.RowGroups.Add(rg);

    doc.Blocks.Add(myTable);

    ....

The problem that I have is that although this does print, it doesn’t try to fit it to the page as described above. Is what I am attempting possible and if so, how?

EDIT:

From looking here I believe what I actually need is a way to calculate the height of the paragraph, so that I can set the Padding property. Unfortunately the solution proposed in this link doesn’t work!

  • 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-08T02:36:09+00:00Added an answer on June 8, 2026 at 2:36 am

    Try placing the entire block in a grid so as to give it the uniform layout and then place the grid in the block and block inside your single table cell. See if this works for you –

    Grid grid = new Grid();
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
    
            Label text1 = new Label();
            text1.Content = "Doc1";
            grid.Children.Add(text1);
            Grid.SetColumn(text1, 0);
            Grid.SetRow(text1, 0);
    
            Label text2 = new Label();
            text1.Content = "Doc2";
            grid.Children.Add(text2);
            Grid.SetColumn(text2, 1);
            Grid.SetRow(text2, 0);
    
            Label text3 = new Label();
            text1.Content = "Doc3";
            grid.Children.Add(text3);
            Grid.SetColumn(text3, 0);
            Grid.SetRow(text3, 1);
    
            Label text4 = new Label();
            text1.Content = "Doc4";
            grid.Children.Add(text4);
            Grid.SetColumn(text4, 1);
            Grid.SetRow(text4, 1);
    
            BlockUIContainer block = new BlockUIContainer(grid);
    
            Table table = new Table();
            TableRowGroup rg = new TableRowGroup();
            TableCell cell = new TableCell();
            cell.Blocks.Add(block);
            TableRow row = new TableRow();
            row.Cells.Add(cell);
            rg.Rows.Add(row);
            table.RowGroups.Add(rg);
            doc.Blocks.Add(table);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.