public static void test_XPSDocumentFromMemoryBuffer() { string pIn = "../../examples/testfiles/catalog.xps"; NOPackage lPackage = NOPackage.readPackageFromFile(pIn); UInt32 lBufferSize = 1000 * 1000; // 1000 kb = 1M byte[] lBuffer = new byte[lBufferSize]; uint lFileSize = 0; lPackage.writePackageToBuffer(lBuffer, lBufferSize, ref lFileSize); MemoryStream lStream = new MemoryStream(lBuffer, 0, (int)lFileSize); string inMemoryPackageName = "memorystream://myXps.xps"; Uri packageUri = new Uri(inMemoryPackageName); Package lXPSPackage = Package.Open(lStream); //Add package to PackageStore PackageStore.AddPackage(packageUri,lXPSPackage); XpsDocument xpsDoc = new XpsDocument(lXPSPackage, CompressionOption.Maximum, inMemoryPackageName); FixedDocumentSequence fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence(); // Do operations on xpsDoc here // Note: Please note that you must keep the Package object // in PackageStore until you are completely done with it since // certain operations on XpsDocument can trigger delayed // resource loading from the package. PackageStore.RemovePackage(packageUri); xpsDoc.Close(); }When you download our SDK you can paste this test in. However you will need to change the threading model of the Main method to STAThread. You can do this by adding [STAThread] just before the Main method like so:
[STAThread] public static void Main(string[] args) { // ... rest of code }Hope this helps.
Subscribe to
Posts [Atom]