Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Mar 10, 2021 10:17 pm

Hi,

I evaluate your tool to replace a text in a pdf-file. After replacing the text the position of the new text is to high.
Attached to this topic you will find a pfd with my example. To replace the text I use your code example. It's not
possible for me to change the textposition. Do you have an example for me?

Greetings from germany

Werner Ernst

wernerernst
 
Posts: 2
Joined: Wed Mar 10, 2021 3:04 pm

Thu Mar 11, 2021 6:25 am

Hello,

Thanks for your inquiry.
Starting from Spire.PDF v7.2.5, we provides a new method (as shown below) to replace the pdf text . If you are not using this new method, please download the latest Spire.PDF Pack(Hot Fix) Version:7.2.9 and give it a try.
Code: Select all
            String input = @"SearchReplaceTemplate.pdf";
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(input);
            PdfPageBase page = doc.Pages[0];

            PdfTextReplacer ptr = new PdfTextReplacer(page);
            ptr.ReplaceAllText("Spire.PDF for .NET", "new text");

            String result = "ReplaceAllSearchedText_out.pdf";
            doc.SaveToFile(result);

If the issue persists after trying, please provide your input pdf file to help us investigate further. Thanks in advance


Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Thu Mar 11, 2021 8:46 am

Hello,

thank you for your fast answer. Your solution works fine.
The text is replaced perfectly.

Greetings from Germany

Werner

wernerernst
 
Posts: 2
Joined: Wed Mar 10, 2021 3:04 pm

Thu Mar 11, 2021 9:07 am

Hello,

Thanks for your feedback.
If you encounter any issues related to our product in the future, just feel free to contact us.
Have a nice day!

Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Return to Spire.PDF