00001 #include "NOPage.h"
00002 #include "NOPackage.h"
00003
00004 using namespace NiXPSObjects;
00005
00006 void manipulateContentStream()
00007 {
00008 NOPackage *lPackage = NOPackage::readPackageFromFile("CoreProperty2.xps");
00009
00010
00011 NOPage lPage = lPackage->getDocument(0).getPage(0);
00012
00013
00014 UInt32 lPageContentLength = lPage.getContentStreamLength();
00015 UTF8Char *lPageContent = new UTF8Char[lPageContentLength + 1];
00016 lPage.getContentStream(lPageContent,lPageContentLength+1);
00017
00018 std::string lNewXML;
00019 lNewXML = "<Glyphs Name=\"a3\" BidiLevel=\"0\" Fill=\"#FF000000\" "
00020 "FontUri=\"/Documents/1/Resources/Fonts/301E55E6-2E6C-620E-337B-92143D57576B.odttf\" FontRenderingEmSize=\"11.04\" "
00021 "StyleSimulations=\"None\" OriginX=\"290\" OriginY=\"167.9\" UnicodeString=\"Test\"></Glyphs>";
00022
00023 std::string lStr(lPageContent,lPageContentLength);
00024 delete [] lPageContent;
00025
00026
00027 lStr.replace(1243, 459, lNewXML.c_str(), lNewXML.length());
00028
00029
00030 lPage.replaceContentStream(lStr.c_str(), lStr.length());
00031
00032
00033 lPackage->writePackageToFile("CoreProperty2-replaced.xps");
00034
00035 NOPackage::destroyPackage(lPackage);
00036 }