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 Sep 07, 2022 8:49 am

Hi,
I am trying to redact some words in landscape document , but rectangles that I get from:

PdfTextFind[] result = page.FindText(word, findType).Finds;
foreach (var find in result)
{ var rec = find.TextBounds}
are wrong when document is in landscape mode, do you have any suggestion?
License Version Spire.Pdf 8.7.2 .

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Wed Sep 07, 2022 10:17 am

Hello,

Thanks for your inquiry.
The findText method you currently use will be deprecated in the future, and in the latest version of Spire.Pdf 8.8.6, there is taking a new method to find text, you can refer to the following code. If you don’t use the latest version of Spire.Pdf, please update to the latest version and use the new method to find text. If your issue still exists, please offer the following message, thanks for your assistance in advance.
1) Your input Pdf file.
2) Your full test code that can reproduce your issue.
3) The screenshot shown your issue.
4) Application type, such as Console App, .NET Framework 4.8.
5) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Code: Select all
PdfDocument doc = new PdfDocument();
            // Read a pdf file
            doc.LoadFromFile(input);
            for (int i = 0;i<doc.Pages.Count;i++) {
                PdfPageBase page = doc.Pages[i];
                PdfTextFinder finder = new PdfTextFinder(page);
                // Create PdfTextFindCollection object to find text
                List<PdfTextFragment> collection = finder.Find("test");

                foreach (PdfTextFragment find in collection) {
                    RectangleF rec = find.Bounds[0];
                 
                }
            }


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Wed Sep 21, 2022 8:18 am

Hi , Thank you for quick response, I have one more question is there a way to replace find text in document not only for preview and print but to eliminate possibility to copy the replaced text.
We could see after downloading document and copy text, that replaced text still exist and text that was replaced with is copied to extra pages?

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Wed Sep 21, 2022 10:14 am

Hello,

Thanks for your feedback.
For the text replacement function, we are now dealing with overlaying the text directly on the top of the replaced text, so the replaced text still exists on the PDF document. However, our development team has worked on new text replacement feature that can completely remove the replaced text. Once new function is achieved, I’ll inform you in time.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 18, 2022 7:52 am

Hello,

Do you have some new information about replacement of text in order to do real redact of selected words, and not only redact for printing?
Regards.

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Tue Oct 18, 2022 10:24 am

Hello,

Thanks for your following-up.
Our development team have achieved the new method of replacing text. You can use the latest version 7.10.0 of Spire.Office for Net and the following code to do a test. If you have any issue, just feel free to contact us.

Code: Select all
String input = @"..\..\data\test.pdf";
            PdfDocument doc = new PdfDocument();

            // Load a pdf file
            doc.LoadFromFile(input);

            // Get the first page of pdf file
             PdfPageBase page = doc.Pages[0];

            //Create a PdfTextReplacer object
            PdfTextReplacer replacer = new PdfTextReplacer(page);
           
            //Replace text
            replacer.ReplaceText("Cash", "Abel");

            //Save the result document
            doc.SaveToFile(@"../../output/result.pdf", FileFormat.PDF);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 18, 2022 1:38 pm

We are using two latest packages for Spire.Pdf and Spire.Doc das that means that those packages das not have new replace method, and that we need to install Spire.Office?
Regards.

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Wed Oct 19, 2022 9:53 am

Hello,

Thanks for your feedback.
The new method of replacing text also exists in the latest Spire.Pdf version 8.10.5. You can have a test with the latest version of Spire.Pdf.
If you have any issue, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 25, 2022 2:11 am

Hello,

Hope you are doing well.
Could you give me some feedback about your issue? Looking forward to your reply.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Thu Oct 27, 2022 8:43 am

Hi , now replace is working well , we could only see that it das not work for some replacement character like for small square, but for regular characters it works .
Regards.

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Thu Oct 27, 2022 10:32 am

Hello,

Thank for your feedback.
To help us reproduce your issue and work out a solution for you, please offer the following message. Thanks for your assistance in advance.
1) Your full test code that can reproduce your issue.
2) Your pdf file.
3) Application type, such as Console App, .NET Framework 4.8.
4) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Tue Nov 01, 2022 9:38 am

Hello,

Hope you are doing well.
Could you give some feedback about this issue? Looking forward to your reply.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Thu Nov 03, 2022 12:59 pm

Hi, regarding your questions I was trying to do replace existing word in pdf document with string replaseStr="▪▪▪▪▪" containing couple off small black square characters with line replacer.ReplaceText(word, replaseStr); or replacer.ReplaceAllText(word, replaseStr);
If necessary I will send file but you can try on any pdf, because it wasn't working with more then one pdf.

I have additional question do you have options on new methods for replacement text ReplaceText and ReplaceAllText to ignore case sensitivity .

Regards
Biljana.

bstojanovic
 
Posts: 41
Joined: Mon Sep 28, 2020 2:54 pm

Fri Nov 04, 2022 9:18 am

Hello,

Thanks for your feedback.
For the issue that replacing text in Pdf file with the “▪▪▪▪▪”, I logged it into our bug tracking system with the ticket number SPIREPDF-5597. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

In addition, case - insensitive replacement of text is not supported in new method of replacing text. I have logged it as a new function into our product updating system with the ticket number SPIREPDF-5598. Our development team will achieve it. Once it is achieved, I will inform you in time.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Fri Dec 02, 2022 10:12 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Office 7.12.0 which fixes the issue with SPIREPDF-5598.
Please download the new version from the following links to test.

Website download link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Office/7.12.0

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF