Hello,
After saving pdf with SetUnicode(), the body of resulting pdf is displayed properly with all unicode characters, but TOC and Bookmarks don't display some unicode characters.
Thank you.
Jozef.
Hello,
After saving pdf with SetUnicode(), the body of resulting pdf is displayed properly with all unicode characters, but TOC and Bookmarks don't display some unicode characters.
Thank you.
Jozef.
Hello Jozef,
Thanks for using our products.
I have tested the scenario using Aspose.Pdf for .NET 5.0.0 using the following code snippet and I am unable to notice any problem. The Unicode characters are properly being displayed in both TOC and Bookmark section. Can you please share the code snippet that you are using so that we can test the scenario at our end. We apologize for your inconvenience.
[C#]
// Instantiate an object PDF class
Pdf pdf = new Pdf();
pdf.IsBookmarked = true;
pdf.BookMarkLevel = 1;
//Create a list section
ListSection tocSection = new ListSection("Table Of Contents");
//Set its list type as table of of contents
tocSection.ListType = ListType.TableOfContents;
//Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection);
//Define the format of the four levels list by setting the left margins and
/text format settings of each level
tocSection.ListFormatArray.Length = 4;
tocSection.ListFormatArray[0].LeftMargin = 0;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
tocSection.ListFormatArray[1].LeftMargin = 10;
tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
tocSection.ListFormatArray[2].LeftMargin = 20;
tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[3].LeftMargin = 30;
tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;
//Create a section in the Pdf document
Section sec1 = pdf.Sections.Add();
//Add four headings in the section
for (int Level = 1; Level < 5; Level++)
{
Heading heading2 = new Heading(pdf, sec1, Level);
Segment segment2 = new Segment(heading2);
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
segment2.Content = "this is heading of level #$UNICODE(197) ";
segment2.Content += Level.ToString();
//Add the heading into Table Of Contents.
heading2.IsInList = true;
sec1.Paragraphs.Add(heading2);
}
// save the Pdf file
pdf.Save(@"d:\pdftest\UniCode_Test.pdf");
Hello,
thanks for the answer.
I'm using Slovak characters in pdf. All slovak characters are displayed properly in pdf except TOC and Bookmark. I have edited your code to vb.net. Changes are highlighted by yellow color.
Here is my code:
'Instantiate an object PDF class
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()
pdf.IsBookmarked = True
''pdf.BookMarkLevel = 1
'Create a list section
Dim tocSection As Aspose.Pdf.ListSection = New Aspose.Pdf.ListSection("Table Of Contents")
'Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.ListType.TableOfContents
'Add the list section to the sections collection of the Pdf document
pdf.Sections.Add(tocSection)
'Define the format of the four levels list by setting the left margins
'and
'text format settings of each level
tocSection.ListFormatArray.Length = 4
tocSection.ListFormatArray(0).LeftMargin = 0
tocSection.ListFormatArray(0).Margin.Right = 30
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(0).TextInfo.IsTrueTypeFontItalic = True
tocSection.ListFormatArray(1).LeftMargin = 10
tocSection.ListFormatArray(1).Margin.Right = 30
tocSection.ListFormatArray(1).TextInfo.IsUnderline = True
tocSection.ListFormatArray(1).TextInfo.FontSize = 10
tocSection.ListFormatArray(2).LeftMargin = 20
tocSection.ListFormatArray(2).Margin.Right = 30
tocSection.ListFormatArray(2).TextInfo.IsTrueTypeFontBold = True
tocSection.ListFormatArray(3).LeftMargin = 30
tocSection.ListFormatArray(3).Margin.Right = 30
tocSection.ListFormatArray(3).TextInfo.IsTrueTypeFontBold = True
'Create a section in the Pdf document
Dim sec1 As Aspose.Pdf.Section = pdf.Sections.Add()
'Add four headings in the section
For Level = 1 To 4
Dim heading2 As Aspose.Pdf.Heading = New Aspose.Pdf.Heading(pdf, sec1, Level)
Dim segment2 As Aspose.Pdf.Segment = New Aspose.Pdf.Segment(heading2)
heading2.Segments.Add(segment2)
heading2.IsAutoSequence = True
''segment2.Content = "this is heading of level #$UNICODE(197) "
segment2.Content = "Problematic characters are: ľ,č,ť,ň,... "
segment2.Content += Level.ToString()
'Add the heading into Table Of Contents.
heading2.IsInList = True
sec1.Paragraphs.Add(heading2)
Next
' save the Pdf file
pdf.SetUnicode()
pdf.Save("d:\UniCode_My_Test.pdf")
I have also attached my resulting pdf file, where you can see differencies between TOC and body.
... and one more question regarding TOC alignment. How can I align TOC on the right? As you can see I have added tocSection.ListFormatArray(0).Margin.Right = 30 to my code, but it looks that it ignored.
Thanks, Jozef.
Hello Jozef,
Thanks for sharing the code snippet.
I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNET-24899. We will investigate this issue in details and will keep you updated on the status of a correction. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
We apologize for your inconvenience.
Hello,
Hi Serguei,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
I have tested the latest version and issue related to TOC is still not resolved (bookmarks are however showing properly). I have registered an issue in our issue tracking system with issue id: PDFNEWNET-34625. Our development team will further look into this issue and we will update you via this forum thread.
Sorry for the inconvenience,
Hi Serguei,
Document doc = new
Document();<o:p></o:p>
Page tocPage = doc.Pages.Add();
TOCInfo tocInfo = new TOCInfo();
TextFragment title = new TextFragment("Table Of Contents");
title.TextState.FontSize = 30;
tocInfo.Title = title;
//Add the list section to the sections collection of the Pdf document
tocPage.TOCInfo = tocInfo;
//Define the format of the four levels list by setting the left margins
//and
//text format settings of each level
tocInfo.FormatArrayLength = 4;
tocInfo.FormatArray[0].Margin.Left = 0;
tocInfo.FormatArray[0].Margin.Right = 30;
tocInfo.FormatArray[0].TextState.FontStyle = FontStyles.Bold | FontStyles.Italic;
//tocSection.ListFormatArray(0).TextInfo.FontName = "Arial Unicode MS"
tocInfo.FormatArray[1].Margin.Left = 10;
tocInfo.FormatArray[1].Margin.Right = 30;
tocInfo.FormatArray[1].TextState.Underline = true;
tocInfo.FormatArray[1].TextState.FontSize = 10;
tocInfo.FormatArray[2].Margin.Left = 20;
tocInfo.FormatArray[2].Margin.Right = 30;
tocInfo.FormatArray[2].TextState.FontStyle = FontStyles.Bold;
tocInfo.FormatArray[3].Margin.Left = 30;
tocInfo.FormatArray[3].Margin.Right = 30;
tocInfo.FormatArray[3].TextState.FontStyle = FontStyles.Bold;
//Create a section in the Pdf document
Page page = doc.Pages.Add();
//Add four headings in the section
for (int Level = 1; Level <= 4; Level++)
{ Aspose.Pdf.Heading heading2 = new Aspose.Pdf.Heading(Level);
TextSegment segment2 = new TextSegment();
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
heading2.TOCPage = tocPage;
segment2.Text = "汉字/漢字" + Level;
heading2.TextState.Font = FontRepository.FindFont("Arial Unicode MS");
//Add the heading into Table Of Contents.
heading2.IsInList = true;
page.Paragraphs.Add(heading2);
}
// save the Pdf fileoutFile
doc.Save(“c:/pdftest/TOCIssue.pdf”);
The issues you have found earlier (filed as PDFNEWNET-34625) have been fixed in Aspose.Pdf for .NET 8.0.0.