I cannot pass pdf/a validator:https://www.pdf-online.com/osa/validate.aspx
With this works passes the online validator:
Code:
gfx.DrawString("ššš", font, New XSolidBrush(XColor.FromArgb(0, 0, 0)), New XRect(50, 100, 500, 30), XStringFormats.TopLeft)
But this doesnt:
Code:
gfx.DrawString("šššččč", font, New XSolidBrush(XColor.FromArgb(0, 0, 0)), New XRect(50, 100, 500, 30), XStringFormats.TopLeft)
I tried different fonts, I tried using I custom font resolver, no luck. Please help kind people. And thank You for pdfSharp.
Here is my complete code:
Code:
Sub vera()
Dim Document As New PdfDocument()
Dim font As XFont = New XFont("Arial", 12, XFontStyleEx.Regular, New XPdfFontOptions(PdfFontEmbedding.EmbedCompleteFontFile))
Document.Info.Title = "PDF/A Minimal Test"
Document.Info.Author = "Tester"
Document.Info.Subject = "PDF/A-1b Compliance"
Document.Info.Creator = "PDFSharp VB.NET"
Document.Version = 14 ' PDF 1.5 for PDF/A-2
Document.SetPdfA()
Dim iccPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sRGB_IEC61966-2-1_black_scaled.icc")
If Not File.Exists(iccPath) Then
Throw New FileNotFoundException("ICC profile missing: " & iccPath)
End If
Dim iccBytes = File.ReadAllBytes(iccPath)
Dim iccProfileStream As New PdfDictionary(Document)
iccProfileStream.Elements.SetInteger("/N", 3)
iccProfileStream.CreateStream(iccBytes)
Document.Internals.AddObject(iccProfileStream)
Dim iccRef As PdfReference = Document.Internals.GetReference(iccProfileStream)
Dim UAManager As UAManager = UAManager.ForDocument(Document)
Dim PdfPage As PdfPage = Document.AddPage()
Dim gfx As XGraphics = XGraphics.FromPdfPage(PdfPage)
Dim sb As StructureBuilder = UAManager.StructureBuilder
sb.BeginElement(PdfGroupingElementTag.Article)
sb.BeginElement(PdfBlockLevelElementTag.Paragraph)
gfx.DrawString("ššš", font, New XSolidBrush(XColor.FromArgb(0, 0, 0)), New XRect(50, 100, 500, 30), XStringFormats.TopLeft)
gfx.DrawLine(New XPen(XColor.FromArgb(0, 0, 0)), 0, PdfPage.Height / 2, PdfPage.Width, PdfPage.Height / 2)
gfx.DrawLine(New XPen(XColor.FromArgb(0, 0, 0)), 0, PdfPage.Height / 4, PdfPage.Width, PdfPage.Height / 4)
gfx.DrawLine(New XPen(XColor.FromArgb(0, 0, 0)), 0, PdfPage.Height / 6, PdfPage.Width, PdfPage.Height / 6)
sb.End()
sb.End()
Dim pdfFont As XPdfFontOptions = font.PdfOptions
Console.WriteLine("Font embedded: " & pdfFont.FontEmbedding.ToString())
Console.WriteLine("Font embedded: " & pdfFont.FontEmbedding.EmbedCompleteFontFile.ToString)
Dim filename = "test.pdf"
Document.Save(filename)
End Sub
PS: now I discovered that pdfsharp already add XMP, well even if I let that part out, still cannot get it to pass the test with