PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 18, 2024 1:36 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jan 28, 2015 10:40 pm 
Offline

Joined: Wed Jan 28, 2015 10:18 pm
Posts: 3
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?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 29, 2015 8:45 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 29, 2015 1:15 pm 
Offline

Joined: Wed Jan 28, 2015 10:18 pm
Posts: 3
How do I do that?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 29, 2015 2:08 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 29, 2015 9:04 pm 
Offline

Joined: Wed Jan 28, 2015 10:18 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 30, 2015 3:22 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 343
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.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 35 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group