PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 16, 2024 8:25 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Nov 08, 2011 2:06 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Hello,

I am new here and this is my first time using pdfsharp and I like it. I have a question about pdfsharp.

How can I define to leave some side margins in all my pdfpages?

Is it in pdfdocument property? I looked at so many properties but cannot figure it out.

Thanks so much!

-tulips


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 08, 2011 3:17 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

Not my area of expertise.
I presume you can use a transformation to set top and left borders. Then your code still must respect usable width and height.

With MigraDoc you can set page borders (using the PageSetup property of the Section). With MigraDoc you simple add text to your document and MigraDoc will handle page breaks and borders for you.

See also:
http://www.pdfsharp.net/wiki/MigraDocSamples.ashx

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 08, 2011 3:39 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thank you! I am just starting with this project and have a long way to go and all pages are dynamic with header and footer being static mostly. So do you recommend I move to Migradoc for my pdf file? Does Migradoc have graphics object that I can use to create some shapes and color it and create bullet points? I would take your advice now than later when I won't have the choice to switch. Thanks again.

-tulips


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 08, 2011 4:06 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
You can use bullet lists with MigraDoc.
I don't know which shapes you need. This could be a problem; no problem to draw images or PDF pages, so if you can provide your "shapes" as PNG, JPEG, or PDF, there won't be a problem.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 09, 2011 9:28 am 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thanks for your reply.

I need to create a graph so I draw rectangles and lines of different colors and thickness. Can I make one page in pdfsharp and put it in Migradoc? That would be perfect and then I can start doing the whole document in Migradoc and then just insert one page from pdfsharp. Is it possible?

Thanks again.

-tulips


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 09, 2011 10:30 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
MigraDoc supports some types of graphs.
But you can also use PDFsharp to create PDF pages (e.g. with reduced page size) that you include like images in MigraDoc.

To me this seems a good way: create the graphs with PDFsharp, create the final document with MigraDoc and include the graphs like images.
You can have several images in one PDF file - append the page number to the filename using hash signs (e.g. "myfile.pdf#7").

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 09, 2011 10:34 am 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thank you so much! I will go the way you suggested. Now, to start on Migradoc I need little help with websample. I cannot find any for Migradoc but there is one for pdfSharp which I used and it worked great! Can you tell me how I can use to send migradoc pdf file to browser?

I changed the line 22 to pdfRenderer.PdfDocument.Save(stream); but it is throwing error that stream is closed. Please help me get started with web Migradoc!

/ Send PDF to browser
21.MemoryStream stream = new MemoryStream();
22.document.Save(stream, false);
23.Response.Clear();
24.Response.ContentType = "application/pdf";
25.Response.AddHeader("content-length", stream.Length.ToString());
26.Response.BinaryWrite(stream.ToArray());
27.Response.Flush();
28.stream.Close();
29.Response.End();

-tulips


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 09, 2011 2:02 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
It should work with
Code:
pdfRenderer.PdfDocument.Save(stream, false);

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 34 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