How to put a password in PDF in batch from Visual C++?

Question: Is there any tools or DLL that can encrypt PDF? Example I have 1,000 PDF files I want to put a password on each PDF? The password will be different on each file.

Answer: According to your needs, maybe you can have a free trial of this software:VeryPDF Encrypt PDF COM. By this software, you can encrypt (using standard 40-bit or 128-bit supported by Acrobat Reader 5.0 and up) existing PDF, set permissions, add user and owner password. This software allows you to put a password in the PDF in batch from C++. Please check more related information on homepage, in the following part, I will show you how to use this software.

Step 1. Free download Encrypt PDF COM

  • There are two versions of Encrypt PDF COM: Server License and Developer License. By the server version, you can install this software under the whole server. The developer version is for software companies to integrate it into their own application and redistribute it. With a developer license, you can integrate our product with your application and distribute it with your own application royalty free.
  • When downloading finishes, there will be an zip file. You need to extract it to some folder then you can find related elements to use this software.

Step 2. Encrypt PDF in batch from C++.

  • When you use this software, please refer to the usage and code templates.
  • Here is one example of calling this software from C++ for encrypting PDF.

Here are some parameters for your reference:
inFileName          Input PDF filename
outFileName       Output PDF filename
EnctyptLen         The encryption level, MUST equal 40 or 12
Permission          
Set permission to a pdf document; include printing, copying and changing and enable form fields.
0: no printing, no copying and no changing
4: allow printing
16: allow copying
8: allow changing
32: allow AcroFormFields
For example, if you want allow printing, copying and changing, the permission value should be 4+16+8 = 28

When encrypt PDF in batch from C++, please refer to the following command line templates.

void main()
{
int encyptlevel,permission=0;
char srcpath[_MAX_PATH];
char despath[_MAX_PATH];
BOOL m_bIsSucceed = FALSE;

memset(srcpath,0,_MAX_PATH);
memset(despath,0,_MAX_PATH);

//example 1

GetModulePath(srcpath,"test1.pdf");
GetModulePath(despath,"test1Encrypt.pdf");
encyptlevel=128;
permission=GetPermission(TRUE,TRUE,TRUE,TRUE);
veryEncryptPDF(srcpath,despath,encyptlevel,permission,
"owner","user");
m_bIsSucceed = veryTestEncryptedPDF(despath,"owner","user");

//example 2

GetModulePath(srcpath,"test2.pdf");
GetModulePath(despath,"test2Encrypt.pdf");
encyptlevel=40;
permission=GetPermission(FALSE,FALSE,FALSE,FALSE);
veryEncryptPDF(srcpath,despath,encyptlevel,permission,
"owner","user");
m_bIsSucceed = veryTestEncryptedPDF(despath,
"owner","user");
}

If you need to check more code templates, please visit usage documentation. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!