Free Support Forum - aspose.com

Aspose.Pdf.Kit PdfContentEditor.ReplaceText InvalidCastException

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

Hi Chris,

I have reproduced this problem at my end and logged it as PDFKITNET-14333 in our issue tracking system. Our team will look into this problem and you’ll be updated via this forum thread once the issue is resolved.

We’re sorry for the inconvenience.
Regards,

Gidday Shahzad,

Thanks for getting back to me. Is this a common occurrence? This is the first time that I’ve coded with Aspose and it hasn’t got off to a good start! :frowning: I’ve got to get something out reasonably soon. Is there are work around?

Cheers,

Chris

Hi Chris,

We’re very sorry for the inconvenience.

I would like to share with you that sometimes such kind of issues are caused due to the particular contents or origin of the PDF files. Our team need to investigate the issue to identify the cause of this problem. I’m afraid, I can’t share a workaround for this sort of issue at the moment. we’ll try to resolve the issue the earliest possible. You’ll be informed via this forum thread once it is resolved.

We’re looking forward to help you out and appreciate your patience.
Regards,



The issues you have found earlier (filed as 14333) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.