#1
Posted
:
Wednesday, January 3, 2018 10:18:17 AM(UTC)
Groups: Registered
Posts: 3
I am looking at working with password protected PDFs and I am wondering about the following workflow.
Can you determine the if a password protected PDF is print-restricted prior to having the password or do you need to enter have the password before you can access the restricted actions?
#2
Posted
:
Wednesday, January 3, 2018 10:46:29 AM(UTC)
Groups: Registered
Posts: 3
Anthony,
So what would be the workflow?
David
#3
Posted
:
Wednesday, January 3, 2018 11:34:35 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
Hello David,
I was incorrect in my last reply, you can read this information by using the
PDFDocument class. Below is a snippet you can use to print out the security options for a PDF. And to answer your original question, you will need to supply a password before anything can be read about the document.
Code:
string fileName = @"C:\temp\Sample.pdf";
bool encrypted = PDFFile.IsEncrypted(fileName);
string password = null;
if (encrypted)
{
Console.Write("File is encrypted, please enter password: ");
password = Console.ReadLine();
}
PDFDocument document = new PDFDocument(fileName, password);
Console.WriteLine(String.Format("IsEncrypted: {0}", document.IsEncrypted));
if (document.SecurityOptions != null)
{
PDFSecurityOptions o = document.SecurityOptions;
Console.WriteLine("SecurityOptions:");
Console.WriteLine(String.Format("\tAnnotationsEnabled: {0}", o.AnnotationsEnabled));
Console.WriteLine(String.Format("\tAssemblyEnabled: {0}", o.AssemblyEnabled));
Console.WriteLine(String.Format("\tCopyEnabled: {0}", o.CopyEnabled));
Console.WriteLine(String.Format("\tCopyForAccessibilityEnabled: {0}", o.CopyForAccessibilityEnabled));
Console.WriteLine(String.Format("\tEditEnabled: {0}", o.EditEnabled));
Console.WriteLine(String.Format("\tEncryptionMode: {0}", o.EncryptionMode));
Console.WriteLine(String.Format("\tFormFieldFillingEnabled: {0}", o.FormFieldFillingEnabled));
Console.WriteLine(String.Format("\tHighQualityPrintEnabled: {0}", o.HighQualityPrintEnabled));
Console.WriteLine(String.Format("\tOwnerPassword: '{0}'", o.OwnerPassword));
Console.WriteLine(String.Format("\tPrintEnabled: {0}", o.PrintEnabled));
Console.WriteLine(String.Format("\tUserPassword: '{0}'", o.UserPassword));
}
else
{
Console.WriteLine("SecurityOptions: null");
}
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
#4
Posted
:
Wednesday, January 3, 2018 11:49:13 AM(UTC)
Groups: Registered
Posts: 3
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.