Home > Back-end >  Delphi how to set up the PDF file open password
Delphi how to set up the PDF file open password

Time:11-15

Is there a master know, to help give directions,
Is to generate a PDF file, and set it to open the file password, need to input this password when open the PDF file can be opened,
Java has the method, but the Delphi has been to find resources, help, thank you!

Java method is as follows:


Import the Java. Util. Enumsets.

The import com. Spire. PDF. PdfDocument;

The import com. Spire. PDF. Security. PdfEncryptionKeySize;

The import com. Spire. PDF. Security. PdfPermissionsFlags;

Public class EncryptPDF {

Public static void main (String [] args) {

//create PdfDocument instance

PdfDocument doc=new PdfDocument ();

//load the PDF files

Doc. LoadFromFile (" sample PDF ");

//encrypted PDF files

PdfEncryptionKeySize keySize=PdfEncryptionKeySize. Key_128_Bit;

String openPassword="123456";

String permissionPassword="test";

Enumsets flags=enumsets. Of (PdfPermissionsFlags. Print, PdfPermissionsFlags Fill_Fields);

Doc. GetSecurity (). Encrypt (openPassword permissionPassword, flags, keySize);

//save the file

Doc. SaveToFile (" Encrypt PDF ");

Doc. The close ();

}

}

After completion of the code to run the program, document, open the document at this time to enter the password, can enter the password that was open the document, is only used to view the document; For permissions password, can edit a document,

CodePudding user response:

Aspose JDK can do this, but Aspose is open source software in business, you need to License
Can to look it's website: https://www.evget.com/article/2012/9/10/17476.html
Then did baidu the hack it

CodePudding user response:

Aspose JDK is cross-platform, independent running environment, do not need Office or a third party plug-in support, you can use the XE call JAR package, also can realize cross-platform

CodePudding user response:

Ok, I try to see, I am D7, don't know way no, thank you!
  • Related