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