本文整理汇总了C++中PageContentContext::G方法的典型用法代码示例。如果您正苦于以下问题:C++ PageContentContext::G方法的具体用法?C++ PageContentContext::G怎么用?C++ PageContentContext::G使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageContentContext
的用法示例。
在下文中一共展示了PageContentContext::G方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UseAsXObjects
EStatusCode UseAsXObjects()
{
PDFWriter pdfWriter;
EStatusCode status;
do
{
status = pdfWriter.StartPDF(scBasePath + "UseAsXObjects.PDF",ePDFVersion13);
if(status != eSuccess)
break;
// creating XObjects for all pages of XObjectContent.pdf (2 pages)
EStatusCodeAndObjectIDTypeList result = pdfWriter.CreateFormXObjectsFromPDF(scBasePath + "XObjectContent.PDF",PDFPageRange(),ePDFPageBoxMediaBox);
if(result.first != eSuccess)
{
status = eFailure;
break;
}
// determine page IDs
ObjectIDTypeList::iterator it = result.second.begin();
ObjectIDType firstPageID = *it;
++it;
ObjectIDType secondPageID = *it;
// create a page using both xobjects
PDFPage* page = new PDFPage();
page->SetMediaBox(PDFRectangle(0,0,595,842));
PageContentContext* contentContext = pdfWriter.StartPageContentContext(page);
// place the first page in the top left corner of the document
contentContext->q();
contentContext->cm(0.5,0,0,0.5,0,421);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(firstPageID));
contentContext->Q();
// draw a rectangle around the page bounds
contentContext->G(0);
contentContext->w(1);
contentContext->re(0,421,297.5,421);
contentContext->S();
// place the second page in the bottom right corner of the document
contentContext->q();
contentContext->cm(0.5,0,0,0.5,297.5,0);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(secondPageID));
contentContext->Q();
// draw a rectangle around the page bounds
contentContext->G(0);
contentContext->w(1);
contentContext->re(297.5,0,297.5,421);
contentContext->S();
status = pdfWriter.EndPageContentContext(contentContext);
if(status != eSuccess)
break;
status = pdfWriter.WritePageAndRelease(page);
if(status != eSuccess)
break;
// appending pages 0,1,2,3 of BasicTIFFImagesTest.PDF
PDFPageRange selectivePageRange;
selectivePageRange.mType = PDFPageRange::eRangeTypeSpecific;
selectivePageRange.mSpecificRanges.push_back(ULongAndULong(0,3));
result = pdfWriter.CreateFormXObjectsFromPDF(scBasePath + "BasicTIFFImagesTest.PDF",selectivePageRange,ePDFPageBoxMediaBox);
if(result.first != eSuccess)
{
status = eFailure;
break;
}
page = new PDFPage();
page->SetMediaBox(PDFRectangle(0,0,595,842));
contentContext = pdfWriter.StartPageContentContext(page);
// placing them in all 4 corners of the 2nd page [going left right, top bottom]
it = result.second.begin();
contentContext->q();
contentContext->cm(0.5,0,0,0.5,0,421);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(*it));
contentContext->Q();
++it;
contentContext->q();
contentContext->cm(0.5,0,0,0.5,297.5,421);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(*it));
contentContext->Q();
++it;
contentContext->q();
contentContext->cm(0.5,0,0,0.5,0,0);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(*it));
//.........这里部分代码省略.........
示例2: Run
EStatusCode SimpleContentPageTest::Run(const TestConfiguration& inTestConfiguration)
{
PDFWriter pdfWriter;
EStatusCode status;
do
{
status = pdfWriter.StartPDF(RelativeURLToLocalPath(inTestConfiguration.mSampleFileBase,"SimpleContent.PDF"),ePDFVersion13);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to start PDF\n";
break;
}
PDFPage* page = new PDFPage();
page->SetMediaBox(PDFRectangle(0,0,595,842));
PageContentContext* contentContext = pdfWriter.StartPageContentContext(page);
if(NULL == contentContext)
{
status = PDFHummus::eFailure;
cout<<"failed to create content context for page\n";
break;
}
// draw a 100X100 points cyan square
contentContext->q();
contentContext->k(100,0,0,0);
contentContext->re(100,500,100,100);
contentContext->f();
contentContext->Q();
// force stream change
status = pdfWriter.PausePageContentContext(contentContext);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to pause page content context\n";
break;
}
// draw a 200X100 points red rectangle
contentContext->q();
contentContext->k(0,100,100,0);
contentContext->re(200,600,200,100);
contentContext->f();
contentContext->Q();
// draw a gray line
contentContext->q();
contentContext->G(0.5);
contentContext->w(3);
contentContext->m(200,600);
contentContext->l(400,400);
contentContext->S();
contentContext->Q();
status = pdfWriter.EndPageContentContext(contentContext);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to end page content context\n";
break;
}
status = pdfWriter.WritePageAndRelease(page);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to write page\n";
break;
}
status = pdfWriter.EndPDF();
if(status != PDFHummus::eSuccess)
{
cout<<"failed in end PDF\n";
break;
}
}while(false);
return status;
}
示例3: Run
EStatusCode PDFEmbedTest::Run(const TestConfiguration& inTestConfiguration)
{
EStatusCode status;
PDFWriter pdfWriter;
do
{
status = pdfWriter.StartPDF(RelativeURLToLocalPath(inTestConfiguration.mSampleFileBase,"PDFEmbedTest.pdf"),ePDFVersion13);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to start PDF\n";
break;
}
// Create XObjects from PDF to embed
EStatusCodeAndObjectIDTypeList result = pdfWriter.CreateFormXObjectsFromPDF(
RelativeURLToLocalPath(inTestConfiguration.mSampleFileBase,"TestMaterials/XObjectContent.PDF"),PDFPageRange(),ePDFPageBoxMediaBox);
if(result.first != PDFHummus::eSuccess)
{
cout<<"failed to create PDF XObjects from PDF file\n";
status = result.first;
break;
}
PDFPage* page = new PDFPage();
page->SetMediaBox(PDFRectangle(0,0,595,842));
PageContentContext* contentContext = pdfWriter.StartPageContentContext(page);
// place the first page in the top left corner of the document
contentContext->q();
contentContext->cm(0.5,0,0,0.5,0,421);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(result.second.front()));
contentContext->Q();
contentContext->G(0);
contentContext->w(1);
contentContext->re(0,421,297.5,421);
contentContext->S();
// place the second page in the bottom right corner of the document
contentContext->q();
contentContext->cm(0.5,0,0,0.5,297.5,0);
contentContext->Do(page->GetResourcesDictionary().AddFormXObjectMapping(result.second.back()));
contentContext->Q();
contentContext->G(0);
contentContext->w(1);
contentContext->re(297.5,0,297.5,421);
contentContext->S();
status = pdfWriter.EndPageContentContext(contentContext);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to end page content context\n";
break;
}
status = pdfWriter.WritePageAndRelease(page);
if(status != PDFHummus::eSuccess)
{
cout<<"failed to write page\n";
break;
}
status = pdfWriter.EndPDF();
if(status != PDFHummus::eSuccess)
{
cout<<"failed in end PDF\n";
break;
}
}while(false);
return status;
}