Hi,
I wrote a class that has been wrapping aspose.pdf features to our application. There is a method that mimics aspose.pdf replace text feature. But it is not working. I tried a lot of various method to resolve this issue but I can not. It replaced target text with blank text. I have Aspose.Total licence. Can you help me to resolve ?
My sample method to replace text in wrapper class:
public void ReplaceText(string targetText, string sourceText)
{
AP.Text.TextFragmentAbsorber textFragmentAbsorber = new AP.Text.TextFragmentAbsorber(targetText);
this._coreDocument.Pages.Accept(textFragmentAbsorber);
AP.Text.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (AP.Text.TextFragment textFragmentItem in textFragmentCollection)
{
textFragmentItem.Text = sourceText;
}
}
Hi Timuçin,
Thanks for contacting support.
Can you please share the source PDF file causing this problem so that we can test the scenario at our end. Also please share that you are facing issue while replacing any particular string or its occurring for all TextFragments.
We are sorry for this inconvenience.
Thank you for your response. I attached my template that I used to replace text. I am facing this issue while replacing particular string. I tried again with your sample code like that. But not worked again.
Sample Code:
----------------------------------------------
License l = new License();
l.SetLicense(“d:\Aspose.Total.lic”);
Document pdfDocument = new Document(“d:\template.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“#AD#”);
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = “Ali Taha”;
}
pdfDocument.Save(“d:\output.pdf”);
----------------------------------------------
The code above replacing “#AD#” text with a Blank text. But I expect that “#AD#” has been replaced with “Ali Taha”. My .net solution is using .net framework 4.0 and I tried all of Aspose.Pdf.dll version (2.0, 3.5,3.5 Client Profile,4.0,4.0 Client Profile). But It is not worked again.
It’s curious but that template.pdf working in your example page below.
I have got enterprise licence. If you need; I can give licence information to you in a private messege.
Thank you.
Hi Timuçin,
Thanks for sharing the resource file.
I have tested the scenario using
Aspose.Pdf for .NET 8.2.0 and I am unable to notice any issue. I have used Visual Studio 2010 application with target platform as .NET Framework 4.0. For your reference, I have also attached the resultant PDF being generated over my end. Can you please try using the latest release.
Hi,
I have already testing with Aspose.Pdf for .NET 8.2.0. But I am actually using Visual Studio 2012 with target platform .NET Framework 4.0. But after your response; I tested with Visual Studio 2010 with target platform .NET Framework 4.0. But still It is not working.
Are there any alternatives to test and resolve this issue? Do you think It is related wit my pc configuration or PDF drivers ? I have to resolve immediately this issue.
Hi,
I realize something when I changed font name to “Helvetica” which is Aspose.Pdf’s default font. It worked !
textFragment.TextState.Font = FontRepository.FindFont(“Helvetica”);
After that I changed my template font from “Calibri” to “Helvetica” and remove the line above. Than it worked again without changed font progmatically.
I think there is a bug with other fonts or other local languages fonts. When I use another font except “Helvetica”, It did not work. My template use Calibri which is default font for Office Word 2013.
Please research this issue in this work around. I think there is a localization issue.
Hi Timuçin,
Thanks for sharing the details and sorry for the delayed response.
I am working over this query and will get back to you soon.
Hi Timuçin,
I have again tested the scenario where I have used Calibri font during code executing and as per my observations, the text is properly being replaced when tested in Visual Studio 2010 application with target platform as .NET Framework 4.0, running over Windows 7(X64) where I have English (United States) as my regional language.
Can you please share some further details which can help us in replicating this problem. We are really sorry for this inconvenience.
Hi,
I’m sharing some information about my environment.
I have installed both of VS 2012 and VS 2010.
My computer’s OS is Windows 7(X64).
I have installed Office Professional Plus 2013.
My target platform is .NET Framework 4.0. But also have installed .NET Framework 4.5.
I try out all of the combinations to figure out this issue. But any of them not worked.
I have tested compiled assembly with other colleagues computers but the results are same.
Other features of Aspose.Pdf are working properly. Only Replace Text is not working without Core fonts.
Hi Timuçin,
Thanks for sharing the details.
Please notice my comments over 484166 where I have shared that I am able to replicate this problem. As soon as we have made some significant progress towards the resolution of this problem, we would be more than happy to update you with the status of correction.
Your patience and comprehension is greatly appreciated in this regard.
The issues you have found earlier (filed as PDFNEWNET-35585) have been fixed in Aspose.Pdf for .NET 10.2.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.