Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfParser::SetPassword ( const std::string &  sPassword )

If you try to open an encrypted PDF file, which requires a password to open, PoDoFo will throw a PdfError( ePdfError_InvalidPassword ) exception.

If you got such an exception, you have to set a password which should be used for opening the PDF.

The usual way will be to ask the user for the password and set the password using this method.

PdfParser will immediately continue to read the PDF file.

sPassworda user or owner password which can be used to open an encrypted PDF file If the password is invalid, a PdfError( ePdfError_InvalidPassword ) exception is thrown!

Definition at line 1031 of file PdfParser.cpp.

References PoDoFo::PdfEncrypt::Authenticate(), PoDoFo::PdfError::DebugMessage(), PoDoFo::ePdfError_InternalLogic, PoDoFo::ePdfError_InvalidPassword, GetDocumentId(), PODOFO_RAISE_ERROR_INFO, and ReadObjectsInternal().

Referenced by PoDoFo::PdfMemDocument::SetPassword().

    if( !m_pEncrypt ) 
        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Cannot set password for unencrypted PDF." );

    bool bAuthenticate = m_pEncrypt->Authenticate( sPassword, this->GetDocumentId() ); 
    if( !bAuthenticate ) 
        PdfError::DebugMessage("Authentication with user password failed\n" );
        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidPassword, "Authentication with user specified password failed.");

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index