MS
This commit is contained in:
31
app/DD_PM_WINDREAM/ClassAnnotation.vb
Normal file
31
app/DD_PM_WINDREAM/ClassAnnotation.vb
Normal file
@@ -0,0 +1,31 @@
|
||||
Imports PdfSharp.Pdf
|
||||
Imports PdfSharp.Pdf.Annotations
|
||||
Imports PdfSharp.Pdf.IO
|
||||
Imports PdfSharp.Drawing
|
||||
Public Class ClassAnnotation
|
||||
Public Shared Function Annotate_PDF(title As String, content As String, page As Integer, Optional ycorrect As Integer = 0, Optional sizecorrect As Integer = 0)
|
||||
Try
|
||||
Dim doc As PdfDocument = PdfReader.Open(CURRENT_DOC_PATH, PdfDocumentOpenMode.Modify)
|
||||
Dim firstPage As PdfPage = doc.Pages(page)
|
||||
|
||||
Dim gfx As XGraphics = XGraphics.FromPdfPage(firstPage)
|
||||
Dim rect As XRect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(30, 60 + ycorrect), New XSize(60 + sizecorrect, 40 + sizecorrect)))
|
||||
|
||||
Dim annot As PdfTextAnnotation = New PdfTextAnnotation
|
||||
|
||||
annot.Title = title
|
||||
'annot.Subject = txtsubject.Text
|
||||
annot.Contents = content
|
||||
annot.Rectangle = New PdfRectangle(rect)
|
||||
|
||||
|
||||
firstPage.Annotations.Add(annot)
|
||||
doc.Save(CURRENT_DOC_PATH)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Unexpected error in Annotate pdf: " & ex.Message, False)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user