Decrypt-problem- pdf corrupt

Hi,

in the zip-file I provide a pdf, that is encrypted. After the decryption, the file seems to be corrupt (the decrypted file is in the zip-file as well). Reading this file with other applications causes a storage violation exception. Reading the file with acrobat reader causes an error as well. Could you please check?
this is the source I use (using Aspose.pdf.dll v. 7.0.0.0):

string sInFile = “Aspose_PDF_corrupt.pdf”;

string sOutFile = “Aspose_PDF_corrupt_new.pdf”;

Aspose.Pdf.License pLic = new Aspose.Pdf.License();

pLic.SetLicense(“Aspose.Total.lic”);



System.IO.MemoryStream ms = new System.IO.MemoryStream();



try

{

Aspose.Pdf.Facades.PdfFileInfo fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(sInFile);

if (fileInfo.IsEncrypted)

{

Aspose.Pdf.Facades.PdfFileSecurity sec = new Aspose.Pdf.Facades.PdfFileSecurity();

sec.InputFile = sInFile;

sec.OutputStream = ms;

bool bOk = sec.DecryptFile("");



System.IO.MemoryStream msx = new System.IO.MemoryStream();

msx.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);



msx.Position = 0;



FileStream fs = File.OpenWrite(sOutFile);

if (msx != null)

{

msx.WriteTo(fs);

fs.Flush();



}

fs.Close();

fs.Dispose();

}

}

catch (Exception ex)

{

MessageBox.Show("Error " + ex.Message);

}

}

kind regards,
Oliver

Hi Oliver,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and sample code.

I am able to generate your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-34058. You will be notified via this forum thread regarding any updates against your reported issue.

Sorry for the inconvenience,

Hi Nausherwan,
any news on this one for me?

kind regards,
Oliver

Hi Oliver,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please modify your code as below to resolve your corrupt file issue. I checked it with the latest version of Aspose.Pdf for .NET v7.3 and it works fine.

string sInFile = @"D:\Aspose_PDF\Aspose_PDF_corrupt.pdf";

string sOutFile = @"D:\ Aspose_PDF\Aspose_PDF_corrupt_new.pdf";

using (MemoryStream ms = new MemoryStream())

{

try

{

Aspose.Pdf.Facades.PdfFileInfo fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(sInFile);

if (fileInfo.IsEncrypted)

{

Aspose.Pdf.Facades.PdfFileSecurity sec = new Aspose.Pdf.Facades.PdfFileSecurity();

sec.InputFile = sInFile;

sec.OutputStream = ms;

bool bOk = sec.DecryptFile("");

using (MemoryStream msx = new MemoryStream())

{

ms.WriteTo(msx);

using (FileStream fs = File.OpenWrite(sOutFile))

{

msx.WriteTo(fs);

}

}

}

}

catch (Exception ex)

{

}

}

Sorry for the inconvenience,

Hi Nausherwan,

thank you for the hint. The workaround works fine.

Kind regards,
Oliver

Hi Oliver,


I am glad to hear that the problem reported earlier has been resolved. Please continue using our products and in case of any further query, please feel free to contact.

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

The blog post for this release is created over this link


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan