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

    public static void test_write1()
    {
    	string pIn="../../examples/testfiles/thumbnail.xps";
    	string pOut="../../examples/output/write1.xps";
    	NOPackage lPackage=NOPackage.readPackageFromFile(pIn);
    	lPackage.writePackageToFile(pOut);
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_create1()
    {
    	string pOut="../../examples/output/create1.xps";
    	NOPackage lPackage=NOPackage.createPackage(1,pOut);
    	lPackage.writePackageToFile(pOut);
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_extractpage1()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/output/extractpage1.xps";
    	NOPackage lPackageSource=NOPackage.readPackageFromFile(pIn);
    	NOPackage lPackageDestination=NOPackage.createPackage(1,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(ref lPackageSource);
    	NOPackage.destroyPackage(ref lPackageDestination);
    }
    
    
    public static void test_extractdoc1()
    {
    	string pIn="../../examples/testfiles/publisher.xps";
    	string pOut="../../examples/output/extractdoc1.xps";
    	NOPackage lPackageSource=NOPackage.readPackageFromFile(pIn);
    	NOPackage lPackageDestination=NOPackage.createPackage(0,pOut);
    	NOPackage lPackageFinal=NOPackage.createPackage(0,pOut);
    
    	NOProgressReporter lReporter = new NOProgressReporter();
    
    	{ // 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(ref lPackageSource);
    	NOPackage.destroyPackage(ref lPackageDestination);
    	NOPackage.destroyPackage(ref lPackageFinal);
    }
    
    
    public static void test_packageinfo_coreprops()
    {
    	NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_font_samples_UNICODE.xps");
    
    	{
    		NOCoreProperties lProps=lPackageSource.getCoreProperties();
    
    		{
    			string lStr=lProps.getProperty(NCommon.CoreProperty.Type.Category);
    			if (!String.IsNullOrEmpty(lStr))
    				System.Console.Out.WriteLine( "Core Property Category: " + lStr );
    		}
    		{
    			string lStr=lProps.getProperty(NCommon.CoreProperty.Type.Created);
    			if (!String.IsNullOrEmpty(lStr))
    				System.Console.Out.WriteLine( "Core Property Created: " + lStr );
    		}
    		{
    			string lStr=lProps.getProperty(NCommon.CoreProperty.Type.Modified);
    			if (!String.IsNullOrEmpty(lStr))
    				System.Console.Out.WriteLine( "Core Property Modified: " + lStr );
    		}
    		{
    			string lStr=lProps.getProperty(NCommon.CoreProperty.Type.Title);
    			if (!String.IsNullOrEmpty(lStr))
    				System.Console.Out.WriteLine( "Core Property Title: " + lStr );
    		}
    	}
    
    	NOPackage.destroyPackage(ref lPackageSource);
    }
    
    
    public static void test_merge_docs2()
    {
    	string pOut="../../examples/output/merge_docs2.xps";
    	NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage lMergeInto=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_font_samples_UNICODE.xps");
    
    	// add document to package
    	NOProgressReporter lReporter = new NOProgressReporter();
    	lMergeInto.addDocument(lPackageSource.getDocument(0),lReporter);
    
    	lMergeInto.writePackageToFile(pOut);
    
    	NOPackage.destroyPackage(ref lPackageSource);
    	NOPackage.destroyPackage(ref lMergeInto);
    }
    
    
    public static void test_get_thumbnail()
    {
    	NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/CoreProperty2.xps");
    
    	// check if this package has a thumbnail
    	if (lPackageSource.hasThumbnail()!=0)
    	{
    		NOThumbnail lThumb=lPackageSource.getThumbnail();
    		UInt32 lSize=lThumb.getImageSize();
    		byte[] lBuffer=new byte [lSize];
    		lThumb.getImageData(lBuffer,lSize);
    		System.Console.Out.WriteLine( "Thumbnail size: " + lSize );
    		// delete[] lBuffer;
    
    	}
    
    	NOPackage.destroyPackage(ref lPackageSource);
    }
    
    
    
    public static void test_insert_cover_page()
    {
    	string pOut="../../examples/output/insert_cover_page.xps";
    	NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage lPackageDestination=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_font_samples_UNICODE.xps");
    
    	// insert cover page
    	lPackageDestination.getDocument(0).insertPage(lPackageSource.getDocument(0).getPage(0),0);
    
    	lPackageDestination.writePackageToFile(pOut);
    
    	NOPackage.destroyPackage(ref lPackageSource);
    	NOPackage.destroyPackage(ref lPackageDestination);
    }
    
    
    public static void test_insert_back_page()
    {
    	string pOut="../../examples/output/insert_back_page.xps";
    	NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    	NOPackage lPackageDestination=NOPackage.readPackageFromFile("../../examples/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(ref lPackageSource);
    	NOPackage.destroyPackage(ref lPackageDestination);
    }
    
    
    public static void test_page_info2()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_font_samples_UNICODE.xps");
    
    	{
    		NOPage lPage=lPackage.getDocument(0).getPage(1);
    
    		NOFontVector lFonts = new NOFontVector(lPackage);
    		lPage.getFonts(lFonts);
    
    		UInt32 lCount;
    		for(lCount=0; lCount < lFonts.size(); lCount++)
    			System.Console.Out.WriteLine( lFonts.elementAt(lCount).getFileName() );
    	}
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_extract_and_merge()
    {
    	string pOut="../../examples/output/extract_and_merge.xps";
    	NOPackage lPackageDestination=NOPackage.createPackage(1,pOut);
    	{ // extract one time
    		NOPackage lPackageSource=NOPackage.readPackageFromFile("../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps");
    		lPackageDestination.getDocument(0).insertPage(lPackageSource.getDocument(0).getPage(0),0);
    		NOPackage.destroyPackage(ref lPackageSource);
    	}
    
    	NOPackage lPackageFinal=NOPackage.createPackage(1,pOut);
    	{ // extract a second time
    		NOPackage lPackageSource=lPackageDestination;
    		lPackageFinal.getDocument(0).insertPage(lPackageSource.getDocument(0).getPage(0),0);
    	}
    
    	lPackageFinal.writePackageToFile(pOut);
    	NOPackage.destroyPackage(ref lPackageDestination);
    
    	NOPackage.destroyPackage(ref lPackageFinal);
    }
    
    
    public static void test_exportImage()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/output/exportImage.png";
    	NOPackage baseDoc=NOPackage.readPackageFromFile(pIn);
    	NOPage basePage=baseDoc.getDocument(0).getPage(1);
    	NOImageVector lImages = new NOImageVector(baseDoc);
    	UInt32 numberOfImages = basePage.getImages(lImages);
    	lImages.elementAt(3).writeImageToFile(pOut);
    	NOPackage.destroyPackage(ref baseDoc);
    }
    
    
    public static void test_exportFont()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/output/exportFont.ttf";
    	NOPackage baseDoc=NOPackage.readPackageFromFile(pIn);
    	NOPage basePage=baseDoc.getDocument(0).getPage(2);
    	NOFontVector lFonts = new NOFontVector(baseDoc);
    	UInt32 numberOfFonts = basePage.getFonts(lFonts);
    	lFonts.elementAt(0).writeToFile(pOut);
    	NOPackage.destroyPackage(ref baseDoc);
    }
    
    
    public static void test_replace_font_Arial()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/testfiles/vdp.xps");
    
    	{
    		NOFontVector lFonts = new NOFontVector(lPackage);
    		lPackage.getDocument(0).getPage(0).getFonts(lFonts);
    
    		lFonts.elementAt(0).replaceWithFile("../../examples/testfiles/Arial.ttf");
    		System.Console.Out.WriteLine( lFonts.elementAt(0).getFontFamilyName() );
    	}
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_exportFont2()
    {
    	string pIn="../../examples/testfiles/Outlook2007_Calendar.xps";
    	string pOut="../../examples/output/exportFont2.otf";
    	NOPackage baseDoc=NOPackage.readPackageFromFile(pIn);
    
    	NOPage basePage=baseDoc.getDocument(0).getPage(0);
    
    	NOFontVector lFonts = new NOFontVector(baseDoc);
    	basePage.getFonts(lFonts);
    
    	lFonts.elementAt(1).writeToFile(pOut);
    
    	NOPackage.destroyPackage(ref baseDoc);
    }
    
    
    public static void test_renderer_long()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/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;
    		byte[] lBuffer = new byte [lBufferLength];
    		NiXPS.memset(lBuffer,0,lBufferLength);
    		lPage.renderToImage(lBuffer,300,300,1,0);
    		// delete[] lBuffer;
    	}
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_renderer_totiff()
    {
    	string pIn="../../examples/testfiles/catalog.xps";
    	string pOut="../../examples/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;
    	byte[] lBuffer = new byte [lBufferLength];
    	NiXPS.memset(lBuffer,0,lBufferLength);
    	lPage.renderToImage(lBuffer,lOutSize,lOutSize,1,0);
    
    	NiXPS.NOUtility_write_tiff(lBuffer,System.Text.Encoding.UTF8.GetBytes(pOut),lOutSize,lOutSize);
    
    	// delete[] lBuffer;
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_renderer_topdf()
    {
    	string pIn="../../examples/testfiles/catalog.xps";
    	string pOut="../../examples/output/renderer_topdf.pdf";
    	NOPackage lPackage=NOPackage.readPackageFromFile(pIn);
    
    	NODocument lDoc=lPackage.getDocument(0);
    	NOProgressReporter lReporter = new NOProgressReporter();
    	lDoc.exportToPDF(pOut,lReporter);
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_renderer_topdf_package()
    {
    	string pIn="../../examples/testfiles/CoreProperty1.xps";
    	string pOut="../../examples/output/renderer_topdf_package.pdf";
    	NOPackage lPackage=NOPackage.readPackageFromFile(pIn);
    	
    	NOProgressReporter lReporter = new NOProgressReporter();
    	lPackage.exportToPDF(pOut,lReporter);
    	
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_renderer_tosvg()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/output/renderer_tosvg.svg";
    	NOPackage lPackage=NOPackage.readPackageFromFile(pIn);
    
    	NODocument lDoc=lPackage.getDocument(0);
    	NOPage lPage=lDoc.getPage(0);
    	lPage.exportToSVG(pOut);
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_create_glyphs_via_NOX()
    {
    	string pOut="../../examples/output/create_glyphs_via_NOX.xps";
    	// new destination document
    	NOPackage lPackage=NOPackage.createPackage(1,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
    	string lURI;
    	{
    		NOPackage lDummyPackage=NOPackage.readPackageFromFile("../../examples/testfiles/vdp.xps");
    		{
    			NOFontVector lFonts = new NOFontVector(lDummyPackage);
    			lDummyPackage.getDocument(0).getPage(0).getFonts(lFonts);
    			NOFont lFont=lPage.addFont(lFonts.elementAt(0));
    			lURI=lFont.getPartName();
    		}
    		NOPackage.destroyPackage(ref lDummyPackage);
    	}
    
    	// create a glyphs section in the canvas
    	NOXGlyphs lGlyphs=lCanvas.createGlyphs(0);
    	lGlyphs.intialize(10.0,("/"+lURI),50.0,50.0);
    
    	lGlyphs.setFill("#FF0000FF");
    
    	lGlyphs.setUnicodeString("abcdefghijklmnopqrstuvwxyz");
    
    	// write out and close
    	lPackage.writePackageToFile(pOut);
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_moveObjectsAndRenderToImage()
    {
    	string pOut="../../examples/output/moveObjectsAndRenderToImage.tiff";
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/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,1);
    
    	NiXPS.UInt32RectC lRect;
    	lRect.mTop=157;
    	lRect.mLeft=59;
    	lRect.mBottom=299;
    	lRect.mRight=538;
    
    	lPage.selectMarquee(ref lRect,600,400,0);
    
    	NOSelection lSelection=lPage.getCopyOfSelection();
    
    	double lPageSizeX=0;
    	double lPageSizeY=0;
    	lPage.getPageSize(ref lPageSizeX, ref 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,1);
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_documentstructure()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/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 = new NOString();
    		lEntry.getDescription(lString);
    
    		NOString lTarget = new NOString();
    		lEntry.getOutlineTarget(lTarget);
    
    		System.Console.Out.WriteLine( "Description:"    + lString.getUTF8String() 
    				+ " Level:"    	+ lEntry.getOutlineLevel()
    				+ " Target:"   	+ lTarget.getUTF8String() );
    	}
    
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_bookmark2()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/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 = new NOString();
    	lEntry.getOutlineTarget(lString);
    
    	UInt16 lPageID=0;
    	UInt32 lObjectID=0;
    	string lStr=lString.getUTF8String();
    	if (lDoc.resolveLink(lStr,ref lPageID,ref lObjectID)==0)
    		return;
    
    	System.Console.Out.WriteLine( "Page-ID:"		+ lPageID 
    		+ " Object-ID:"	+ lObjectID );
    }
    
    
    public static void test_calculateBoundingBox()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/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;
    		byte[] lBuffer = new byte [lBufferLength];
    		NiXPS.memset(lBuffer,0,lBufferLength);
    		lPage.renderToImage(lBuffer,10,10,1,0);
    
    		UInt32 lObjectID = lPage.findObjectAt(417,194,960,720);
    		lPage.clearSelection();
    		lPage.setSelection(lObjectID,1);
    
    		NOSelection lSelectedObjects = lPage.getCopyOfSelection();
    
    		NiXPS.doubleRectC lRect;
    		lRect=lPage.getBoundingBox(lSelectedObjects.getSelectedObject(0).mID);
    
    		System.Console.Out.WriteLine(  "[" + String.Format("{0:0.##}",lRect.mTop) + "," + String.Format("{0:0.##}",lRect.mBottom) + "," + String.Format("{0:0.##}",lRect.mLeft) + "," + String.Format("{0:0.##}",lRect.mRight) + "]" );
    
    		// delete[] lBuffer;
    	}
    }
    
    
    public static void test_interleave_pages()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/output/interleave_pages.xps";
    	string file_terms="../../examples/testfiles/vdp.xps";
    	string file_input=pIn;
    	string 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(1,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(ref lOutput);
    	NOPackage.destroyPackage(ref lInput);
    	NOPackage.destroyPackage(ref lTerms);
    }
    
    
    public static 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("../../examples/testfiles/angledtext.xps");
    	NODocument lDocument = lPackage.getDocument(0);
    	NOPage lPage = lDocument.getPage(0);
    
    	byte[] lBuffer = new byte [125 * 162 * 3];
    	lPage.renderToImage(lBuffer, 125, 162, 0, 0);
    
    	NiXPS.doubleRectC lRect1;
    	lRect1.mLeft = 346;
    	lRect1.mTop = 409;
    	lRect1.mBottom = 357;
    	lRect1.mRight = 361;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	lRect1.mBottom = 328;
    	lRect1.mRight = 369;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	//  297,404 . 431,203
    	// should select entire text
    	lRect1.mLeft = 297;
    	lRect1.mTop = 404;
    	lRect1.mBottom = 203;
    	lRect1.mRight = 431;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	// 366,324 . 378,275
    	// "n isocele"
    	lRect1.mLeft = 366;
    	lRect1.mTop = 324;
    	lRect1.mBottom = 275;
    	lRect1.mRight = 378;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	// 376,291 . 416,157
    	// "eles triangle, nearly."
    	lRect1.mLeft = 376;
    	lRect1.mTop = 291;
    	lRect1.mBottom = 157;
    	lRect1.mRight = 416;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	// 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(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    }
    
    
    public static void test_textareaselect2()
    {
    	NOPackage lPackage=NOPackage.readPackageFromFile("../../examples/testfiles/0inDashArray.xps");
    	NODocument lDocument = lPackage.getDocument(0);
    	NOPage lPage = lDocument.getPage(0);
    
    	byte[] lBuffer = new byte [125 * 162 * 3];
    	lPage.renderToImage(lBuffer, 125, 162, 0, 0);
    
    	NiXPS.doubleRectC lRect1;
    	//  101,193 . 168,240
    	lRect1.mLeft = 101;
    	lRect1.mTop = 193;
    	lRect1.mBottom = 240;
    	lRect1.mRight = 168;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    	// 184,194 . 78,254
    	lRect1.mLeft = 184;
    	lRect1.mTop = 194;
    	lRect1.mBottom = 254;
    	lRect1.mRight = 78;
    	lPage.selectTextMarquee(ref lRect1);
    
    	{
    		NiXPSObjects.NOTextSelection lTextSelection = lPage.getTextSelection();
    		UInt32 i = 0; for (; i < lTextSelection.getNumberOfSelections(); i++)
    		{
    			NiXPSObjects.NOString lString = lTextSelection.getSelectedTextPart(i);
    			string lstring = lString.getUTF8String();
    			System.Console.Out.WriteLine( lstring );
    		}
    	}
    
    }
    
    
    public static void test_generate_from_image_siena()
    {
    	string pOut="../../examples/output/siena.xps";
    	NOPackage lNewPackage = NOPackage.createFromImage("../../examples/testfiles/siena.jpg");
    	lNewPackage.writePackageToFile(pOut);
    	NOPackage.destroyPackage(ref lNewPackage);
    }
    
    
    public static void test_replace_text()
    {
    	string pIn="../../examples/testfiles/template.xps";
    	string pOut="../../examples/output/replace_text.xps";
    	NOPackage lPackage=NOPackage.readPackageFromFile(pIn);
        NODocument lDoc=lPackage.getDocument(0);
       
    	{
    		NOFontVector lFonts = new NOFontVector(lPackage);
    		lDoc.searchAndReplaceText("TAG_TO", "Other Text", lFonts, 1);
    		if (lFonts.size()>0)
    		{
    			if (lFonts.elementAt(0).replaceWithFile("../../examples/testfiles/Arial.ttf")==0)
    				return;
    		}
    	}
    
    	{
    		NOFontVector lFonts = new NOFontVector(lPackage);
    		lDoc.searchAndReplaceText("TAG_TO", "Other Text", lFonts, 0);
    	}
    
    	lPackage.writePackageToFile(pOut);
    	NOPackage.destroyPackage(ref lPackage);
    }
    
    
    public static void test_open_drawrectangle_save()
    {
    	string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps";
    	string pOut="../../examples/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("M 100,100 L 200,100 L 200,200 L 100,200 Z");
    
    	// color: ARGB - so full red, transparant overlay
    	lPath.setFill("#99FF0000");
    
    	// write the XPS file out
    	lPackage.writePackageToFile(pOut);
    
    	NOPackage.destroyPackage(ref lPackage);
    }