To create PDF files, I am using the
PDFSharp
Library, the output which I get varies in position of the rectangle when compared to the output when I draw manually on the page.
Below is the sample code.
I have tried drawing the rectangle at (0,0), in this case, both the outputs are the same. But when I am drawing at specific given location, the output varies.
Please help!
What I have tried:
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Public Class Form1
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawRectangle(Pens.Black, 567, 280, 86, 17)
End Sub
Private Sub PrintDocument1_PrintPagex(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim doc As New PdfDocument
Dim page As PdfPage = doc.AddPage
Dim gfx As XGraphics = XGraphics.FromPdfPage(page, XGraphicsUnit.Point)
gfx.DrawRectangle(XPens.Black, 567, 280, 86, 17)
Dim filename As String = "D:\Hello.pdf"
doc.Save(filename)
End Sub
End Class