Hi,
I wouldnt recommend doing mock-ups in PdfSharp as using something like MS Word or even Excel will be much much quicker - like you use Photoshop becuase its all GUI based, rather than code based for webpages, but yes you're right about XRect's, though you will basically need to follow this process to add an xrect:
- create a PdfDocument object
- add a PdfPage pbject to the PdfDocument
- get an XGraphics object from the pdfPage (XGraphics.FromPdfPage(yourPageInstance);) - i figured it would be yourPageInstance.GetGraphics() at first....
- create new XRect and pass in the x/y/width/height
- call yourXGraphicsInstance.DrawRect(yourXRectInstance);
note that XGraphics objects are page specific - i tend to keep a List<XGraphics> somewhere global so i can get access at any point in my code to draw on any page (and i believe you can only call XGraphics.FromPdfPage(yourPageInstance); on a page once, hence why its useful to keep the reference somewhere global...
Re: the page padding, look at the samples provided with PdfSharp for MigraDoc, i use this:
Code:
Document.DefaultPageSetup.TopMargin = TopMargin = Unit.FromCentimeter(3);
which can be applied to all margins like this:
Code:
Document.DefaultPageSetup.TopMargin = Document.DefaultPageSetup.BottomMargin = = Document.DefaultPageSetup.LeftMargin = Document.DefaultPageSetup.RightMargin = Unit.FromCentimeter(3);
Where Document is an instance of a MigraDoc.DocumentObjectModel.Document Object...
PdfSharp tends to be much lower level, kind of like formatting a <p> tag within the tag instead of using CSS:
Code:
<p font="arial">sometext</p> as opposed to <p style="yourArialStyleWhichCanAccomplishMuchMore">sometext</p>
I tend to use PdfSharp for drawing graphics (and labels on those graphics) and MigraDoc for the higher level things like tables/parahgraphs etc.
Hope this helps,
Mike