/*
//
// ADOBE SYSTEMS INCORPORATED
// Copyright (C) 2000-2003 Adobe Systems Incorporated
// All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file
// in accordance with the terms of the Adobe license agreement
// accompanying it. If you have received this file from a source other
// than Adobe, then your use, modification, or distribution of it
// requires the prior written permission of Adobe.
//
*/
/*
//
// DecryptionMain.cpp
//
// This sample demonstrates handling of an encrypted PDF document.
//
// The test PDF document is encrypted using Acrobat Standard Security
// with 256-bit AES encryption and all applicable permissions denied.
//
// - Specifically it illustrates authorizing document open permission
// with the PDAuthProcEx callback (called by PDDocOpenEx), which
// requires the user password.
//
//- To demonstrate PDF 2.0 unicode based password support,user password for test document
//is stored in user-password.txt file as an utf-16 big endian with BOM string.
//
// - It also illustrates authorizing permissions to operate on the
// contents of the encrypted document, which requires the master
// password.
//
// The operation performed on the content is simply reversing the
// page order (content extraction and document assembly).
//
*/
#include <iostream>
#include "Decryption.h"
#include "MyPDFLibUtils.h"
using namespace std;
int main();
// sample entry point
int main()
{
INIT_AUTO_POOL(autoReleasePool); /* Required only on MAC platform */
/* relative path to this samples ExampleFiles directory for Mac and Win */
const char *encryptedDoc = "../ExampleFiles/encrypted.pdf" ; /* input file */
const char *decryptedDoc = "../ExampleFiles/decrypted.pdf" ; /* output file */
ASErrorCode errCode = 0;
int err = MyPDFLInit(); // initialize the PDFLib
if (err != 0) // check for error after initialization
{
cerr << "Initialization error. See \"AcroErr.h\" for more info.\n" << endl;
cerr << "Error system: " <<
ErrGetSystem(err) << endl;
cerr << "Error Severity: " <<
ErrGetSeverity(err) << endl;
cerr << "Error Code: " <<
ErrGetCode(err) << endl;
}
else
{
Decryption *theSample =
NULL;
DURING
// Seek open permission on the encrypted document
theSample = new Decryption(encryptedDoc);
// request permission to operate on document
if (theSample->ClientAuthMasterProc())
{
/* operate on document */
theSample->ProcessDocument(decryptedDoc);
}
HANDLER
errCode =
ERRORCODE;
END_HANDLER;
if (errCode)
DisplayError(errCode);
if (theSample) delete theSample;
MyPDFLTerm();
}
RELEASE_AUTO_POOL(autoReleasePool); /* Required only on MAC platform */
return 0;
}