Stamp Font size is not changing for Mixed size PDF | Aspose.PDF for .NET

Hi Team,

I am trying to add text stamp in mixed size of pdf and text font size must be change as per page size like if page is A4 then font size must be 11, A3 must be 19, A2 must be 25, A1 must be 35 and A0 must be 57. In my code before stamping i am checking page size and changing font size but after stamp when I check the PDF then i found font size is same for all pages.

Code Snip
using Aspose.Pdf;
using Aspose.Pdf.Facades;
using System;
namespace PDF_Watermarker
{
class FooterStamp
{
float PDFWidth = 0.0F; float PDFHeight = 0.0F;
string Result = string.Empty; int PdfPageCount = 1;
public void AddFooterwithBCOandDate(string PDFCurrentFile, string WatermarkText)
{
Document pdfDocument = new Document(PDFCurrentFile); //Open PDF
PdfFileInfo info = new PdfFileInfo(PDFCurrentFile);//to Get PDF INFO
if (!string.IsNullOrEmpty(info.Creator) && info.Creator.ToLower().Contains(“adobe livecycle designer 11.0”))
{
Result = "Error - This PDF Created By Adobe LiveCycle Designer 11.0 \nFile at " + PDFCurrentFile;
}
else
{
TextStamp textFooterStamp = new TextStamp(WatermarkText + " Received by Auckland Council " + DateTime.Now.ToString(“dd/MM/yyyy”));
// set properties of the stamp
textFooterStamp.BottomMargin = 7;
textFooterStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
textFooterStamp.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom;
// set text properties
textFooterStamp.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont(“Arial”); textFooterStamp.TextState.ForegroundColor = Color.Blue;
textFooterStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold | Aspose.Pdf.Text.FontStyles.Italic;
for (int i = 1; i <= pdfDocument.Pages.Count; i++)
{
PDFWidth = info.GetPageWidth(PdfPageCount);//Get PDF Size
PDFHeight = info.GetPageHeight(PdfPageCount);//Get PDF Size

                //Check Page Type and  Incresase Font size                
                if (PDFWidth > 550 && PDFWidth < 900)  //A4 Page
                {                        
                    textFooterStamp.TextState.FontSize = 11;
                }
                else if (PDFWidth > 900 && PDFWidth < 1350)  //A3 Page
                {                        
                    textFooterStamp.TextState.FontSize = 19;                        
                }
                else if (PDFWidth > 1350 && PDFWidth < 1950) //A2 Page
                {                       
                    textFooterStamp.TextState.FontSize = 25;                       
                }
                else if (PDFWidth > 1950 && PDFWidth < 3000) //A1 Page
                {                        
                    textFooterStamp.TextState.FontSize = 35;                        
                }
                else if (PDFWidth > 3000) //A0 Page
                {                       
                    textFooterStamp.TextState.FontSize = 57;                        
                }
                pdfDocument.Pages[PdfPageCount].AddStamp(textFooterStamp);  // Add stamp in Footer 
                PdfPageCount = PdfPageCount + 1; //Increase PDF Page Number for Background watermark           
            }
            pdfDocument.Save(PDFCurrentFile);  // Save the Pdf file 
            Result = "Header stamp added successfully\nFile Save at " + PDFCurrentFile;
        }
    }
}

}

Request to please help to resolve this issue .

@vivekhvs

Could you kindly share the sample source and respective output PDF file for our reference with which you are using the above shared code snippet. We will test the scenario in our environment and address it accordingly.

Hi Asad,

Thanks for your reply. PFA mixed size PDF and code snippet file.

(Attachment CodeSnippet.txt is missing)

Mixed Size PDF.pdf (13.6 MB)

Hi Asad,

Thanks for your reply. PFA mixed size PDF and code snippet file.

Mixed Size PDF.pdf (13.6 MB)

FooterStamp.PNG (68.3 KB)

@vivekhvs

We have tested the scenario in our environment while using Aspose.PDF for .NET 21.4 and were able to notice the same issue that you mentioned. Therefore, an issue has been logged in our issue management system under the ticket ID PDFNET-49892 for the sake of correction. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like