PDF Alignment is damaged when we try to replace fonts in a PDF using C#

Hi,

PDF Alignment is damaged when we try to replace fonts in a PDF using C#.

The pdf file has fonts like below.

we want to replace all these fonts with courier new font.



Below is the code snippet we are using. but its not working.

The font is getting changed but the alignment is getting damaged in side the pdf.

Please help.

var lent = loadedDocument.UsedFonts.Length;
for (int j = 0; j < lent; j++)
{
//Replace font
if (loadedDocument.UsedFonts[j].Type.ToString() != "TrueTypeEmbedded")
{
loadedDocument.UsedFonts[j].Replace(new PdfStandardFont(PdfFontFamily.Courier, 10));
PdfFont newfont = new PdfTrueTypeFont(new Font("Courier", 14), true);
}
}
loadedDocument.Save("D:/Replacedfile.pdf");
loadedDocument.Close(true)

Please help.





2 Replies

GK Gowthamraj Kumar Syncfusion Team July 8, 2021 11:21 AM UTC

Hi Vamsi, 
 
Thank you for contacting Syncfusion support. 
 
We were able to reproduce the reported issue with provided details on our end. Currently, we are validating on this and we will update the further details on July 12th 2021. 
 
Regards, 
Gowthamraj K 



GK Gowthamraj Kumar Syncfusion Team July 12, 2021 12:09 PM UTC

Hi Vamsi, 
 
Thank you for your patience. 
 
We have checked the reported issue with our test document on our end. The reported alignment issue may occurs due to that replaced font and its behaviour. Every font has differ styles and render behaviour. We suspect that same for replacing the TrueType font with standard courier font. Meanwhile, we are requesting you to share the input pdf document which you are facing this alignment issue to analyse on this and it will be helpful for us to analyse and assist you further on this. 
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon