Write Headings in numbering style with html contents

Hi,


I’m using aspose pdf Generator and I need to write headings in numbering style, but the segment’s text content must be html code, saved in the DB and passed to the method as string.

I know that the html text is supported in Text object by setting the boolean isHtmlTagsupported=true and this feature is also supported by Heading object but when i run my code the result is an error like this
||at Aspose.Pdf.Generator.Segments.get_Item(Int32 index)
at
..( , Pdf , Heading , ™ )
at .š.( , Pdf , ™ , Boolean )
at
.‚.( , Pdf )
at .Š.( , Pdf )
at Aspose.Pdf.Generator.Pdf.Save(String pdfFile)
at TAC.Business.ToolsManager.CreateTestPDF(Boolean isPreview, Int32 testId) in
ToolsManager.cs: line 218
at
TAC.Business.Tests.PdfUtilityTest.CretePDFTest() in PdfUtilityTest.cs: line 22||

Best regards

Alejob

Hi Alessandro,

Thanks for using our products.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

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 <span style=“font-family:“Arial”,“sans-serif””>PDFNEWNET-34045. We
will investigate this issue in details and will keep you updated on the status
of a correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

We
apologize for your inconvenience.


The issues you have found earlier (filed as PDFNEWNET-34045) have been fixed in Aspose.Pdf for .NET 8.9.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Alessandro,


Thanks for your patience. As stated above that your reported issue has been resolved in Aspose.Pdf for .NET 8.9.0. release. Please note issue has been fixed in new Generator i.e. Aspose.Pdf.Document class. Please check sample code snippet as following. Hopefully it will help you to accomplish your task.

Please note Aspose.Pdf.Generator is obsolete now and we are fixing issues and making enhancements in new Generator as it follows DOM approach and is more efficient than old Generator. Moreover it can be used to create a new PDF from scratch or manipulate existing PDF document as well.

string outFile = “34045.pdf”;<o:p></o:p>

string inFile = @"NAB Logo.bmp";

Document doc = new Document();

Page page = doc.Pages.Add();

//LOGO

Aspose.Pdf.Image logo = new Aspose.Pdf.Image();

logo.File = inFile;

page.Paragraphs.Add(logo);

//TITLE

TextFragment pdfHeadTitle = new TextFragment(string.Format("{0}", "internalTest.TestTemplate.Name"));

pdfHeadTitle.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

pdfHeadTitle.TextState.Font = FontRepository.FindFont("Arial");

pdfHeadTitle.TextState.FontStyle = FontStyles.Bold;

pdfHeadTitle.TextState.FontSize = 16;

pdfHeadTitle.TextState.LineSpacing = 5;

page.Paragraphs.Add(pdfHeadTitle);

String date_new;

int count = 1;

date_new = string.Format("Test creato il: {0}", DateTime.Now.ToString("dd/MM/yyyy"));

//Counter

TextFragment pdfHeadCount = new TextFragment(count.ToString());

pdfHeadCount.TextState.Font = FontRepository.FindFont("Arial");

pdfHeadCount.TextState.FontStyle = FontStyles.Bold;

pdfHeadCount.TextState.FontSize = 12;

pdfHeadCount.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;

pdfHeadCount.TextState.LineSpacing = 5;

page.Paragraphs.Add(pdfHeadCount);

//Date

TextFragment pdfHeadDate = new TextFragment(date_new);

pdfHeadDate.TextState.Font = FontRepository.FindFont("Arial");

pdfHeadDate.TextState.FontStyle = FontStyles.Bold;

pdfHeadDate.TextState.FontSize = 12;

pdfHeadDate.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;

pdfHeadDate.TextState.LineSpacing = 5;

page.Paragraphs.Add(pdfHeadDate);

for (int question = 0; question <= 5; question++)

{

Aspose.Pdf.Heading headingQ = new Aspose.Pdf.Heading(1);

headingQ.Text = "pulisci(question.Text)";

headingQ.TextState.Font = FontRepository.FindFont("Arial");

headingQ.TextState.FontSize = 10;

headingQ.TextState.FontStyle = FontStyles.Bold;

headingQ.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify;

headingQ.TextState.LineSpacing = 3;

headingQ.Margin = new Aspose.Pdf.MarginInfo();

headingQ.Margin.Top = 10;

headingQ.IsAutoSequence = true;

page.Paragraphs.Add(headingQ);

for (int internalAnswer = 0; internalAnswer <= 5; internalAnswer++)

{

Aspose.Pdf.Heading headingA = new Aspose.Pdf.Heading(2);

headingA.Text = "(internalAnswer.Text)";

headingA.TextState.Font = FontRepository.FindFont("Arial");

headingA.TextState.FontSize = 10;

headingA.TextState.FontStyle = FontStyles.Bold;

headingA.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify;

headingA.TextState.LineSpacing = 3;

headingA.Margin = new Aspose.Pdf.MarginInfo();

headingA.Margin.Left = 12;

headingA.Margin.Top = 5;

page.Paragraphs.Add(headingA);

}

}

doc.Save(outFile);


Please feel free to contact us for any further assistance.


Best Regards,