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”);
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”);