本文整理汇总了C++中PdfObject::IsDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ PdfObject::IsDictionary方法的具体用法?C++ PdfObject::IsDictionary怎么用?C++ PdfObject::IsDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfObject
的用法示例。
在下文中一共展示了PdfObject::IsDictionary方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void PdfeFontType3::initGlyphs( const PdfObject* pFont )
{
// CharProcs and Resources objects.
PdfObject* pCharProcs = pFont->GetIndirectKey( "CharProcs" );
PdfObject* pResources = pFont->GetIndirectKey( "Resources" );
// No CharProcs: exception raised.
if( !pCharProcs || !pCharProcs->IsDictionary() ) {
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Entries missing in the Type 3 font dictionary." );
}
// Resize space vectors.
m_mapCIDToGID.resize( m_lastCID-m_firstCID+1, 0 );
m_glyphs.resize( m_lastCID-m_firstCID+1, PdfeGlyphType3() );
// Look at each character.
PdfName cname;
PdfObject* pGlyph;
for( pdfe_cid c = m_firstCID ; c <= m_lastCID ; ++c ) {
// Get character name and search it in CharProcs.
cname = this->fromCIDToName( c );
pGlyph = pCharProcs->GetIndirectKey( cname );
// If found, set GID to c-m_firstCID+1 and create glyph.
if( pGlyph ) {
m_mapCIDToGID[c-m_firstCID] = c-m_firstCID+1;
m_glyphs[c-m_firstCID] = PdfeGlyphType3( cname, pGlyph, pResources );
}
}
}
示例2: GetFromResources
PdfObject* PdfPage::GetFromResources( const PdfName & rType, const PdfName & rKey )
{
if( m_pResources->GetDictionary().HasKey( rType ) )
{
PdfObject* pType = m_pResources->GetDictionary().GetKey( rType );
if( pType->IsDictionary() && pType->GetDictionary().HasKey( rKey ) )
{
const PdfReference & ref = pType->GetDictionary().GetKey( rKey )->GetReference();
return m_pObject->GetOwner()->GetObject( ref );
}
}
return NULL;
}
示例3: Init
void PdfDestination::Init( PdfObject* pObject, PdfDocument* pDocument )
{
bool bValueExpected = false;
PdfObject* pValue = NULL;
if ( pObject->GetDataType() == ePdfDataType_Array )
{
m_array = pObject->GetArray();
m_pObject = pObject;
}
else if( pObject->GetDataType() == ePdfDataType_String )
{
PdfNamesTree* pNames = pDocument->GetNamesTree( ePdfDontCreateObject );
if( !pNames )
{
PODOFO_RAISE_ERROR( ePdfError_NoObject );
}
pValue = pNames->GetValue( "Dests", pObject->GetString() );
bValueExpected = true;
}
else if( pObject->GetDataType() == ePdfDataType_Name )
{
PdfMemDocument* pMemDoc = dynamic_cast<PdfMemDocument*>(pDocument);
if ( !pMemDoc )
{
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle,
"For reading from a document, only use PdfMemDocument." );
}
PdfObject* pCatalog = pMemDoc->GetCatalog();
if ( !pCatalog )
{
PODOFO_RAISE_ERROR( ePdfError_NoObject );
}
PdfObject* pDests = pCatalog->GetIndirectKey( PdfName( "Dests" ) );
if( !pDests )
{
// The error code has been chosen for its distinguishability.
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidKey,
"No PDF-1.1-compatible destination dictionary found." );
}
pValue = pDests->GetIndirectKey( pObject->GetName() );
bValueExpected = true;
}
else
{
PdfError::LogMessage( eLogSeverity_Error, "Unsupported object given to"
" PdfDestination::Init of type %s", pObject->GetDataTypeString() );
m_array = PdfArray(); // needed to prevent crash on method calls
// needed for GetObject() use w/o checking its return value for NULL
m_pObject = pDocument->GetObjects()->CreateObject( m_array );
}
if ( bValueExpected )
{
if( !pValue )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidName );
}
if( pValue->IsArray() )
m_array = pValue->GetArray();
else if( pValue->IsDictionary() )
m_array = pValue->GetDictionary().GetKey( "D" )->GetArray();
m_pObject = pValue;
}
}
示例4: ReadObjects
void PdfParser::ReadObjects()
{
int i = 0;
PdfParserObject* pObject = NULL;
m_vecObjects->Reserve( m_nNumObjects );
// Check for encryption and make sure that the encryption object
// is loaded before all other objects
if( m_pTrailer->GetDictionary().HasKey( PdfName("Encrypt") ) )
{
#ifdef PODOFO_VERBOSE_DEBUG
PdfError::DebugMessage("The PDF file is encrypted.\n" );
#endif // PODOFO_VERBOSE_DEBUG
PdfObject* pEncrypt = m_pTrailer->GetDictionary().GetKey( PdfName("Encrypt") );
if( pEncrypt->IsReference() )
{
i = pEncrypt->GetReference().ObjectNumber();
pObject = new PdfParserObject( m_vecObjects, m_device, m_buffer, m_offsets[i].lOffset );
pObject->SetLoadOnDemand( m_bLoadOnDemand );
try {
pObject->ParseFile( NULL ); // The encryption dictionary is not encrypted :)
m_vecObjects->push_back( pObject );
m_offsets[i].bParsed = false;
m_pEncrypt = PdfEncrypt::CreatePdfEncrypt( pObject );
} catch( PdfError & e ) {
std::ostringstream oss;
if( pObject )
{
oss << "Error while loading object " << pObject->Reference().ObjectNumber() << " "
<< pObject->Reference().GenerationNumber() << std::endl;
delete pObject;
}
e.AddToCallstack( __FILE__, __LINE__, oss.str().c_str() );
throw e;
}
}
else if( pEncrypt->IsDictionary() )
m_pEncrypt = PdfEncrypt::CreatePdfEncrypt( pEncrypt );
else
{
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidEncryptionDict,
"The encryption entry in the trailer is neither an object nor a reference." );
}
// Generate encryption keys
// Set user password, try first with an empty password
bool bAuthenticate = m_pEncrypt->Authenticate( "", this->GetDocumentId() );
#ifdef PODOFO_VERBOSE_DEBUG
PdfError::DebugMessage("Authentication with empty password: %i.\n", bAuthenticate );
#endif // PODOFO_VERBOSE_DEBUG
if( !bAuthenticate )
{
// authentication failed so we need a password from the user.
// The user can set the password using PdfParser::SetPassword
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidPassword, "A password is required to read this PDF file.");
}
}
ReadObjectsInternal();
}
示例5: if
PdfContentsTokenizer::PdfContentsTokenizer( PdfCanvas* pCanvas )
: PdfTokenizer(), m_readingInlineImgData(false)
{
if( !pCanvas )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
}
PdfObject* pContents = pCanvas->GetContents();
if( pContents && pContents->IsArray() )
{
PdfArray& a = pContents->GetArray();
for ( PdfArray::iterator it = a.begin(); it != a.end() ; ++it )
{
if ( !(*it).IsReference() )
{
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "/Contents array contained non-references" );
}
if ( !pContents->GetOwner()->GetObject( (*it).GetReference() ) )
{
// some damaged PDFs may have dangling references
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "/Contents array NULL reference" );
}
m_lstContents.push_back( pContents->GetOwner()->GetObject( (*it).GetReference() ) );
}
}
else if ( pContents && pContents->HasStream() )
{
m_lstContents.push_back( pContents );
}
else if ( pContents && pContents->IsDictionary() )
{
m_lstContents.push_back( pContents );
PdfError::LogMessage(eLogSeverity_Information,
"PdfContentsTokenizer: found canvas-dictionary without stream => empty page");
// OC 18.09.2010 BugFix: Found an empty page in a PDF document:
// 103 0 obj
// <<
// /Type /Page
// /MediaBox [ 0 0 595 842 ]
// /Parent 3 0 R
// /Resources <<
// /ProcSet [ /PDF ]
// >>
// /Rotate 0
// >>
// endobj
}
else
{
PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Page /Contents not stream or array of streams" );
}
if( m_lstContents.size() )
{
SetCurrentContentsStream( m_lstContents.front() );
m_lstContents.pop_front();
}
}