PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

My Data Table is too wide
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3042
Page 1 of 1

Author:  xlthim63 [ Wed Jan 28, 2015 10:40 pm ]
Post subject:  My Data Table is too wide

I have been Googling for two days, and I can't find anything addressing my problem.
I have a custom ASP.NET control that basically creates a table, and presents data on a web page. Works great for display.

Now I need to let the user download the data as a PDF.
First - I have a company banner I create in the ASP mark-up. How do I make this an image ( or whatever is best) to use as the header, or first element, or whatever is the best way to print it out?
Next - I have a class to convert form my custom table object to a MigraDoc table. It seems to be working with one problem...
I can only see about 3/4 of my table. It is too wide for the document. I read somewhere that MigaDoc would "wrap" a table to the next line if it is too wide, but it is not happening with mine.
The document shown seems to be in landscape mode for the widest presentation, but still not wide enough.

I thought I read somewhere that I could take an ASP control, make an image out of it, and then just add the image to the document, but I can't find that any more.

I've poked around in PDFsharp also and can't find anything obvious for what I am trying to accomplish.

How do I need to be going about doing this?

Author:  Thomas Hoevel [ Thu Jan 29, 2015 8:45 am ]
Post subject:  Re: My Data Table is too wide

Hi!
xlthim63 wrote:
I read somewhere that MigaDoc would "wrap" a table to the next line if it is too wide, but it is not happening with mine.
MigraDoc can't do that.
You can set the width of the page to any size you want or need. That's what we do: if DIN A4 landscape is not enough, then we increase the width to accommodate our table.

You can get the same effect by shrinking both column widths and font size.

Author:  xlthim63 [ Thu Jan 29, 2015 1:15 pm ]
Post subject:  Re: My Data Table is too wide

How do I do that?

Author:  Thomas Hoevel [ Thu Jan 29, 2015 2:08 pm ]
Post subject:  Re: My Data Table is too wide

The Section has a PageSetup. Set the PageWidth property of PageSetup to the width you need.
If you need different values for different tables, start a new section for the table.

Author:  xlthim63 [ Thu Jan 29, 2015 9:04 pm ]
Post subject:  Re: My Data Table is too wide

It still will not let me create a page wide enough for my table.

private static void FormatSection(Section section)
{
section.PageSetup.PageFormat = PageFormat.Ledger;
section.PageSetup.Orientation = Orientation.Landscape;
section.PageSetup.TopMargin = 0.25;
section.PageSetup.BottomMargin = 0.25;
section.PageSetup.LeftMargin = 0.25;
section.PageSetup.RightMargin = 0.25;
section.PageSetup.HeaderDistance = 1.0;
section.PageSetup.FooterDistance = 5.0;
section.PageSetup.PageHeight = ConvertInchesToUnits(8.5);
section.PageSetup.PageWidth = ConvertInchesToUnits(14.0);
}

I have played with all of these settings with various results.
I need a pdf that is 8.5" in height and 14" in width. The only time I ever got these dimensions to show up they were backwards (tall skinny pdf, showing half my table).

PageWidth and PageHeight are Units, right? So if I want 14 inches wide, I need to set PageWidth to 1008 (72 * 14 = 1008, assuming dpi of 72)?

Please show me an example somewhere of someone displaying and/or saving a pdf that is 8.5" tall and 14" wide.

Author:  () => true [ Fri Jan 30, 2015 3:22 pm ]
Post subject:  Re: My Data Table is too wide

Hi!

You can use "section.PageSetup.PageWidth = Unit.FromInch(14);" instead of your own code.
Or simply this:
section.PageSetup.PageWidth = "14in"; // "355.6mm" will work - I'm not sure whether "in" is the correct abbreviation.

Don't use "Orientation.Landscape;" if you set values like you do - with Landscape the Width value is used for the height and vice versa.
Set Height to 14" if you want to use Landscape.

You don't have to (and should not) set Landscape if you set Height to 8" and Width to 14". PageFormat will be ignored if you set both Width and Height.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/