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

spacings on the sides of the page
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1838
Page 1 of 1

Author:  tulips [ Tue Nov 08, 2011 2:06 pm ]
Post subject:  spacings on the sides of the page

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

Author:  Thomas Hoevel [ Tue Nov 08, 2011 3:17 pm ]
Post subject:  Re: spacings on the sides of the page

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

Author:  tulips [ Tue Nov 08, 2011 3:39 pm ]
Post subject:  Re: spacings on the sides of the page

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

Author:  Thomas Hoevel [ Tue Nov 08, 2011 4:06 pm ]
Post subject:  Re: spacings on the sides of the page

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.

Author:  tulips [ Wed Nov 09, 2011 9:28 am ]
Post subject:  Re: spacings on the sides of the page

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

Author:  Thomas Hoevel [ Wed Nov 09, 2011 10:30 am ]
Post subject:  Re: spacings on the sides of the page

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").

Author:  tulips [ Wed Nov 09, 2011 10:34 am ]
Post subject:  Re: spacings on the sides of the page

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

Author:  Thomas Hoevel [ Wed Nov 09, 2011 2:02 pm ]
Post subject:  Re: spacings on the sides of the page

It should work with
Code:
pdfRenderer.PdfDocument.Save(stream, false);

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