本文整理汇总了C++中PDFDoc::getOptContentConfig方法的典型用法代码示例。如果您正苦于以下问题:C++ PDFDoc::getOptContentConfig方法的具体用法?C++ PDFDoc::getOptContentConfig怎么用?C++ PDFDoc::getOptContentConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDFDoc
的用法示例。
在下文中一共展示了PDFDoc::getOptContentConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkIsVisible
void TestOptionalContent::checkIsVisible()
{
GooString *fileName = new GooString(TESTDATADIR "/unittestcases/vis_policy_test.pdf");
globalParams = new GlobalParams();
PDFDoc *doc = new PDFDoc( fileName );
QVERIFY( doc );
OCGs *ocgs = doc->getOptContentConfig();
QVERIFY( ocgs );
XRef *xref = doc->getXRef();
Object obj;
// In this test, both Ref(21,0) and Ref(2,0) are set to On
// AnyOn, one element array:
// 22 0 obj<</Type/OCMD/OCGs[21 0 R]/P/AnyOn>>endobj
xref->fetch( 22, 0, &obj );
QVERIFY( obj.isDict() );
QVERIFY( ocgs->optContentIsVisible( &obj ) );
obj.free();
// Same again, looking for any leaks or dubious free()'s
xref->fetch( 22, 0, &obj );
QVERIFY( obj.isDict() );
QVERIFY( ocgs->optContentIsVisible( &obj ) );
obj.free();
// AnyOff, one element array:
// 29 0 obj<</Type/OCMD/OCGs[21 0 R]/P/AnyOff>>endobj
xref->fetch( 29, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AllOn, one element array:
// 36 0 obj<</Type/OCMD/OCGs[28 0 R]/P/AllOn>>endobj
xref->fetch( 36, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AllOff, one element array:
// 43 0 obj<</Type/OCMD/OCGs[28 0 R]/P/AllOff>>endobj
xref->fetch( 43, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AnyOn, multi-element array:
// 50 0 obj<</Type/OCMD/OCGs[21 0 R 28 0 R]/P/AnyOn>>endobj
xref->fetch( 50, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AnyOff, multi-element array:
// 57 0 obj<</Type/OCMD/P/AnyOff/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 57, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AllOn, multi-element array:
// 64 0 obj<</Type/OCMD/P/AllOn/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 64, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AllOff, multi-element array:
// 71 0 obj<</Type/OCMD/P/AllOff/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 71, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
delete doc;
delete globalParams;
}
示例2: convert
bool PdfPlug::convert(QString fn)
{
bool firstPg = true;
int currentLayer = m_Doc->activeLayer();
int baseLayer = m_Doc->activeLayer();
importedColors.clear();
if(progressDialog)
{
progressDialog->setOverallProgress(2);
progressDialog->setLabel("GI", tr("Generating Items"));
qApp->processEvents();
}
QFile f(fn);
oldDocItemCount = m_Doc->Items->count();
if (progressDialog)
{
progressDialog->setBusyIndicator("GI");
qApp->processEvents();
}
globalParams = new GlobalParams();
if (globalParams)
{
GooString *fname = new GooString(QFile::encodeName(fn).data());
globalParams->setErrQuiet(gTrue);
GBool hasOcg = gFalse;
QList<OptionalContentGroup*> ocgGroups;
// globalParams->setPrintCommands(gTrue);
PDFDoc *pdfDoc = new PDFDoc(fname, 0, 0, 0);
if (pdfDoc)
{
if (pdfDoc->isOk())
{
double hDPI = 72.0;
double vDPI = 72.0;
int firstPage = 1;
int lastPage = pdfDoc->getNumPages();
SlaOutputDev *dev = new SlaOutputDev(m_Doc, &Elements, &importedColors, importerFlags);
if (dev->isOk())
{
OCGs* ocg = pdfDoc->getOptContentConfig();
if (ocg)
{
hasOcg = ocg->hasOCGs();
if (hasOcg)
{
QStringList ocgNames;
Array *order = ocg->getOrderArray();
if (order)
{
for (int i = 0; i < order->getLength (); ++i)
{
Object orderItem;
order->get(i, &orderItem);
if (orderItem.isDict())
{
Object ref;
order->getNF(i, &ref);
if (ref.isRef())
{
OptionalContentGroup *oc = ocg->findOcgByRef(ref.getRef());
QString ocgName = UnicodeParsedString(oc->getName());
if (!ocgNames.contains(ocgName))
{
ocgGroups.prepend(oc);
ocgNames.append(ocgName);
}
}
ref.free();
}
else
{
GooList *ocgs;
int i;
ocgs = ocg->getOCGs ();
for (i = 0; i < ocgs->getLength (); ++i)
{
OptionalContentGroup *oc = (OptionalContentGroup *)ocgs->get(i);
QString ocgName = UnicodeParsedString(oc->getName());
if (!ocgNames.contains(ocgName))
{
ocgGroups.prepend(oc);
ocgNames.append(ocgName);
}
}
}
}
}
else
{
GooList *ocgs;
int i;
ocgs = ocg->getOCGs ();
for (i = 0; i < ocgs->getLength (); ++i)
{
OptionalContentGroup *oc = (OptionalContentGroup *)ocgs->get(i);
QString ocgName = UnicodeParsedString(oc->getName());
if (!ocgNames.contains(ocgName))
{
//.........这里部分代码省略.........
示例3: checkVisibilitySetting
void TestOptionalContent::checkVisibilitySetting()
{
globalParams = new GlobalParams();
GooString *fileName = new GooString(TESTDATADIR "/unittestcases/vis_policy_test.pdf");
PDFDoc *doc = new PDFDoc( fileName );
QVERIFY( doc );
OCGs *ocgs = doc->getOptContentConfig();
QVERIFY( ocgs );
XRef *xref = doc->getXRef();
Object obj;
// In this test, both Ref(21,0) and Ref(28,0) start On,
// based on the file settings
Object ref21obj;
ref21obj.initRef( 21, 0 );
Ref ref21 = ref21obj.getRef();
OptionalContentGroup *ocgA = ocgs->findOcgByRef( ref21 );
QVERIFY( ocgA );
QVERIFY( (ocgA->getName()->cmp("A")) == 0 );
QCOMPARE( ocgA->getState(), OptionalContentGroup::On );
Object ref28obj;
ref28obj.initRef( 28, 0 );
Ref ref28 = ref28obj.getRef();
OptionalContentGroup *ocgB = ocgs->findOcgByRef( ref28 );
QVERIFY( ocgB );
QVERIFY( (ocgB->getName()->cmp("B")) == 0 );
QCOMPARE( ocgB->getState(), OptionalContentGroup::On );
// turn one Off
ocgA->setState( OptionalContentGroup::Off );
// AnyOn, one element array:
// 22 0 obj<</Type/OCMD/OCGs[21 0 R]/P/AnyOn>>endobj
xref->fetch( 22, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// Same again, looking for any leaks or dubious free()'s
xref->fetch( 22, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AnyOff, one element array:
// 29 0 obj<</Type/OCMD/OCGs[21 0 R]/P/AnyOff>>endobj
xref->fetch( 29, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AllOn, one element array:
// 36 0 obj<</Type/OCMD/OCGs[28 0 R]/P/AllOn>>endobj
xref->fetch( 36, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AllOff, one element array:
// 43 0 obj<</Type/OCMD/OCGs[28 0 R]/P/AllOff>>endobj
xref->fetch( 43, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AnyOn, multi-element array:
// 50 0 obj<</Type/OCMD/OCGs[21 0 R 28 0 R]/P/AnyOn>>endobj
xref->fetch( 50, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AnyOff, multi-element array:
// 57 0 obj<</Type/OCMD/P/AnyOff/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 57, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), true );
obj.free();
// AllOn, multi-element array:
// 64 0 obj<</Type/OCMD/P/AllOn/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 64, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
// AllOff, multi-element array:
// 71 0 obj<</Type/OCMD/P/AllOff/OCGs[21 0 R 28 0 R]>>endobj
xref->fetch( 71, 0, &obj );
QVERIFY( obj.isDict() );
QCOMPARE( ocgs->optContentIsVisible( &obj ), false );
obj.free();
//.........这里部分代码省略.........