Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Table of content issue in Aspose pdf 8.5

$
0
0

Hi ,

In need some help regarding table of contents in Aspose pdf 8.5. Please refer to attached pdf that has been created .

Problem 1:

There are some fields data (returned from database) that has HTML , one of such field has Table of Content - heading defined on it example:

"*Hospira—Various Plum A+ Infusion Pumps: Door Roller Assembly May Break,Potentially Leading to Unrestricted Flow and/or Overdelivery [Update]" .

This field is displayed correctly in pdf , but table of contents is displaying text with <HTML> tags.

Code:

Aspose.Pdf.Generator.Row HeadlineRow = tab1.Rows.Add();

                    Aspose.Pdf.Generator.Heading HeadlineText = new Aspose.Pdf.Generator.Heading(pdfConv, sec1, 2);
                    Aspose.Pdf.Generator.Segment HeadlineTextSeg = new Aspose.Pdf.Generator.Segment(HeadlineText);
                    HeadlineText.Segments.Add(HeadlineTextSeg);
                    HeadlineTextSeg.Content = "<font face=\"Arial\" size=14px>" + ssss.Headline.Trim() + "<br></font>";

                    HeadlineText.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;
                    HeadlineText.IsHtmlTagSupported = true;

                    //Add the heading into Table Of Contents.
                    HeadlineText.IsInList = true;
                    Aspose.Pdf.Generator.Cell HeadlineRowCell = HeadlineRow.Cells.Add();
                    HeadlineRowCell.Paragraphs.Add(HeadlineText);

Problem 2:

The text on which table of content is defined (IsInList=true) are indented towards right in pdf (refer to pdf heading in Red , Geographic Regions and Suggested Distribution . Please suggest what property I need to set here to avoid this indentation.

 

Code to define ToC:

                tocSection.ListType = ListType.TableOfContents;
                tocSection.ListFormatArray.Length = 2;
                tocSection.ListFormatArray[0].SubsequentLinesIndent = 2;
                tocSection.ListFormatArray[0].Margin.Bottom = 10;
                tocSection.ListFormatArray[0].TextInfo.FontName = "Arial";
                tocSection.ListFormatArray[0].TextInfo.FontSize = 9;

                tocSection.ListFormatArray[1].SubsequentLinesIndent = 4;
                tocSection.ListFormatArray[1].Margin.Bottom = 10;
                tocSection.ListFormatArray[1].LeftMargin = 15;
                tocSection.ListFormatArray[1].TextInfo.FontName = "Arial";
                tocSection.ListFormatArray[1].TextInfo.FontSize = 7;

                pdfConv.Sections.Add(tocSection);

 

Problem 3 

We want to add a Image and then ToC heading as "Contents" for Table of Contents page (please refer to attached pdf). But it is showing heading first and then Image. Please let us know what is wrong in code.

 

                  //Create a list section
                Aspose.Pdf.Generator.Image imgtoc = new Aspose.Pdf.Generator.Image();

                // add a image first
                imgtoc.ImageInfo.File = dataDir + "Images/TOCHeadingImage.png";
                imgtoc.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;

                imgtoc.ImageInfo.FixWidth = 400;
                ListSection tocSection = new ListSection(pdfConv);

                tocSection.Paragraphs.Add(imgtoc);

                tocSection.Title = new Text("Contents");
                tocSection.Title.TextInfo.FontName = "Arial";
                tocSection.Title.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;

                Aspose.Pdf.Generator.Color c = new Aspose.Pdf.Generator.Color(255, 163, 163);
                tocSection.Title.TextInfo.BackgroundColor = c;
                tocSection.Title.TextInfo.FontSize = 9;
                tocSection.Title.TextInfo.LineSpacing = 9;
                tocSection.Title.TextInfo.IsTrueTypeFontBold = false;
                tocSection.Title.Margin.Top = 10;
                tocSection.Title.Margin.Bottom = 20;

 

Appreciate your help and quick response.

 

Thanks

PG

 

 


Viewing all articles
Browse latest Browse all 3131

Trending Articles