Programming language: in C/C++/in C#

List of C++ Examples

  • test_write1(): Open an XPS file, and save it with a different filename.
  • test_create1(): Create a new XPS file from scratch.
  • test_extractpage1(): Extract a single page from an XPS document, and save this page in a newly created document.
  • test_extractdoc1(): Extract a document, and store it in a new document.
  • test_packageinfo_coreprops(): Get the properties that are stored in the XPS file.
  • test_merge_docs2(): Merge 2 XPS documents, performing a 'document' merge. The resulting XPS file contains 2 documents.
  • test_get_thumbnail(): Get the thumbnail preview that is stored in the XPS file.
  • test_insert_cover_page(): Insert a cover page in an XPS document.
  • test_insert_back_page(): Insert a back page.
  • test_page_info2(): Get the list of all fonts used on a page.
  • test_extract_and_merge(): Extract a page, and insert this into a new document, and save it as a separate file.
  • test_exportImage(): Extract an image resource used on a specific page in an XPS file.
  • test_exportFont(): Extract a font resource.
  • test_replace_font_Arial(): Replace a font resource.
  • test_exportFont2(): Extract a font.
  • test_renderer_long(): Render all pages of an XPS file to image buffers.
  • test_renderer_totiff(): Render an XPS page to a TIFF file.
  • test_renderer_topdf(): Convert an XPS document to PDF.
  • test_renderer_topdf_package(): Convert a complete multi-document XPS file to PDF.
  • test_renderer_tosvg(): Convert an XPS page to SVG.
  • test_create_glyphs_via_NOX(): Create an XPS file from scratch, and write some text on the first page.
  • test_moveObjectsAndRenderToImage(): Select objects on an XPS page, move them, and render the resulting page to a TIFF file.
  • test_documentstructure(): Show the document structure (table of contents).
  • test_bookmark2(): Show the bookmarks in an XPS file.
  • test_calculateBoundingBox(): Get access to the bounding boxes of objects on an XPS page.
  • test_interleave_pages(): Interleave a page for every page stored in the XPS file.
  • test_textareaselect1(): Select all text within a given rectangle.
  • test_textareaselect2(): Select all text within a given rectangle.
  • test_generate_from_image_siena(): Create an XPS file from a jpeg image.
  • test_replace_text(): Search and replace text.
  • test_open_drawrectangle_save(): Access the XPS content stream to draw a rectangle on the page.

    C++ Examples

    void test_write1()
    {
    	const char *pIn="testfiles/thumbnail.xps";
    	const char *pOut="output/write1.xps";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
    	lPackage->writePackageToFile(pOut);
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_create1()
    {
    	const char *pOut="output/create1.xps";
    	NOPackage *lPackage=NOPackage::createPackage(true,pOut);
    	lPackage->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_extractpage1()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/extractpage1.xps";
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile(pIn);
    	NOPackage *lPackageDestination=NOPackage::createPackage(true,pOut);
    
    	NODocument lSourceDoc=lPackageSource->getDocument(0);
    	NODocument lDestinationDoc=lPackageDestination->getDocument(0);
    
    	// extract the page to a new doc
    	lDestinationDoc.insertPage(lSourceDoc.getPage(5),0);
    
    	lPackageDestination->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackageSource);
    	NOPackage::destroyPackage(lPackageDestination);
    }
    
    
    void test_extractdoc1()
    {
    	const char *pIn="testfiles/publisher.xps";
    	const char *pOut="output/extractdoc1.xps";
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile(pIn);
    	NOPackage *lPackageDestination=NOPackage::createPackage(false,pOut);
    	NOPackage *lPackageFinal=NOPackage::createPackage(false,pOut);
    
    	NOProgressReporter lReporter;
    
    	{ // step 1: copy doc to the destination package
    		NODocument lSourceDoc=lPackageSource->getDocument(0);
    		lPackageDestination->addDocument(lSourceDoc,lReporter);
    	}
    
    	{ // step 2: copy doc to the destination package
    		NODocument lSourceDoc=lPackageDestination->getDocument(0);
    		lPackageFinal->addDocument(lSourceDoc,lReporter);
    	}
    
    	// write out result
    	lPackageFinal->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackageSource);
    	NOPackage::destroyPackage(lPackageDestination);
    	NOPackage::destroyPackage(lPackageFinal);
    }
    
    
    void test_packageinfo_coreprops()
    {
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/Office2007_font_samples_UNICODE.xps");
    
    	{
    		NOCoreProperties lProps=lPackageSource->getCoreProperties();
    
    		{
    			const UTF8String lStr=lProps.getProperty(CoreProperty::Category);
    			if (!lStr.empty())
    				std::cout << "Core Property Category: " << lStr << std::endl;
    		}
    		{
    			const UTF8String lStr=lProps.getProperty(CoreProperty::Created);
    			if (!lStr.empty())
    				std::cout << "Core Property Created: " << lStr << std::endl;
    		}
    		{
    			const UTF8String lStr=lProps.getProperty(CoreProperty::Modified);
    			if (!lStr.empty())
    				std::cout << "Core Property Modified: " << lStr << std::endl;
    		}
    		{
    			const UTF8String lStr=lProps.getProperty(CoreProperty::Title);
    			if (!lStr.empty())
    				std::cout << "Core Property Title: " << lStr << std::endl;
    		}
    	}
    
    	NOPackage::destroyPackage(lPackageSource);
    }
    
    
    void test_merge_docs2()
    {
    	const char *pOut="output/merge_docs2.xps";
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage *lMergeInto=NOPackage::readPackageFromFile("testfiles/Office2007_font_samples_UNICODE.xps");
    
    	// add document to package
    	NOProgressReporter lReporter;
    	lMergeInto->addDocument(lPackageSource->getDocument(0),lReporter);
    
    	lMergeInto->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackageSource);
    	NOPackage::destroyPackage(lMergeInto);
    }
    
    
    void test_get_thumbnail()
    {
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/CoreProperty2.xps");
    
    	// check if this package has a thumbnail
    	if (lPackageSource->hasThumbnail()!=0)
    	{
    		NOThumbnail lThumb=lPackageSource->getThumbnail();
    		const UInt32 lSize=lThumb.getImageSize();
    		UInt8 *lBuffer=new UInt8[lSize];
    		lThumb.getImageData(lBuffer,lSize);
    		std::cout << "Thumbnail size: " << lSize << std::endl;
    		delete [] lBuffer;
    
    	}
    
    	NOPackage::destroyPackage(lPackageSource);
    }
    
    
    
    void test_insert_cover_page()
    {
    	const char *pOut="output/insert_cover_page.xps";
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage *lPackageDestination=NOPackage::readPackageFromFile("testfiles/Office2007_font_samples_UNICODE.xps");
    
    	// insert cover page
    	lPackageDestination->getDocument(0).insertPage(lPackageSource->getDocument(0).getPage(0),0);
    
    	lPackageDestination->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackageSource);
    	NOPackage::destroyPackage(lPackageDestination);
    }
    
    
    void test_insert_back_page()
    {
    	const char *pOut="output/insert_back_page.xps";
    	NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage *lPackageDestination=NOPackage::readPackageFromFile("testfiles/Office2007_font_samples_UNICODE.xps");
    
    	// insert back page
    	lPackageDestination->getDocument(0).insertPage(lPackageSource->getDocument(0).getPage(0),lPackageDestination->getDocument(0).getNumberOfPages());
    
    	lPackageDestination->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackageSource);
    	NOPackage::destroyPackage(lPackageDestination);
    }
    
    
    void test_page_info2()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/Office2007_font_samples_UNICODE.xps");
    
    	{
    		NOPage lPage=lPackage->getDocument(0).getPage(1);
    
    		NOFontVector lFonts(*lPackage);
    		lPage.getFonts(lFonts);
    
    		UInt32 lCount;
    		for(lCount=0; lCount < lFonts.size(); lCount++)
    			std::cout << lFonts.elementAt(lCount).getFileName() << std::endl;
    	}
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_extract_and_merge()
    {
    	const char *pOut="output/extract_and_merge.xps";
    	NOPackage *lPackageDestination=NOPackage::createPackage(true,pOut);
    	{ // extract one time
    		NOPackage *lPackageSource=NOPackage::readPackageFromFile("testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    		lPackageDestination->getDocument(0).insertPage(lPackageSource->getDocument(0).getPage(0),0);
    		NOPackage::destroyPackage(lPackageSource);
    	}
    
    	NOPackage *lPackageFinal=NOPackage::createPackage(true,pOut);
    	{ // extract a second time
    		NOPackage *lPackageSource=lPackageDestination;
    		lPackageFinal->getDocument(0).insertPage(lPackageSource->getDocument(0).getPage(0),0);
    	}
    
    	lPackageFinal->writePackageToFile(pOut);
    	NOPackage::destroyPackage(lPackageDestination);
    
    	NOPackage::destroyPackage(lPackageFinal);
    }
    
    
    void test_exportImage()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/exportImage.png";
    	NOPackage *baseDoc=NOPackage::readPackageFromFile(pIn);
    	NOPage basePage=baseDoc->getDocument(0).getPage(1);
    	NOImageVector lImages(*baseDoc);
    	const UInt32 numberOfImages = basePage.getImages(lImages);
    	lImages.elementAt(3).writeImageToFile(pOut);
    	NOPackage::destroyPackage(baseDoc);
    }
    
    
    void test_exportFont()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/exportFont.ttf";
    	NOPackage *baseDoc=NOPackage::readPackageFromFile(pIn);
    	NOPage basePage=baseDoc->getDocument(0).getPage(2);
    	NOFontVector lFonts(*baseDoc);
    	const UInt32 numberOfFonts = basePage.getFonts(lFonts);
    	lFonts.elementAt(0).writeToFile(pOut);
    	NOPackage::destroyPackage(baseDoc);
    }
    
    
    void test_replace_font_Arial()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/vdp.xps");
    
    	{
    		NOFontVector lFonts(*lPackage);
    		lPackage->getDocument(0).getPage(0).getFonts(lFonts);
    
    		lFonts.elementAt(0).replaceWithFile("testfiles/Arial.ttf");
    		std::cout << lFonts.elementAt(0).getFontFamilyName() << "";
    	}
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_exportFont2()
    {
    	const char *pIn="testfiles/Outlook2007_Calendar.xps";
    	const char *pOut="output/exportFont2.otf";
    	NOPackage *baseDoc=NOPackage::readPackageFromFile(pIn);
    
    	NOPage basePage=baseDoc->getDocument(0).getPage(0);
    
    	NOFontVector lFonts(*baseDoc);
    	basePage.getFonts(lFonts);
    
    	lFonts.elementAt(1).writeToFile(pOut);
    
    	NOPackage::destroyPackage(baseDoc);
    }
    
    
    void test_renderer_long()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    
    	NODocument lDoc=lPackage->getDocument(0);
    
    	UInt32 lCount=0; for(;lCount < lDoc.getNumberOfPages();lCount++)
    	{
    		NOPage lPage=lDoc.getPage(lCount);
    		UInt32 lBufferLength = 300 * 300 * 3;
    		UInt8 *lBuffer = new UInt8[lBufferLength];
    		memset(lBuffer,0,lBufferLength);
    		lPage.renderToImage(lBuffer,300,300,true,false);
    		delete [] lBuffer;
    	}
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_renderer_totiff()
    {
    	const char *pIn="testfiles/catalog.xps";
    	const char *pOut="output/renderer_totiff.tiff";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
    
    	NODocument lDoc=lPackage->getDocument(0);
    
    	UInt32 lOutSize=1000;
    
    	NOPage lPage=lDoc.getPage(0);
    	UInt32 lBufferLength = lOutSize * lOutSize * 3;
    	UInt8 *lBuffer = new UInt8[lBufferLength];
    	memset(lBuffer,0,lBufferLength);
    	lPage.renderToImage(lBuffer,lOutSize,lOutSize,true,false);
    
    	NOUtility_write_tiff(lBuffer,const_cast(pOut),lOutSize,lOutSize);
    
    	delete [] lBuffer;
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_renderer_topdf()
    {
    	const char *pIn="testfiles/catalog.xps";
    	const char *pOut="output/renderer_topdf.pdf";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
    
    	NODocument lDoc=lPackage->getDocument(0);
    	NOProgressReporter lReporter;
    	lDoc.exportToPDF(pOut,lReporter);
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_renderer_topdf_package()
    {
    	const char *pIn="testfiles/CoreProperty1.xps";
    	const char *pOut="output/renderer_topdf_package.pdf";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
    	
    	NOProgressReporter lReporter;
    	lPackage->exportToPDF(pOut,lReporter);
    	
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_renderer_tosvg()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/renderer_tosvg.svg";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
    
    	NODocument lDoc=lPackage->getDocument(0);
    	NOPage lPage=lDoc.getPage(0);
    	lPage.exportToSVG(pOut);
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_create_glyphs_via_NOX()
    {
    	const char *pOut="output/create_glyphs_via_NOX.xps";
    	// new destination document
    	NOPackage *lPackage=NOPackage::createPackage(true,pOut);
    
    	// create a new page in the destination doc
    	NOPage lPage=lPackage->getDocument(0).createPage();
    
    	// create fixed page
    	NOXFixedPage lContent=lPage.createFixedPage();
    	lContent.intialize(300,500);
    
    	// create a canvas
    	NOXCanvas lCanvas=lContent.createCanvas(0);
    	lCanvas.intialize();
    
    	// now, get some font
    	UTF8String lURI;
    	{
    		NOPackage *lDummyPackage=NOPackage::readPackageFromFile("testfiles/vdp.xps");
    		{
    			NOFontVector lFonts(*lDummyPackage);
    			lDummyPackage->getDocument(0).getPage(0).getFonts(lFonts);
    			NOFont lFont=lPage.addFont(lFonts.elementAt(0));
    			lURI=lFont.getPartName();
    		}
    		NOPackage::destroyPackage(lDummyPackage);
    	}
    
    	// create a glyphs section in the canvas
    	NOXGlyphs lGlyphs=lCanvas.createGlyphs(0);
    	lGlyphs.intialize(10.0,(NOString)((UTF8String)"/"+lURI),50.0,50.0);
    
    	lGlyphs.setFill((NOString)"#FF0000FF");
    
    	lGlyphs.setUnicodeString((NOString)"abcdefghijklmnopqrstuvwxyz");
    
    	// write out and close
    	lPackage->writePackageToFile(pOut);
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_moveObjectsAndRenderToImage()
    {
    	const char *pOut="output/moveObjectsAndRenderToImage.tiff";
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/0inDashArray.xps");
    
    	NODocument lDocument = lPackage->getDocument(0);
    	NOPage lPage = lDocument.getPage(0);
    
    	// render first to make sure we have bounding boxes
    	lPage.renderToTiff(pOut,1000,1000,300,true);
    
    	NCommon::UInt32Rect lRect;
    	lRect.mTop=157;
    	lRect.mLeft=59;
    	lRect.mBottom=299;
    	lRect.mRight=538;
    
    	lPage.selectMarquee(lRect,600,400,false);
    
    	NOSelection lSelection=lPage.getCopyOfSelection();
    
    	double lPageSizeX=0;
    	double lPageSizeY=0;
    	lPage.getPageSize(&lPageSizeX, &lPageSizeY);
    
    	UInt32 lNumberOfSelectedObjects = lSelection.getNumberOfSelectedObjects();
    	UInt32 j = 0; for (; j < lNumberOfSelectedObjects; j++)
    		lPage.moveObject(lSelection.getSelectedObject(j).mID,100*lPageSizeX/600,100*lPageSizeY/400);
    
    	lPage.renderToTiff(pOut,1000,1000,300,true);
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_documentstructure()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/OMS_globa.xps");
    
    	NOXDocumentStructure lStruct=lPackage->getDocument(0).getDocumentStructure();
    
    	NOXCP_Outline lCP_Outline=lStruct.getDocumentStructureOutline(0);
    
    	NOXDocumentOutline lOutline = lCP_Outline.getDocumentOutline(0);
    
    	UInt32 i=0; for(;i < lOutline.getNumOutlineEntry();i++)
    	{
    		NOXOutlineEntry lEntry=lOutline.getOutlineEntry(i);
    
    		NOString lString;
    		lEntry.getDescription(lString);
    
    		NOString lTarget;
    		lEntry.getOutlineTarget(lTarget);
    
    		std::cout << "Description:"    << lString.getUTF8String() 
    				<< " Level:"    	<< lEntry.getOutlineLevel()
    				<< " Target:"   	<< lTarget.getUTF8String() << std::endl;
    	}
    
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_bookmark2()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/OMS_globa.xps");
    
    	NODocument lDoc=lPackage->getDocument(0);
    
    	NOXDocumentStructure lStruct=lPackage->getDocument(0).getDocumentStructure();
    
    	NOXCP_Outline lCP_Outline=lStruct.getDocumentStructureOutline(0);
    
    	NOXDocumentOutline lOutline = lCP_Outline.getDocumentOutline(0);
    
    	NOXOutlineEntry lEntry=lOutline.getOutlineEntry(3);
    
    	NOString lString;
    	lEntry.getOutlineTarget(lString);
    
    	UInt16 lPageID=0;
    	UInt32 lObjectID=0;
    	UTF8String lStr=lString.getUTF8String();
    	if (lDoc.resolveLink(lStr.c_str(),&lPageID,&lObjectID)==0)
    		return;
    
    	std::cout << "Page-ID:"		<< lPageID 
    		<< " Object-ID:"	<< lObjectID << "";
    }
    
    
    void test_calculateBoundingBox()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/SkewedText.xps");
    
    	NODocument lDoc=lPackage->getDocument(0);
    
    	UInt32 lCount=0; for(;lCount < lDoc.getNumberOfPages();lCount++)
    	{
    		NOPage lPage=lDoc.getPage(0);
    		UInt32 lBufferLength = 10 * 10 * 3;
    		UInt8 *lBuffer = new UInt8[lBufferLength];
    		memset(lBuffer,0,lBufferLength);
    		lPage.renderToImage(lBuffer,10,10,true,false);
    
    		UInt32 lObjectID = lPage.findObjectAt(417,194,960,720);
    		lPage.clearSelection();
    		lPage.setSelection(lObjectID,true);
    
    		NOSelection lSelectedObjects = lPage.getCopyOfSelection();
    
    		NCommon::doubleRect lRect;
    		lRect=lPage.getBoundingBox(lSelectedObjects.getSelectedObject(0).mID);
    
    		std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << "[" << double(lRect.mTop) << "," << double(lRect.mBottom) << "," << double(lRect.mLeft) << "," << double(lRect.mRight) << "]" << "";
    
    		delete [] lBuffer;
    	}
    }
    
    
    void test_interleave_pages()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/interleave_pages.xps";
    	const char *file_terms="testfiles/vdp.xps";
    	const char *file_input=pIn;
    	const char *file_output=pOut;
    
    	// open terms, get handler to terms page
    	NOPackage *lTerms=NOPackage::readPackageFromFile(file_terms);
    	NOPage lTermsPage=lTerms->getDocument(0).getPage(0);
    
    	// open input, get handle to the doc inside
    	NOPackage *lInput=NOPackage::readPackageFromFile(file_input);
    	NODocument lInputDoc=lInput->getDocument(0);
    
    	// create output, 1 doc, get handle to doc inside
    	NOPackage *lOutput=NOPackage::createPackage(true,pOut);
    	NODocument lOutputDoc=lOutput->getDocument(0);
    
    	// loop over the pages in lInputDoct, interleave with lTermspage
    	// and put this in the lOutputDoc
    	UInt32 i=0; for (;i < lInputDoc.getNumberOfPages();i++)
    	{
    			lOutputDoc.insertPage(lInputDoc.getPage(i),2*i);
    			lOutputDoc.insertPage(lTermsPage,2*i+1);
    	}
    
    	lOutput->writePackageToFile(file_output);
    
    	NOPackage::destroyPackage(lOutput);
    	NOPackage::destroyPackage(lInput);
    	NOPackage::destroyPackage(lTerms);
    }
    
    
    void test_textareaselect1()
    {
    	// bounding box selectTextMarquee: [ 346,409 -> 361,357];
    	// selected characters: 5 -> 15
    	// bounding box selectTextMarquee: [ 346,409 -> 369,328];
    	// selected characters: 6 -> 21
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/angledtext.xps");
    	NODocument lDocument = lPackage->getDocument(0);
    	NOPage lPage = lDocument.getPage(0);
    
    	UInt8 *lBuffer = new UInt8[125 * 162 * 3];
    	lPage.renderToImage(lBuffer, 125, 162, false, false);
    
    	doubleRect lRect1;
    	lRect1.mLeft = 346;
    	lRect1.mTop = 409;
    	lRect1.mBottom = 357;
    	lRect1.mRight = 361;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	lRect1.mBottom = 328;
    	lRect1.mRight = 369;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	//  297,404 -> 431,203
    	// should select entire text
    	lRect1.mLeft = 297;
    	lRect1.mTop = 404;
    	lRect1.mBottom = 203;
    	lRect1.mRight = 431;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	// 366,324 -> 378,275
    	// "n isocele"
    	lRect1.mLeft = 366;
    	lRect1.mTop = 324;
    	lRect1.mBottom = 275;
    	lRect1.mRight = 378;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	// 376,291 -> 416,157
    	// "eles triangle, nearly."
    	lRect1.mLeft = 376;
    	lRect1.mTop = 291;
    	lRect1.mBottom = 157;
    	lRect1.mRight = 416;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	// 367,324 -> 343,221
    	// ---> should be "is object will be an", because the end is above the finishing line and not underneath of it
    	lRect1.mLeft = 367;
    	lRect1.mTop = 324;
    	lRect1.mBottom = 221;
    	lRect1.mRight = 343;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    }
    
    
    void test_textareaselect2()
    {
    	NOPackage *lPackage=NOPackage::readPackageFromFile("testfiles/0inDashArray.xps");
    	NODocument lDocument = lPackage->getDocument(0);
    	NOPage lPage = lDocument.getPage(0);
    
    	UInt8 *lBuffer = new UInt8[125 * 162 * 3];
    	lPage.renderToImage(lBuffer, 125, 162, false, false);
    
    	doubleRect lRect1;
    	//  101,193 -> 168,240
    	lRect1.mLeft = 101;
    	lRect1.mTop = 193;
    	lRect1.mBottom = 240;
    	lRect1.mRight = 168;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    	// 184,194 -> 78,254
    	lRect1.mLeft = 184;
    	lRect1.mTop = 194;
    	lRect1.mBottom = 254;
    	lRect1.mRight = 78;
    	lPage.selectTextMarquee(lRect1);
    
    	{
    		NiXPSObjects::NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects::NOString lString = lTextSelection.getSelectedTextPart(i);
    			NCommon::UTF8String lUTF8String = lString.getUTF8String();
    			std::cout << lUTF8String << std::endl;
    		}
    	}
    
    }
    
    
    void test_generate_from_image_siena()
    {
    	const char *pOut="output/siena.xps";
    	NOPackage *lNewPackage = NOPackage::createFromImage("testfiles/siena.jpg");
    	lNewPackage->writePackageToFile(pOut);
    	NOPackage::destroyPackage(lNewPackage);
    }
    
    
    void test_replace_text()
    {
    	const char *pIn="testfiles/template.xps";
    	const char *pOut="output/replace_text.xps";
    	NOPackage *lPackage=NOPackage::readPackageFromFile(pIn);
        NODocument lDoc=lPackage->getDocument(0);
       
    	{
    		NOFontVector lFonts(*lPackage);
    		lDoc.searchAndReplaceText("TAG_TO", "Other Text", lFonts, true);
    		if (lFonts.size()>0)
    		{
    			if (lFonts.elementAt(0).replaceWithFile("testfiles/Arial.ttf")==0)
    				return;
    		}
    	}
    
    	{
    		NOFontVector lFonts(*lPackage);
    		lDoc.searchAndReplaceText("TAG_TO", "Other Text", lFonts, false);
    	}
    
    	lPackage->writePackageToFile(pOut);
    	NOPackage::destroyPackage(lPackage);
    }
    
    
    void test_open_drawrectangle_save()
    {
    	const char *pIn="testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	const char *pOut="output/open_drawrectangle_save.xps";
    	NOPackage *lPackage = NOPackage::readPackageFromFile(pIn);
    
    	// get first page
    	NOPage lPage = lPackage->getDocument(0).getPage(0);
    
    	// get content stream
    	NOXFixedPage lContent = lPage.getFixedPage();
    
    	// append a rectangle
    	// a rectangle is a path, we will add this in a seperate canvas (group)
    	// and we will put this canvas at the end of the stack, so it will be displayed on top
    	NOXPath lPath=lContent.createCanvas(lContent.getNumCanvas()).createPath(0);
    	lPath.intialize();
    
    	// geometry: (100,100)-(200,200)
    	lPath.setData((NOString)"M 100,100 L 200,100 L 200,200 L 100,200 Z");
    
    	// color: ARGB - so full red, transparant overlay
    	lPath.setFill((NOString)"#99FF0000");
    
    	// write the XPS file out
    	lPackage->writePackageToFile(pOut);
    
    	NOPackage::destroyPackage(lPackage);
    }