PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Broken unicode support in bookmarks?
https://forum.pdfsharp.net/viewtopic.php?f=3&t=1452
Page 1 of 1

Author:  spyros1973 [ Wed Dec 01, 2010 5:17 pm ]
Post subject:  Broken unicode support in bookmarks?

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.

Attachments:
migra.jpg
migra.jpg [ 33.4 KiB | Viewed 17985 times ]

Author:  Thomas Hoevel [ Thu Dec 02, 2010 9:10 am ]
Post subject:  Re: Broken unicode support in bookmarks?

Hi!

You can try the patch posted here:
viewtopic.php?f=2&t=1309

Author:  spyros1973 [ Thu Dec 02, 2010 2:28 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

Thanks! This works perfectly.

Author:  viljemt [ Wed Nov 12, 2014 1:15 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

Hi!

patch is working great for German, Russian...languages.

I any possibility to modify it for Slovenian, Croatian, Polish... languages?

With regards, Viljem

Author:  Thomas Hoevel [ Wed Nov 12, 2014 1:26 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

Hi!
viljemt wrote:
patch is working great for German, Russian...languages.
I any possibility to modify it for Slovenian, Croatian, Polish... languages?
How can it be that it works for Russian, but not for Polish?

Author:  viljemt [ Wed Nov 12, 2014 1:34 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

Hi!

if I would only know. In attachment.
Attachment:
Test-RUS-POL.png
Test-RUS-POL.png [ 22.52 KiB | Viewed 16152 times ]

Author:  Thomas Hoevel [ Wed Nov 12, 2014 1:45 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

It works for me:
Attachment:
forum_14-11-12.png
forum_14-11-12.png [ 28.51 KiB | Viewed 16149 times ]

How urgent is it?
The version supposed to be released later this year seems to work fine.

Author:  viljemt [ Wed Nov 12, 2014 1:52 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

Wow great!

It is urgent. If it is possible...can I beta test it?

Author:  maloi_alex [ Sat Nov 15, 2014 7:34 am ]
Post subject:  Re: Broken unicode support in bookmarks?

viljemt wrote:
Hi!
if I would only know. In attachment.


Hi. I corrected this issue. Try to use the files in the attachment.

Attachments:
fixed_files.zip [9.9 KiB]
Downloaded 649 times

Author:  viljemt [ Mon Nov 17, 2014 2:42 pm ]
Post subject:  Re: Broken unicode support in bookmarks?

maloi_alex wrote:
Hi. I corrected this issue. Try to use the files in the attachment.


wow, this works great!! Thank you!


p.s.: in Lexer.cs there is double '((' and '))'.
Attachment:
2014-11-17_15-38_PdfSharp modified_files.jpg
2014-11-17_15-38_PdfSharp modified_files.jpg [ 92.23 KiB | Viewed 16096 times ]

Author:  maloi_alex [ Tue Nov 18, 2014 7:10 am ]
Post subject:  Re: Broken unicode support in bookmarks?

viljemt wrote:
p.s.: in Lexer.cs there is double '((' and '))'.


You're right. This code is dirty, because was written by me in the "flow of mind" mode.

Author:  viljemt [ Tue Nov 18, 2014 9:39 am ]
Post subject:  Re: Broken unicode support in bookmarks?

Hi!

I does not mater how it looks. Code works, that is important for me.

Thank you again!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/