本文整理汇总了C++中PdfObject::IsName方法的典型用法代码示例。如果您正苦于以下问题:C++ PdfObject::IsName方法的具体用法?C++ PdfObject::IsName怎么用?C++ PdfObject::IsName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfObject
的用法示例。
在下文中一共展示了PdfObject::IsName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getCSType
PDFColorSpace PDFAnalyzer::getCSType(PdfObject* cs)
{
try {
// colorspace is either a name or an array
if (cs && cs->IsName())
{
PdfName csName = cs->GetName();
if (csName == "DeviceGray")
return CS_DeviceGray;
else if (csName == "DeviceRGB")
return CS_DeviceRGB;
else if (csName == "DeviceCMYK")
return CS_DeviceCMYK;
}
else if (cs && cs->IsArray())
{
PdfArray csArr = cs->GetArray();
PdfObject csTypePdfName = csArr[0];
if (csTypePdfName.IsName())
{
PdfName csTypeName = csTypePdfName.GetName();
if (csTypeName == "ICCBased")
return CS_ICCBased;
else if (csTypeName == "CalGray")
return CS_CalGray;
else if (csTypeName == "CalRGB")
return CS_CalRGB;
else if (csTypeName == "Lab")
return CS_Lab;
else if (csTypeName == "Indexed")
{
PdfObject base = cs->GetArray()[1];
PdfObject* pBase = &base;
if (base.IsReference())
{
pBase = cs->GetOwner()->GetObject(base.GetReference());
}
pBase->SetOwner(cs->GetOwner());
return getCSType(pBase);
}
else if (csTypeName == "Separation")
return CS_Separation;
else if (csTypeName == "DeviceN")
return CS_DeviceN;
else if (csTypeName == "Pattern")
return CS_Pattern;
}
}
}
catch (PdfError & e)
{
qDebug() << "Error in identifying the color type";
e.PrintErrorMsg();
return CS_Unknown;
}
return CS_Unknown;
}
示例3: start
void PDFProcessor::start ()
{
int nNum = 0;
try
{
PdfObject* pObj = NULL;
// open document
qDebug() << "Opening file: " << filename.toStdString().c_str();
PdfMemDocument document( filename.toStdString().c_str() );
// m_pszOutputDirectory = const_cast<char*>(pszOutput);
TCIVecObjects it = document.GetObjects().begin();
while( it != document.GetObjects().end() )
{
if( (*it)->IsDictionary() )
{
PdfObject* pObjType = (*it)->GetDictionary().GetKey( PdfName::KeyType );
PdfObject* pObjSubType = (*it)->GetDictionary().GetKey( PdfName::KeySubtype );
if( ( pObjType && pObjType->IsName() && ( pObjType->GetName().GetName() == "XObject" ) ) ||
( pObjSubType && pObjSubType->IsName() && ( pObjSubType->GetName().GetName() == "Image" ) ) )
{
pObj = (*it)->GetDictionary().GetKey( PdfName::KeyFilter );
if( pObj && pObj->IsArray() && pObj->GetArray().GetSize() == 1 &&
pObj->GetArray()[0].IsName() && (pObj->GetArray()[0].GetName().GetName() == "DCTDecode") )
pObj = &pObj->GetArray()[0];
std::string filterName = pObj->GetName().GetName();
bool processed = 0;
if( pObj && pObj->IsName() && ( filterName == "DCTDecode" ) )
{
// The only filter is JPEG -> create a JPEG file
qDebug() << "JPG found.\n";
processed = true;
nNum++;
}
if( pObj && pObj->IsName() && ( filterName == "JPXDecode" ) )
{
// The only filter is JPEG -> create a JPEG file
qDebug() << "JPG found.\n";
processed = true;
nNum++;
}
if( pObj && pObj->IsName() && ( filterName == "FlateDecode" ) )
{
// The only filter is JPEG -> create a JPEG file
qDebug() << "JPG found.\n";
processed = true;
nNum++;
}
// else we found something strange, we do not care about it for now.
if (processed == false)
{
qDebug() << "Unknown image type found:" << QString::fromStdString(filterName) << "\n";
nNum++;
}
document.FreeObjectMemory( *it );
}
}
++it;
}
}
catch( PdfError & e )
{
qDebug() << "Error: An error ocurred during processing the pdf file:" << e.GetError();
e.PrintErrorMsg();
return;// e.GetError();
}
// TODO: statistics of no of images etc
// nNum = extractor.GetNumImagesExtracted();
qDebug() << "Extracted " << nNum << " images successfully from the PDF file.\n";
}
示例4: FlateCompress
void PdfMemStream::FlateCompress()
{
PdfObject* pObj;
PdfVariant vFilter( PdfName("FlateDecode" ) );
PdfVariant vFilterList;
PdfArray tFilters;
PdfArray::const_iterator tciFilters;
if( !m_lLength )
return; // ePdfError_ErrOk
// TODO: Handle DecodeParms
if( m_pParent->GetDictionary().HasKey( "Filter" ) )
{
pObj = m_pParent->GetIndirectKey( "Filter" );
if( pObj->IsName() )
{
if( pObj->GetName() != "DCTDecode" && pObj->GetName() != "FlateDecode" )
{
tFilters.push_back( vFilter );
tFilters.push_back( *pObj );
}
}
else if( pObj->IsArray() )
{
tciFilters = pObj->GetArray().begin();
while( tciFilters != pObj->GetArray().end() )
{
if( (*tciFilters).IsName() )
{
// do not compress DCTDecoded are already FlateDecoded streams again
if( (*tciFilters).GetName() == "DCTDecode" || (*tciFilters).GetName() == "FlateDecode" )
{
return;
}
}
++tciFilters;
}
tFilters.push_back( vFilter );
tciFilters = pObj->GetArray().begin();
while( tciFilters != pObj->GetArray().end() )
{
tFilters.push_back( (*tciFilters) );
++tciFilters;
}
}
else
return;
vFilterList = PdfVariant( tFilters );
m_pParent->GetDictionary().AddKey( "Filter", vFilterList );
FlateCompressStreamData(); // throws an exception on error
}
else
{
m_pParent->GetDictionary().AddKey( "Filter", PdfName( "FlateDecode" ) );
FlateCompressStreamData();
}
}
示例5: inspectExtGStateObj
void PDFAnalyzer::inspectExtGStateObj(PdfObject* extGStateObj, QList<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, PDFGraphicState & currGS)
{
PdfObject* bmObj = extGStateObj->GetIndirectKey("BM");
if (bmObj && bmObj->IsName())
{
currGS.blendModes.clear();
currGS.blendModes.append(bmObj->GetName().GetEscapedName().c_str());
if (!(bmObj->GetName() == "Normal" || bmObj->GetName() == "Compatible"))
hasTransparency = true;
}
else if (bmObj && bmObj->IsArray())
{
PdfArray arr = bmObj->GetArray();
currGS.blendModes.clear();
for(int i=0; i<arr.GetSize(); ++i)
currGS.blendModes.append(arr[i].GetName().GetEscapedName().c_str());
if (arr[0].IsName() && !(arr[0].GetName() == "Normal" || arr[0].GetName() == "Compatible"))
hasTransparency = true;
}
PdfObject* caObj = extGStateObj->GetIndirectKey("ca");
if (caObj && (caObj->IsReal() || caObj->IsNumber()))
{
currGS.fillAlphaConstant = caObj->GetReal();
if (caObj->GetReal() < 1)
hasTransparency = true;
}
PdfObject* cAObj = extGStateObj->GetIndirectKey("CA");
if (cAObj && (cAObj->IsReal() || cAObj->IsNumber()))
{
if (cAObj->GetReal() < 1)
hasTransparency = true;
}
PdfObject* sMaskObj = extGStateObj->GetIndirectKey("SMask");
if (sMaskObj && !(sMaskObj->IsName() && sMaskObj->GetName() == "None"))
hasTransparency = true;
PdfObject* fontObj = extGStateObj->GetIndirectKey("Font");
if (fontObj && fontObj->IsArray())
{
PdfArray arr = fontObj->GetArray();
if (arr[0].IsReference())
{
PdfReference ref = arr[0].GetReference();
PdfObject* fontObject = m_doc->GetObjects().GetObject(ref);
if (fontObject)
{
PDFFont font = getFontInfo(fontObject);
usedFonts.append(font);
currGS.font.first = font;
currGS.font.second = arr[1].GetReal();
}
}
}
PdfObject* lwObj = extGStateObj->GetIndirectKey("LW");
if (lwObj)
currGS.lineWidth = lwObj->GetReal();
PdfObject* lcObj = extGStateObj->GetIndirectKey("LC");
if (lcObj)
currGS.lineCap = lcObj->GetNumber();
PdfObject* ljObj = extGStateObj->GetIndirectKey("LJ");
if (ljObj)
currGS.lineJoin = ljObj->GetNumber();
PdfObject* mlObj = extGStateObj->GetIndirectKey("ML");
if (mlObj)
currGS.miterLimit = mlObj->GetReal();
PdfObject* dObj = extGStateObj->GetIndirectKey("D");
if (dObj)
{
PdfArray dashArr = dObj->GetArray()[0];
currGS.dashPattern.first.clear();
for (int i=0; i<dashArr.GetSize(); ++i)
currGS.dashPattern.first.append(dashArr[i].GetNumber());
currGS.dashPattern.second = dObj->GetArray()[1].GetNumber();
}
}
示例6: inspectCanvas
//.........这里部分代码省略.........
if (!usedColorSpaces.contains(CS_DeviceRGB))
usedColorSpaces.append(CS_DeviceRGB);
currGS.fillCS = CS_DeviceRGB;
currGS.fillColor.clear();
for (int i=0; i<args.size(); ++i)
currGS.fillColor.append(args[i].GetReal());
break;
case KW_RG:
if (!usedColorSpaces.contains(CS_DeviceRGB))
usedColorSpaces.append(CS_DeviceRGB);
currGS.strokeCS = CS_DeviceRGB;
currGS.strokeColor.clear();
for (int i=0; i<args.size(); ++i)
currGS.strokeColor.append(args[i].GetReal());
break;
case KW_k:
if (!usedColorSpaces.contains(CS_DeviceCMYK))
usedColorSpaces.append(CS_DeviceCMYK);
currGS.fillCS = CS_DeviceCMYK;
currGS.fillColor.clear();
for (int i=0; i<args.size(); ++i)
currGS.fillColor.append(args[i].GetReal());
break;
case KW_K:
if (!usedColorSpaces.contains(CS_DeviceCMYK))
usedColorSpaces.append(CS_DeviceCMYK);
currGS.strokeCS = CS_DeviceCMYK;
currGS.strokeColor.clear();
for (int i=0; i<args.size(); ++i)
currGS.strokeColor.append(args[i].GetReal());
break;
case KW_cs:
{
if (args.size() == 1 && args[0].IsName())
{
if (args[0].GetName() == "DeviceGray")
{
currGS.fillCS = CS_DeviceGray;
currGS.fillColor.clear();
currGS.fillColor.append(0);
if (!usedColorSpaces.contains(CS_DeviceGray))
usedColorSpaces.append(CS_DeviceGray);
}
else if (args[0].GetName() == "DeviceRGB")
{
currGS.fillCS = CS_DeviceRGB;
currGS.fillColor.clear();
for (int i=0; i<3; ++i)
currGS.fillColor.append(0);
if (!usedColorSpaces.contains(CS_DeviceRGB))
usedColorSpaces.append(CS_DeviceRGB);
}
else if (args[0].GetName() == "DeviceCMYK")
{
currGS.fillCS = CS_DeviceCMYK;
currGS.fillColor.clear();
for (int i=0; i<3; ++i)
currGS.fillColor.append(0);
currGS.fillColor.append(1);
if (!usedColorSpaces.contains(CS_DeviceCMYK))
usedColorSpaces.append(CS_DeviceCMYK);
}
else if (args[0].GetName() == "Pattern")
{
currGS.fillCS = CS_Pattern;
if (!usedColorSpaces.contains(CS_Pattern))
示例7: ReadXRefStreamContents
void PdfParser::ReadXRefStreamContents( pdf_long lOffset, bool bReadOnlyTrailer )
{
char* pBuffer;
char* pStart;
pdf_long lBufferLen;
long long lSize = 0;
PdfVariant vWArray;
PdfObject* pObj;
long nW[W_ARRAY_SIZE] = { 0, 0, 0 };
int i;
m_device.Device()->Seek( lOffset );
PdfParserObject xrefObject( m_vecObjects, m_device, m_buffer );
// Ignore the encryption in the XREF as the XREF stream must no be encrypted (see PDF Reference 3.4.7)
xrefObject.ParseFile( NULL );
if( !xrefObject.GetDictionary().HasKey( PdfName::KeyType ) )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
pObj = xrefObject.GetDictionary().GetKey( PdfName::KeyType );
if( !pObj->IsName() || ( pObj->GetName() != "XRef" ) )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
if( !m_pTrailer )
m_pTrailer = new PdfParserObject( m_vecObjects, m_device, m_buffer );
MergeTrailer( &xrefObject );
if( bReadOnlyTrailer )
return;
if( !xrefObject.GetDictionary().HasKey( PdfName::KeySize ) || !xrefObject.GetDictionary().HasKey( "W" ) )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
lSize = xrefObject.GetDictionary().GetKeyAsLong( PdfName::KeySize, 0 );
vWArray = *(xrefObject.GetDictionary().GetKey( "W" ));
// The pdf reference states that W is always an array with 3 entries
// all of them have to be integeres
if( !vWArray.IsArray() || vWArray.GetArray().size() != 3 )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
for( i=0;i<W_ARRAY_SIZE;i++ )
{
if( !vWArray.GetArray()[i].IsNumber() )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
nW[i] = static_cast<long>(vWArray.GetArray()[i].GetNumber());
}
std::vector<long long> vecIndeces;
// get the first object number in this crossref stream.
// it is not required to have an index key though.
if( xrefObject.GetDictionary().HasKey( "Index" ) )
{
// reuse vWArray!!
vWArray = *(xrefObject.GetDictionary().GetKey( "Index" ));
if( !vWArray.IsArray() )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
TCIVariantList it = vWArray.GetArray().begin();
while ( it != vWArray.GetArray().end() )
{
vecIndeces.push_back( (*it).GetNumber() );
++it;
}
}
else
{
vecIndeces.push_back( 0 );
vecIndeces.push_back( lSize );
}
if( vecIndeces.size() % 2 )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
if( !xrefObject.HasStreamToParse() )
{
PODOFO_RAISE_ERROR( ePdfError_NoXRef );
}
xrefObject.GetStream()->GetFilteredCopy( &pBuffer, &lBufferLen );
pStart = pBuffer;
//.........这里部分代码省略.........