本文整理汇总了C++中PdfArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ PdfArray::size方法的具体用法?C++ PdfArray::size怎么用?C++ PdfArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfArray
的用法示例。
在下文中一共展示了PdfArray::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertPagesIntoNode
void PdfPagesTree::InsertPagesIntoNode( PdfObject* pParent, const PdfObjectList & rlstParents,
int nIndex, const std::vector<PdfObject*>& vecPages )
{
if( !pParent || !vecPages.size() )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
}
// 1. Add the reference of the new page to the kids array of pParent
// 2. Increase count of every node in lstParents (which also includes pParent)
// 3. Add Parent key to the page
// 1. Add reference
const PdfArray oldKids = pParent->GetDictionary().GetKey( PdfName("Kids") )->GetArray();
PdfArray newKids;
newKids.reserve( oldKids.GetSize() + vecPages.size() );
bool bIsPushedIn = false;
int i=0;
for (PdfArray::const_iterator it=oldKids.begin(); it!=oldKids.end(); ++it, ++i )
{
if ( !bIsPushedIn && (nIndex < i) ) // Pushing before
{
for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
{
newKids.push_back( (*itPages)->Reference() ); // Push all new kids at once
}
bIsPushedIn = true;
}
newKids.push_back( *it ); // Push in the old kids
}
// If new kids are still not pushed in then they may be appending to the end
if ( !bIsPushedIn && ( (nIndex + 1) == static_cast<int>(oldKids.size())) )
{
for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
{
newKids.push_back( (*itPages)->Reference() ); // Push all new kids at once
}
bIsPushedIn = true;
}
pParent->GetDictionary().AddKey( PdfName("Kids"), newKids );
// 2. increase count
for ( PdfObjectList::const_reverse_iterator itParents = rlstParents.rbegin(); itParents != rlstParents.rend(); ++itParents )
{
this->ChangePagesCount( *itParents, vecPages.size() );
}
// 3. add parent key to each of the pages
for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
{
(*itPages)->GetDictionary().AddKey( PdfName("Parent"), pParent->Reference() );
}
}
示例2: SetBorderStyle
void PdfAnnotation::SetBorderStyle( double dHCorner, double dVCorner, double dWidth, const PdfArray & rStrokeStyle )
{
// TODO : Support for Border style for PDF Vers > 1.0
PdfArray aValues;
aValues.push_back(dHCorner);
aValues.push_back(dVCorner);
aValues.push_back(dWidth);
if( rStrokeStyle.size() )
aValues.push_back(rStrokeStyle);
m_pObject->GetDictionary().AddKey( "Border", aValues );
}
示例3: CreateWidth
void PdfFontCID::CreateWidth( PdfObject* pFontDict ) const
{
const int cAbsoluteMax = 0xffff;
int nFirstChar = m_pEncoding->GetFirstChar();
int nLastChar = m_pEncoding->GetLastChar();
int i;
// Allocate an initialize an array, large enough to
// hold a width value for every possible glyph index
double* pdWidth = static_cast<double*>(malloc( sizeof(double) * cAbsoluteMax ) );
if( !pdWidth )
{
PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
}
for( i=0;i<cAbsoluteMax;i++ )
pdWidth[i] = 0.0;
// Load the width of all requested glyph indeces
int nMin = 0xffff;
int nMax = 0;
long lGlyph = 0;
for( i=nFirstChar;i<=nLastChar;i++ )
{
lGlyph = m_pMetrics->GetGlyphId( i );
if( lGlyph )
{
nMin = PDF_MIN( static_cast<long>(nMin), lGlyph );
nMax = PDF_MAX( static_cast<long>(nMax), lGlyph );
nMax = PDF_MIN( nMax, cAbsoluteMax );
if( lGlyph < cAbsoluteMax )
pdWidth[lGlyph] = m_pMetrics->GetGlyphWidth( lGlyph );
}
}
if (nMax >= nMin) {
// Now compact the array
std::ostringstream oss;
PdfArray array;
array.reserve( nMax - nMin + 1 );
i = nMin;
double dCurWidth = pdWidth[i];
pdf_int64 lCurIndex = i++;
pdf_int64 lCurLength = 1L;
for( ;i<=nMax;i++ )
{
if( static_cast<int>(pdWidth[i] - dCurWidth) == 0 )
++lCurLength;
else
{
if( lCurLength > 1 )
{
array.push_back( lCurIndex );
pdf_int64 temp = lCurIndex + lCurLength - 1;
array.push_back( temp );
array.push_back( dCurWidth );
}
else
{
if( array.size() && array.back().IsArray() )
{
array.back().GetArray().push_back( dCurWidth );
}
else
{
PdfArray tmp;
tmp.push_back( dCurWidth );
array.push_back( lCurIndex );
array.push_back( tmp );
}
}
lCurIndex = i;
lCurLength = 1L;
dCurWidth = pdWidth[i];
}
}
if (array.size() == 0)
{
array.push_back( lCurIndex = nMin );
array.push_back( lCurIndex = nMax );
array.push_back( dCurWidth );
}
pFontDict->GetDictionary().AddKey( PdfName("W"), array );
}
free( pdWidth );
}
示例4: 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;
}
//.........这里部分代码省略.........