当前位置: 首页>>代码示例>>C++>>正文


C++ PDFDoc::getPDFMajorVersion方法代码示例

本文整理汇总了C++中PDFDoc::getPDFMajorVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ PDFDoc::getPDFMajorVersion方法的具体用法?C++ PDFDoc::getPDFMajorVersion怎么用?C++ PDFDoc::getPDFMajorVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PDFDoc的用法示例。


在下文中一共展示了PDFDoc::getPDFMajorVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void PDFFormat::init(std::string& filename){
    PDFDoc *doc = PDFDocFactory().createPDFDoc(GooString(filename.c_str()));
    
    //GBool enc = doc->isEncrypted();
    GooString ID;

    Object obj,id_obj;
    Dict* trailer = doc->getXRef()->getTrailerDict()->getDict();
    trailer->lookupNF("ID",&obj);
    
    obj.getArray()->getNF(0,&id_obj);
    data.ID1.assign(id_obj.getString()->getCString(),16);
    
    obj.getArray()->getNF(1,&id_obj);
    data.ID2.assign(id_obj.getString()->getCString(),16);
    
    GBool enc = trailer->hasKey("Encrypt");
    if(enc){
        is_encrypted = true;
        trailer->lookupNF("Encrypt",&obj);
        Object encObj;
        doc->getXRef()->fetch(obj.getRef().num,obj.getRef().gen,&encObj);
        encObj.getDict()->lookupNF("Filter",&obj);
        encObj.getDict()->lookupNF("R",&obj);
        this->data.R = obj.getInt();
        encObj.getDict()->lookupNF("V",&obj);
        this->data.V = obj.getInt();
        encObj.getDict()->lookupNF("P",&obj);
        this->data.P = obj.getInt();
        encObj.getDict()->lookupNF("Length",&obj);
        this->data.length = obj.getInt();
        encObj.getDict()->lookupNF("O",&obj);
        if ((int)this->data.R <= 4) {
            /* Revision 4 or less => 32Byte O string */
            this->data.O.assign(obj.getString()->getCString(),32);
        } else {
            /* Revision 5 or 6 => 48Byte O string */
            this->data.O.assign(obj.getString()->getCString(),48);
            ::memcpy(this->data.O_valid_salt, this->data.O.substr(32, 8).c_str(), 8);
            ::memcpy(this->data.O_key_salt, this->data.O.substr(40, 8).c_str(), 8);
            this->data.O.resize(32);
        }
        encObj.getDict()->lookupNF("U",&obj);
        if ((int)this->data.R <= 4) {
            /* Revision 4 or less => 32Byte U string */
            this->data.U.assign(obj.getString()->getCString(),32);
        } else {
            /* Revision 5 or 6 => 48Byte U string */
            this->data.U.assign(obj.getString()->getCString(),48);
            ::memcpy(this->data.U_valid_salt, this->data.U.substr(32, 8).c_str(), 8);
            ::memcpy(this->data.U_key_salt, this->data.U.substr(40, 8).c_str(), 8);
            this->data.U.resize(32);
        }
        
        if(encObj.getDict()->hasKey("EncryptMetadata")){
            encObj.getDict()->lookupNF("EncryptMetadata", &obj);
            this->data.MetaEncrypted = obj.getBool();
        }
        
        int v_major = doc->getPDFMajorVersion();
        int v_minor = doc->getPDFMinorVersion();
        
        if (verbose) {
            // Print PDF encryption information from EncObj
            std::cout << "======= PDF information =======" << std::endl;
            std::cout << "PDF version: " << v_major << "." << v_minor << std::endl;
            if ((int)this->data.R == 5) {
                std::cout << "Extension level 3 detected." << std::endl;
            } else if ((int)this->data.R == 6) {
                std::cout << "Extension level 5 detected." << std::endl;
            } else if ((int)this->data.R > 6) {
                std::cout << "Warning: Unknown (unsupported) security revision!" << std::endl;
            }
            std::cout << "Security revision: " << (int)this->data.R << std::endl;
            std::cout << "Encryption alg. version: " << (int)this->data.V << std::endl;
            std::cout << "Key length: " << (int)this->data.length << std::endl;
            std::cout << "Metadata encrypted: ";
            if (this->data.MetaEncrypted) {
                std::cout << "yes";
            } else {
                std::cout << "no";
            }
            std::cout << std::endl;
            std::cout << "===============================" << std::endl;
        }
            
            
    }else{
        is_encrypted = false;
    }
    is_supported = true;

}
开发者ID:gazdik,项目名称:bp-wrathion,代码行数:93,代码来源:PDFFormat.cpp


注:本文中的PDFDoc::getPDFMajorVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。