| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Adding Borders with Crop Marks https://forum.pdfsharp.net/viewtopic.php?f=2&t=2574 |
Page 1 of 1 |
| Author: | jhutchings5 [ Tue Sep 17, 2013 8:23 pm ] |
| Post subject: | Adding Borders with Crop Marks |
I am having some trouble and can't seem to find out a way to do this... Is there a way to add borders with crop marks to an existing PDF? I am trying to take an existing PDF 8.5x11 and add .25 inch border around the whole document with crop marks for printing. |
|
| Author: | Thomas Hoevel [ Wed Sep 18, 2013 9:24 am ] |
| Post subject: | Re: Adding Borders with Crop Marks |
Not my area of expertise. You can create a new, larger page with PDFsharp, draw the crop marks as lines and draw the page from the existing PDF also. There may be better ways, but this way it will work. See samples like Combine Documents, Concatenate Documents, or Two Pages on One: http://www.pdfsharp.net/wiki/PDFsharpSamples.ashx |
|
| Author: | jhutchings5 [ Wed Sep 18, 2013 12:45 pm ] |
| Post subject: | Re: Adding Borders with Crop Marks |
Code: Dim filename As String = txtUploadPath.Text ' Create the output document Dim outputDocument As New PdfDocument() outputDocument.PageLayout = PdfPageLayout.SinglePage Dim gfx As XGraphics ' Open the external document as XPdfForm object Dim form As XPdfForm = XPdfForm.FromFile(filename) ' Determine width and height Dim extWidth As Double = form.PixelWidth Dim extHeight As Double = form.PixelHeight Dim page As PdfPage = outputDocument.AddPage() 'page.Orientation = PageOrientation.Landscape page.Width = (XUnit.FromInch(0.5).Point + extWidth) page.Height = (XUnit.FromInch(0.5).Point + extHeight) Dim width As Double = page.Width Dim height As Double = page.Height gfx = XGraphics.FromPdfPage(page) ' Skip if left side has to remain blank Dim box As XRect box = New XRect(0, 0, extWidth, extHeight) ' Draw the page identified by the page number like an image gfx.DrawImage(form, box) ' Save the document... filename = "Border.pdf" outputDocument.Save(filename) ' ...and start a viewer. Process.Start(filename) txtUploadPath.Text = "File uploaded" Here is what I have... now the issue that I am running into is that the PDF image that is drawn in is left/top justified. Is there a way to center the image? I tried Code: gfx.DrawImage(form, box.center) However this will start the image at the center. Do you know if there is a way to to manually adjust the starting point? I want to start the image top/left - 0.25 inch
|
|
| Author: | jhutchings5 [ Wed Sep 18, 2013 1:10 pm ] |
| Post subject: | Re: Adding Borders with Crop Marks |
I was able to figure it out. Code: box = New XRect(XUnit.FromInch(0.25).Point, XUnit.FromInch(0.25).Point, extWidth, extHeight) gfx.DrawImage(form, box) I didn't realize that you could set a starting point when you define the box size. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|