There is no verbiage in the online docs about this method? The following code results in closing the Stream the PdfContentEditor is bound to and the last line throwing an exception the a closed stream cannot be written to. Not sure what to do?
I have tried using a separate input and output stream, using a temporary memory stream, binding with filepath, binding with filestream and saving with filepath, binding with filepath and saving with filestream etc, etc, etc. HOURS of attempts, and NOTHING works.
Can you please provide some code showing how to:
Bind the PdfContentEditor to a existing Pdf
Replace a text string using ReplaceText() method
Save the altered Pdf to a new file
This has been a very frustrating endeavor, and there is almost ZERO documentation available, and no solution that I can find anywhere. Thank you in advance for your help.
Please take a look over the following code snippet which demonstrates the feature of ReplaceText feature of PdfContentEditor class. I have also attached the source PDF and the resultant PDF that I have generated after this operation has been performed.
[C#]
// create an object of PdfContentEditor PdfContentEditor editor = new PdfContentEditor(); // bind the source PDF document editor.BindPdf(@"d:/pdftest/Source_ReplaceText_Test.pdf"); // specify the source string that needs to be replaced with target string editor.ReplaceText("dog", "Cat"); // save the updated PDF document editor.Save(@"d:/pdftest/Resultant_After_ReplaceText.pdf");
In case it does not satisfy your requirements or you have any further query, please feel free to contact. We apologize for your inconvenience.
PS, Please note that this feature is in Beta version and might not deliver 100% accurate results.