We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

[Urgent]Generating corrupt file after text replacement

Hi All,

I have few PDF files(reference attached), when I am trying to replace some text using below code, generated PDF is being corrupted where many of the files is working fine. Please help me our why attached files are being corrupted.

Note : Scroll down up to the bottom to see the error.(“Original.pdf” is the original one and “Corrupted.pdf” is the corrupted pdf against Original.pdf )


Code :

using Aspose.Pdf.Facades;


Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“H:\Aspose.Pdf.lic”);

//open input PDF
PdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.BindPdf(“H:\Original.pdf”);
//replace text on all pages

pdfContentEditor.ReplaceText("<>", DateTime.Now.ToShortDateString());

pdfContentEditor.ReplaceText("<>", “Kali Charan Dash”);
pdfContentEditor.ReplaceText("<<biz_name>>", “kcdash”);
pdfContentEditor.ReplaceText("<>", “MIG-2, 31/6”);
pdfContentEditor.ReplaceText("<>", “HB Colony, CS Pur”);
pdfContentEditor.ReplaceText("<<x_city>>", “Bhubaneswar”);
pdfContentEditor.ReplaceText("<<x_state>>", “Odisha”);
pdfContentEditor.ReplaceText("<<x_zip>>", “751016”);
pdfContentEditor.ReplaceText("<<zip_4>>", “0016”);
pdfContentEditor.ReplaceText("<>", “India”);

pdfContentEditor.ReplaceText("<<REF_NUM>>", “011 8600 8600”);

pdfContentEditor.ReplaceText("<<effec_dt>>", “April 30, 2013”);
pdfContentEditor.ReplaceText("<>", “999”);
pdfContentEditor.ReplaceText("<>", “Rajesh Kumar”);

pdfContentEditor.ReplaceText("<<LHD_VERS>>", “lhd vers”);
pdfContentEditor.ReplaceText("<<OSE_VERS>>", “ose vers”);
pdfContentEditor.ReplaceText("<>", “insert1”);
pdfContentEditor.ReplaceText("<>", “insert2”);

//save output PDF
pdfContentEditor.Save(“H:\Corrupted.pdf”);

Observation :

Facing problem with the below segment
pdfContentEditor.ReplaceText("<<LHD_VERS>>", “lhd vers”);
pdfContentEditor.ReplaceText("<<OSE_VERS>>", “ose vers”);
pdfContentEditor.ReplaceText("<>", “insert1”);
pdfContentEditor.ReplaceText("<>", “insert2”);


Hi Kali,


Thanks for your inquiry. We have already looking into your similar query here. I’ve linked you current post to the already logged ticket PDFNEWNET-35083. We will notify you as soon as this issue is resolved.

Sorry for the inconvenience faced.

Best Regards,

Hi Kali,


Thanks for your patience. Please check updated status and a workaround for the issue here.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35083) have been fixed in Aspose.Pdf for .NET 8.1.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)