Hi
I am using freespire.pdf(8.6.0) Version in .Net Core Project (.Net - 6 )
As I am try to replacing texts in pdf with new words but it replace with only white space,no new word is replaced there
I also tried with different way and example provied on e-iceblue official site but not works
Please see below my code
var templatePath = Path.Combine(GoatSignConsts.TemplatePath, template.TenantId.ToString(), template.FileName);
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(templatePath);
PdfUsedFont pdfFont = doc.UsedFonts[0];
PdfTextFindCollection collection = page.FindText("{{Name}}", TextFindParameter.WholeWord);
RectangleF rec;
//Creates a brush
PdfBrush brush = new PdfSolidBrush(Color.DarkBlue);
foreach (PdfTextFind find in collection.Finds)
{
float.TryParse((pdfFont.Size + 2).ToString(), out float fontSize);
PdfTrueTypeFont font;
try
{
font = new PdfTrueTypeFont(new Font(new FontFamily(pdfFont.Name), 12, FontStyle.Regular), fontSize, true);
}
catch (Exception)
{
font = new PdfTrueTypeFont(new Font(new FontFamily("Arial"), 12, FontStyle.Regular), fontSize, true);
}
// Gets the bound of the found text in page
rec = find.TextBounds.FirstOrDefault();
//rec.Y = rec.Y + 1;
page.Canvas.DrawRectangle(PdfBrushes.White, rec);
page.Canvas.DrawString("Replaced One", font, brush, rec);
}
We have also applied other methods but we are facing lots of issue with layout and words position
Also Tried this
foreach (PdfTextFind find in collection.Finds)
{
//replace word in pdf
find.ApplyRecoverString(dVariable.Value, Color.White, true);
}
Please take a look and because we tried with different applications