We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Heading object: Different Style for User label and textsegment

I’m using 11.3 version of Aspose.pdf. I want to apply bold style to User label but the text-segment needs to be in normal font. if i apply bold style to heading.TextState, it gets applied to both User label and text-segment. Below is the sample code.

Document pdfDoc = new Document();

pdfDoc.PageInfo.Width = 612.0;

pdfDoc.PageInfo.Height = 792.0;

pdfDoc.PageInfo.Margin = new Aspose.Pdf.MarginInfo();

pdfDoc.PageInfo.Margin.Left = 72;

pdfDoc.PageInfo.Margin.Right = 72;

pdfDoc.PageInfo.Margin.Top = 72;

pdfDoc.PageInfo.Margin.Bottom = 72;



Page pdfPage = pdfDoc.Pages.Add();

pdfPage.PageInfo.Width = 612.0;

pdfPage.PageInfo.Height = 792.0;

pdfPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo();

pdfPage.PageInfo.Margin.Left = 72;

pdfPage.PageInfo.Margin.Right = 72;

pdfPage.PageInfo.Margin.Top = 72;

pdfPage.PageInfo.Margin.Bottom = 72;



Aspose.Pdf.FloatingBox floatBox = new Aspose.Pdf.FloatingBox();

floatBox.Margin = pdfPage.PageInfo.Margin;



pdfPage.Paragraphs.Add(floatBox);

Aspose.Pdf.Text.Font font = Aspose.Pdf.Text.FontRepository.FindFont(“Arial”);



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

heading.UserLabel = "(3) ";

heading.IsAutoSequence = true;

heading.Margin = new MarginInfo(45, 0, 0, 0);

heading.TextState.Font = font;

heading.TextState.FontSize = 10;
heading.TextState.FontStyle = FontStyles.Bold;

heading.TextState.LineSpacing = 3;



TextSegment segment = new TextSegment("Eliminate the duty of loyalty under division © of ");

segment.TextState.Font = font;
segment.TextState.FontStyle = FontStyles.Regular;
segment.TextState.FontSize = 10;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);



floatBox.Paragraphs.Add(heading);



string outFile = @“c:\temp\UserLabel.pdf”;

pdfDoc.Save(outFile);

Hi Prashant,

Thanks for your inquiry. I have tested your scenario with Aspose.Pdf for .NET 11.3.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-40277 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

We are sorry for the inconvenience caused.

Best Regards,

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


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