Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Mon Aug 17, 2020 9:37 am
Hallo Support-Team
I am using the free version of Spire.Office for .NET
Even if I set the owner password of the PDF document and save the changes to the file,
Spire.PDF cannot set all the permissions to "Not Allowed".
What should I do?
- Code: Select all
using Spire.Pdf;
using Spire.Pdf.Security;
using Spire.Xls;
using Spire.Xls.Converter;
namespace test.Models
{
public class PDFReport
{
public void Main()
{
string tempFilePath = @"D:\Template\Template.xlsx";
string tempOutPutPath = @"D:\Template\TEST.pdf";
// load Excel file
Workbook workbook = new Workbook();
workbook.LoadFromFile(tempFilePath);
// Set PDF template
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
pdfDocument.Security.KeySize = PdfEncryptionKeySize.Key256Bit;
pdfDocument.Security.OwnerPassword = "test";
PdfConverter pdfConverter = new PdfConverter(workbook);
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
pdfDocument = pdfConverter.Convert(settings);
pdfDocument.SaveToFile(tempOutPutPath);
System.Diagnostics.Process.Start(tempOutPutPath);
}
}
}
Login to view the files attached to this post.
-

sa_uchida
-
- Posts: 2
- Joined: Mon Aug 17, 2020 8:40 am
Tue Aug 18, 2020 7:27 am
Hi
Thanks for your inquiry.
The following code can set all the permissions to "Not Allowed". If you have any questions, please feel free to write it back.
- Code: Select all
//load the document from file
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(“test.pdf");
//encrypt the PDF file and set all the permissions to "Not Allowed"
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.None, PdfEncryptionKeySize.Key128Bit);
//save the document to file
pdf.SaveToFile("Encrypted.pdf", FileFormat.PDF);
Sincerely,
Lynn
E-iceblue support team
-


lynn.zhang
-
- Posts: 57
- Joined: Mon Jul 27, 2020 2:27 am
Wed Aug 19, 2020 2:01 am
Hallo Support-Team
Thank you for your support.
I was able to do what I wanted to do.
-

sa_uchida
-
- Posts: 2
- Joined: Mon Aug 17, 2020 8:40 am
Wed Aug 19, 2020 6:35 am
Hi,
Thanks for your feedback.
Glad to hear that your issue has been resolved. If you need further assistance, please feel free to write back.
Wish you all the best!
Sincerely,
Lynn
E-iceblue support team
-


lynn.zhang
-
- Posts: 57
- Joined: Mon Jul 27, 2020 2:27 am