I'm trying to use the sample code to test the replace function:
Dim editor As PdfContentEditor = New PdfContentEditor() editor.BindPdf(inputPath + "text.pdf") editor.ReplaceText("Pdf", "WordPpt") editor.Save(outputPath + "replace.pdf")
This will work, but then I cannot access the original file, text.pdf, from windows or nor can I run the script again as the file is locked. As though the process did not release it. To attemp to work around this I tried using a stream as the BindPdf argument with no success. I tried:
Dim inputStream As FileStream = File.Open(inputPath + inputFile, FileMode.Open, FileAccess.Read, FileShare.Read) editor.BindPdf(inputStream)
I get an error trying this:
Exception Details: System.ArgumentNullException: Path cannot be null. Parameter name: path
on this line: Line 32: editor.ReplaceText("Pdf", "WordPpt")
Can someone provide me with the correct way to handle this?
Please make sure you are using the latest version of Aspose.Pdf.Kit, as I have tested the scenario using one of my sample Pdf file and I am unable to notice the problem. The Pdf file that I have used is in attachment along with the resultant Pdf that I’ve generated.
In case you still facing any problem with latest version, please share the resource Pdf file that you are using, so that we can test the issue at our end.
[VB.NET]
Dim editor As PdfContentEditor = New PdfContentEditor() editor.BindPdf("d:\pdftest\ReplaceText.pdf") editor.ReplaceText("item1", "Computer") editor.Save("d:\pdftest\ReplaceText_replaced.pdf")
It seems now that a long as I don't get an error, the files will not stay locked. So that is working ok.
But the replace success is spotty and unpredicable. Some words will replace others will not. Is this something that is being worked on now? I like the component, just can't use it unless it's 100% on the replace.
This is Beta version of ReplaceText. The feature may not be supported well for some PDF files and we may be not able to fix it in short time.
Our development team is working hard to improve this feature, and as soon as we have made some progress, we would be pleased to update you with the status of correction. Your patience in this regard is highly appreciated.