Hi,
I'm getting an InvalidCastException when using PdfContentEditor.ReplaceText. The code and stack are below. I've tested it on two different pdfs (attached).
Any help would be gratefully received.
Cheers,
Chris
string templateFilePath = Server.MapPath("EB0345.pdf");
string ebookFilePath = Server.MapPath("replace.pdf");
if (File.Exists(templateFilePath)) {
if (File.Exists(ebookFilePath)) {
File.Delete(ebookFilePath);
}
File.Copy(templateFilePath, ebookFilePath);
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(templateFilePath);
editor.ReplaceText("the", "Chris");
editor.ReplaceText("of", "Chris");
editor.Save(ebookFilePath);
}
[InvalidCastException: Unable to cast object of type 'xfc3c9f4b173edcf4.x93eee9e971096ef0' to type 'xfc3c9f4b173edcf4.xdbaa4f30f49e508b'.]
x30a678191d9b1780.x704c80db9a265cb6.xb74014599166833d(Stream xdc4cce4a2fe6be69, Stream xf823f0edaa261f3b, String xeb819055c812d61d, String x5fe2d6e726bf62c5) +1029
Aspose.Pdf.Kit.PdfContentEditor.ReplaceText(String srcString, String descString) +214
Play._Default.Button1_Click(Object sender, EventArgs e) in C:\Sandpit\Play\Play\Default.aspx.cs:27
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565