Problem with image of the cyrillics in PdfSharp.Pdf.Annotations.PdfTextAnnotation:
Code:
Public Sub nPDF()
pdfDIMA = New PdfDocument 'создание документа
Dim pdfPage As PdfPage = pdfDIMA.AddPage 'добавляем страницу
Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage) 'создаем объект Графич sFont
Dim codFont As XPdfFontOptions = New XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Default)
Dim fontD As XFont = New XFont("Verdana", 20, XFontStyle.Bold, codFont) 'создаем шрифт
'Dim fontD As XFont = New XFont(sFont, 20, XFontStyle.Bold, codFont) 'создаем шрифт
'Dim theColor As Color = Color.Black ' Color.Purple
Dim mP1 As Point = New Point(10, 10)
Dim mP2 As Point = New Point(300, 20)
Dim regEg As XRect = New XRect(mP1.X, mP1.Y, mP2.X - mP1.X, mP2.Y - mP1.Y)
Dim instF As New XStringFormat
instF.Alignment = XStringAlignment.Near
instF.LineAlignment = XLineAlignment.Center 'StringAlignment.Center
Dim sSize As XSize
'Dim sSTRI As String = "Кирилица Latinica 12345"
graph.DrawString("Кирилица Latinica 12345", fontD, XBrushes.Black, regEg, instF)
sSize = graph.MeasureString("Кирилица Latinica 12345", fontD)
'пробуем с аннотациями проблема с кирилицей
Dim textAnnot As Annotations.PdfTextAnnotation = New Annotations.PdfTextAnnotation
Dim rect As XRect
'textAnnot = New PdfSharp.Pdf.Annotations.PdfTextAnnotation
textAnnot.Title = "Кирилица Latinica 12345"
textAnnot.Subject = "Кирилица Latinica 12345"
textAnnot.Contents = "Кирилица Latinica 12345"
textAnnot.Icon = PdfSharp.Pdf.Annotations.PdfTextAnnotationIcon.Comment '.Note
rect = graph.Transformer.WorldToDefaultPage(New XRect(sSize.Width + 20, 10, 20, 20))
textAnnot.Rectangle = New PdfRectangle(rect)
graph.PdfPage.Annotations.Add(textAnnot)
pdfDIMA.Save("D:\file.pdf")
pdfDIMA.Dispose()
ShellExecute(0, "open", "D:\file.pdf", "", "", SW_SHOWMAXIMIZED)
End Sub
This possible somehow solve )))
Attachment:
pdf_font.JPG [ 29.54 KiB | Viewed 4740 times ]