本文整理汇总了C++中PdfObject::GetIndirectKey方法的典型用法代码示例。如果您正苦于以下问题:C++ PdfObject::GetIndirectKey方法的具体用法?C++ PdfObject::GetIndirectKey怎么用?C++ PdfObject::GetIndirectKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfObject
的用法示例。
在下文中一共展示了PdfObject::GetIndirectKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPageNumber
unsigned int PdfPage::GetPageNumber() const
{
unsigned int nPageNumber = 0;
PdfObject* pParent = m_pObject->GetIndirectKey( "Parent" );
PdfReference ref = m_pObject->Reference();
while( pParent )
{
const PdfArray& kids = pParent->GetIndirectKey( "Kids" )->GetArray();
PdfArray::const_iterator it = kids.begin();
while( it != kids.end() && (*it).GetReference() != ref )
{
PdfObject* pNode = m_pObject->GetOwner()->GetObject( (*it).GetReference() );
if( pNode->GetDictionary().GetKey( PdfName::KeyType )->GetName() == PdfName( "Pages" ) )
nPageNumber += static_cast<int>(pNode->GetDictionary().GetKey( "Count" )->GetNumber());
else
// if we do not have a page tree node,
// we most likely have a page object:
// so the page count is 1
++nPageNumber;
++it;
}
ref = pParent->Reference();
pParent = pParent->GetIndirectKey( "Parent" );
}
return ++nPageNumber;
}
示例2: getFontInfo
PDFFont PDFAnalyzer::getFontInfo(PdfObject* fontObj)
{
PDFFont currFont;
PdfObject* subtype = fontObj->GetIndirectKey("Subtype");
if (subtype && subtype->IsName())
{
PdfObject* fontDesc = fontObj->GetIndirectKey("FontDescriptor");
if (subtype->GetName() == "Type1")
currFont.fontType = F_Type1;
else if (subtype->GetName() == "MMType1")
currFont.fontType = F_MMType1;
else if (subtype->GetName() == "TrueType")
currFont.fontType = F_TrueType;
else if (subtype->GetName() == "Type3")
{
currFont.fontType = F_Type3;
currFont.isEmbedded = true;
fontDesc = NULL;
}
else if (subtype->GetName() == "Type0")
{
PdfObject* descendantFonts = fontObj->GetIndirectKey("DescendantFonts");
if (descendantFonts && descendantFonts->IsArray())
{
PdfObject descendantFont = descendantFonts->GetArray()[0];
descendantFont.SetOwner(descendantFonts->GetOwner());
PdfObject* subtypeDescFont = descendantFont.GetIndirectKey("Subtype");
fontDesc = descendantFont.MustGetIndirectKey("FontDescriptor");
if (subtypeDescFont && subtypeDescFont->IsName())
{
if (subtypeDescFont->GetName() == "CIDFontType0")
currFont.fontType = F_CIDFontType0;
else if (subtypeDescFont->GetName() == "CIDFontType2")
currFont.fontType = F_CIDFontType2;
}
}
}
if (fontDesc)
{
PdfObject* fontFile = fontDesc->GetIndirectKey("FontFile");
PdfObject* fontFile2 = fontDesc->GetIndirectKey("FontFile2");
PdfObject* fontFile3 = fontDesc->GetIndirectKey("FontFile3");
if (fontFile && fontFile->HasStream())
currFont.isEmbedded = true;
if (fontFile2 && fontFile2->HasStream())
currFont.isEmbedded = true;
if (fontFile3 && fontFile3->HasStream())
{
currFont.isEmbedded = true;
PdfObject* ff3Subtype = fontFile3->GetIndirectKey("Subtype");
if (ff3Subtype && ff3Subtype->IsName() && ff3Subtype->GetName() == "OpenType")
currFont.isOpenType = true;
}
}
}
return currFont;
}
示例3:
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 );
}
}
}
示例4: 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;
}
}
示例5: CreateFont
PdfFont* PdfFontFactory::CreateFont( FT_Library*, PdfObject* pObject )
{
PdfFontMetrics* pMetrics = NULL;
PdfFont* pFont = NULL;
PdfObject* pDescriptor = NULL;
PdfObject* pEncoding = NULL;
if( pObject->GetDictionary().GetKey( PdfName::KeyType )->GetName() != PdfName("Font") )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
const PdfName & rSubType = pObject->GetDictionary().GetKey( PdfName::KeySubtype )->GetName();
if( rSubType == PdfName("Type0") )
{
// The PDF reference states that DescendantFonts must be an array,
// some applications (e.g. MS Word) put the array into an indirect object though.
const PdfArray & descendant =
pObject->GetIndirectKey( "DescendantFonts" )->GetArray();
PdfObject* pFontObject = pObject->GetOwner()->GetObject( descendant[0].GetReference() );
pDescriptor = pFontObject->GetIndirectKey( "FontDescriptor" );
pEncoding = pObject->GetIndirectKey( "Encoding" );
if ( pEncoding && pDescriptor ) // OC 18.08.2010: Avoid sigsegv
{
const PdfEncoding* const pPdfEncoding =
PdfEncodingObjectFactory::CreateEncoding( pEncoding );
// OC 15.08.2010 BugFix: Parameter pFontObject added: TODO: untested
pMetrics = new PdfFontMetricsObject( pFontObject, pDescriptor, pPdfEncoding );
pFont = new PdfFontCID( pMetrics, pPdfEncoding, pObject, false );
}
}
else if( rSubType == PdfName("Type1") )
{
// TODO: Old documents do not have a FontDescriptor for
// the 14 standard fonts. This suggestions is
// deprecated now, but give us problems with old documents.
pDescriptor = pObject->GetIndirectKey( "FontDescriptor" );
pEncoding = pObject->GetIndirectKey( "Encoding" );
// OC 13.08.2010: Handle missing FontDescriptor for the 14 standard fonts:
if( !pDescriptor )
{
// Check if its a PdfFontType1Base14
PdfObject* pBaseFont = NULL;
pBaseFont = pObject->GetIndirectKey( "BaseFont" );
const char* pszBaseFontName = pBaseFont->GetName().GetName().c_str();
PdfFontMetricsBase14* pMetrics = PODOFO_Base14FontDef_FindBuiltinData(pszBaseFontName);
if ( pMetrics != NULL )
{
// pEncoding may be undefined, found a valid pdf with
// 20 0 obj
// <<
// /Type /Font
// /BaseFont /ZapfDingbats
// /Subtype /Type1
// >>
// endobj
// If pEncoding is null then
// use StandardEncoding for Courier, Times, Helvetica font families
// and special encodings for Symbol and ZapfDingbats
const PdfEncoding* pPdfEncoding = NULL;
if ( pEncoding!= NULL )
pPdfEncoding = PdfEncodingObjectFactory::CreateEncoding( pEncoding );
else if ( !pMetrics->IsSymbol() )
pPdfEncoding = PdfEncodingFactory::GlobalStandardEncodingInstance();
else if ( strcmp(pszBaseFontName, "Symbol") == 0 )
pPdfEncoding = PdfEncodingFactory::GlobalSymbolEncodingInstance();
else if ( strcmp(pszBaseFontName, "ZapfDingbats") == 0 )
pPdfEncoding = PdfEncodingFactory::GlobalZapfDingbatsEncodingInstance();
return new PdfFontType1Base14(pMetrics, pPdfEncoding, pObject);
}
}
const PdfEncoding* pPdfEncoding = NULL;
if ( pEncoding != NULL )
pPdfEncoding = PdfEncodingObjectFactory::CreateEncoding( pEncoding );
else if ( pDescriptor )
{
// OC 18.08.2010 TODO: Encoding has to be taken from the font's built-in encoding
// Its extremely complicated to interpret the type1 font programs
// so i try to determine if its a symbolic font by reading the FontDescriptor Flags
// Flags & 4 --> Symbolic, Flags & 32 --> Nonsymbolic
pdf_int32 lFlags = static_cast<pdf_int32>(pDescriptor->GetDictionary().GetKeyAsLong( "Flags", 0L ));
if ( lFlags & 32 ) // Nonsymbolic, otherwise pEncoding remains NULL
pPdfEncoding = PdfEncodingFactory::GlobalStandardEncodingInstance();
}
if ( pPdfEncoding && pDescriptor ) // OC 18.08.2010: Avoid sigsegv
{
// OC 15.08.2010 BugFix: Parameter pObject added:
pMetrics = new PdfFontMetricsObject( pObject, pDescriptor, pPdfEncoding );
pFont = new PdfFontType1( pMetrics, pPdfEncoding, pObject );
}
}
else if( rSubType == PdfName("TrueType") )
{
pDescriptor = pObject->GetIndirectKey( "FontDescriptor" );
pEncoding = pObject->GetIndirectKey( "Encoding" );
//.........这里部分代码省略.........
示例6: inspectCanvas
bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, QList<PDFImage> & imgs)
{
// this method can be used to get used color spaces, detect transparency, and get used fonts in either PdfPage or PdfXObject
PdfObject* colorSpaceRes;
PdfObject* xObjects;
PdfObject* transGroup;
PdfObject* extGState;
PdfObject* fontRes;
QMap<PdfName, PDFColorSpace> processedNamedCS;
QMap<PdfName, PDFFont> processedNamedFont;
QList<PdfName> processedNamedXObj;
QList<PdfName> processedNamedGS;
try {
// get hold of a PdfObject pointer of this canvas
// needed for the finding resources code below to work
PdfPage* page = dynamic_cast<PdfPage*>(canvas);
PdfObject* canvasObject = page?(page->GetObject()):((dynamic_cast<PdfXObject*>(canvas))->GetObject());
// find a resource with ColorSpace entry
PdfObject* resources = canvas->GetResources();
for (PdfObject* par = canvasObject; par && !resources; par = par->GetIndirectKey("Parent"))
{
resources = par->GetIndirectKey("Resources");
}
colorSpaceRes = resources?resources->GetIndirectKey("ColorSpace"):NULL;
xObjects = resources?resources->GetIndirectKey("XObject"):NULL;
extGState = resources?resources->GetIndirectKey("ExtGState"):NULL;
fontRes = resources?resources->GetIndirectKey("Font"):NULL;
// getting the transparency group of this content stream (if available)
transGroup = canvasObject?canvasObject->GetIndirectKey("Group"):NULL;
if (transGroup)
{
PdfObject* subtype = transGroup->GetIndirectKey("S");
if (subtype && subtype->GetName() == "Transparency")
{
// having transparency group means there's transparency in the PDF
hasTransparency = true;
// reporting the color space used in transparency group (Section 7.5.5, PDF 1.6 Spec)
PdfObject* cs = transGroup->GetIndirectKey("CS");
if (cs)
{
PDFColorSpace retval = getCSType(cs);
if (retval != CS_Unknown && !usedColorSpaces.contains(retval))
usedColorSpaces.append(retval);
}
}
}
}
catch (PdfError & e)
{
qDebug() << "Error in analyzing stream's resources.";
e.PrintErrorMsg();
return false;
}
try {
// start parsing the content stream
PdfContentsTokenizer tokenizer(canvas);
EPdfContentsType t;
const char * kwText;
PdfVariant var;
bool readToken;
int tokenNumber = 0;
QList<PdfVariant> args;
bool inlineImgDict = false;
QStack<PDFGraphicState> gsStack;
PDFGraphicState currGS;
while ((readToken = tokenizer.ReadNext(t, kwText, var)))
{
++tokenNumber;
if (t == ePdfContentsType_Variant)
{
args.append(var);
}
else if (t == ePdfContentsType_Keyword)
{
QString kw(kwText);
switch(kwNameMap.value(kw, KW_Undefined))
{
case KW_q:
gsStack.push(currGS);
break;
case KW_Q:
currGS = gsStack.pop();
break;
case KW_cm:
{
if (args.size() == 6)
{
double mt[6];
for (int i=0; i<6; ++i)
{
mt[i] = args[i].GetReal();
}
QMatrix transMatrix(mt[0], mt[1], mt[2], mt[3], mt[4], mt[5]);
currGS.ctm = transMatrix*currGS.ctm;
}
//.........这里部分代码省略.........