hemalp
December 27, 2023, 1:43pm
1
Sample Code:
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(“Aspose.Total.NET.lic”);
var fs = new FileStream(@“00000203600003_00000.pdf”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Aspose.Pdf.Document document = new Aspose.Pdf.Document(fs,“test1”);
document.Save(@“UnProtected.pdf”);
You can find.pdf file in the attachment.
00000203600003_00000.pdf (44.7 KB)
@hemalp
When I checked in windows 10 under .Net 6 with the library version 23.12, the save passed.
I can’t evaluate the result because the file is password protected.
The attached file was generated when working without connecting a license.
UnProtected.pdf (129.2 KB)
What environment are you running the code in?
hemalp
December 28, 2023, 4:27am
4
I am using .Net Framework 4.8 and Aspose.Pdf version 23.8.0.0.
hemalp
December 28, 2023, 4:31am
5
@sergei.shibanov just open your attached file UnProtected.pdf , File is saved as password protected.
My goal is save this as unprotected pdf.
Sample Code:
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(“Aspose.Total.NET.lic”);
var fs = new FileStream(@“00000203600003_00000.pdf”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Aspose.Pdf.Document document = new Aspose.Pdf.Document(fs,“test1”);
document .ChangePasswords(“test1”, “”, “”);
document.Save(@“UnProtected.pdf”);
Throw exception like: Security properties can’t be changed because provided owner password is not true owner password.
How can I handle Exception.
@hemalp
For this you can use next code
var fs = new FileStream(dataDir + @"00000203600003_00000.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var document = new Aspose.Pdf.Document(fs, "test1");
document.Decrypt(); // instead document.ChangePasswords("test1", "", "");
document.Save(dataDir + @"UnProtected.pdf");