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

Free Support Forum - aspose.com

Aspose Pdf Section Number and Title needs to be different font family and size using TextStamp

Hi Team,

I’m using Aspose.Total licensed version. We have a requirement to have different font size and font family for Section Number and Section Title.
Currently i am using TextStamp feature for putting the title on the existing pdf. Using below piece of code for the same.

FormattedText ft = new FormattedText(“4 Sample Excel”, System.Drawing.Color.FromArgb(227, 23, 54), System.Drawing.Color.White, “Georgia”, EncodingType.Cp1250, false, 14.99f);
TextStamp textStamp = new TextStamp(ft);
// Set properties of the stamp
textStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold;
textStamp.TopMargin = 10;
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Top;
// Add header on all pages
Page pdfpage = doc.Pages[1];
pdfpage.AddStamp(textStamp);

Do we have an option in Aspose pdf to have different font size and family within a TextStamp to do this? if yes, please guide me. Please find the attached pdf’s.

SectionNumber-Title-Issue.pdf (64.2 KB)
SectionNumber-Title-Expected.pdf (119.6 KB)

@mgsantosh

Regretfully, there is no way in the API to add different font family and font size within a single TextStamp object. Therefore, you need to use two different text stamps and position them according to your requirements by specifying their XIndent and YIndent Properties.

@asad.ali Thank you for the quick response.
If we use two different stamps, we are getting alignment issues.
We also tried to use table in the Header section, but here we are rotating few of the pages to landscape and some same as Portrait. So for the pages which are changed to Landscape, the header is also coming in landscape only.

Is there any way to achieve this to add different font family and font size for Section Number and Title.
Appreciate your help.

@mgsantosh

Can you please share a sample code snippet for our reference using which you are generating PDF from the scratch? We will further investigate the feasibility of your requirements and share our feedback with you accordingly.