Hello. I have just discovered PDAsharp and MigraDoc - splendid work. I succesfully created some tests document, but faced a problem using Greek characters in the table of contents (whereas in the main document area, the same characters are displayed with no problem).
Take a look at the attached picture, which displays Adobe reader showing the document created by MigraDoc. As you can see, in the main document area, there are two tables and each has a caption written in proper greek letters. However, the same captions are displayed as junk letters in the bookmark list at the left.
The doc I used to create this document came from the samples and is the following:
Code:
Dim doc As Document = CreateDoc("Στατιστικά βάσης δεδομένων", "Στατιστικά στοιχεία για τη βάση δεδομένων")
DefineStyles(doc)
Dim paragraph As Paragraph = doc.LastSection.AddParagraph("Γενικά στοιχεία", "Heading2")
Dim tbl As Table = CreateTable(2)
AddRow(tbl, "Διακομιστής βάσης δεδομένων", db.ServerName).Cells(0).Shading.Color = Colors.PaleGoldenrod
AddRow(tbl, "Βάση δεδομένων", db.ServerDB).Cells(0).Shading.Color = Colors.PaleGoldenrod
doc.LastSection.Add(tbl)
doc.LastSection.AddParagraph("Πίνακες", "Heading2")
tbl = CreateTable(2, "Πίνακας", "Εγγραφές")
AddRow(tbl, "idioktites", db.GetInteger("select count(*) from idioktites")).Cells(0).Shading.Color = Colors.PaleGreen
AddRow(tbl, "oikopeda", db.GetInteger("select count(*) from oikopeda")).Cells(0).Shading.Color = Colors.PaleGoldenrod
AddRow(tbl, "merides", db.GetInteger("select count(*) from merides")).Cells(0).Shading.Color = Colors.PaleGoldenrod
doc.LastSection.Add(tbl)
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(doc, "MigraDoc.mdddl")
Dim render As New PdfDocumentRenderer(True, PdfSharp.Pdf.PdfFontEmbedding.Always)
render.Document = doc
render.RenderDocument()
Dim filename As String = System.IO.Path.Combine(FileOperations.GetMyDocumentsFolder, "DbStats.pdf")
render.PdfDocument.Save(filename)
Process.Start(filename)
So, I guess that the problem lies in the lines:
Dim paragraph As Paragraph = doc.LastSection.AddParagraph("Γενικά στοιχεία", "Heading2")
and
Dim paragraph As Paragraph = doc.LastSection.AddParagraph("Γενικά στοιχεία", "Heading2")
The first parameter of AddParagraph is displayed correctly in the document area, but wrongly in the bookmarks list.
Thanks for reading this.