TaskFlow/app/DD_PM_WINDREAM/frmAnnotations.vb
Digital Data - Marlon Schreiber 6be485d4b5 MS - Anpassung Detailview für JJ
2018-02-06 12:29:21 +01:00

33 lines
1.0 KiB
VB.net

Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.Annotations
Imports PdfSharp.Pdf.IO
Imports PdfSharp.Drawing
Public Class frmAnnotations
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim doc As PdfDocument = PdfReader.Open(CURRENT_DOC_PATH, PdfDocumentOpenMode.Modify)
Dim firstPage As PdfPage = doc.Pages(txtSeitenzahl.Text)
Dim gfx As XGraphics = XGraphics.FromPdfPage(firstPage)
Dim rect As XRect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(30, 60), New XSize(30, 30)))
Dim annot As PdfTextAnnotation = New PdfTextAnnotation
annot.Title = txttitle.Text
'annot.Subject = txtsubject.Text
annot.Contents = txtcontent.Text
annot.Rectangle = New PdfRectangle(rect)
firstPage.Annotations.Add(annot)
doc.Save(CURRENT_DOC_PATH)
Me.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class