GeneratePrintTicketResource( ContentType contentType, PrintTicket printTicket ) { IXpsOMPrintTicketResource printTicketResource = null; XpsPrintStream printTicketXpsStream = XpsPrintStream.CreateXpsPrintStream(); printTicket.SaveTo(printTicketXpsStream); IStream printTicketStream = printTicketXpsStream.GetManagedIStream(); Uri printTicketUri = _xpsManager.GeneratePrintTicketUri(contentType); try { IOpcPartUri printTicketPart = GenerateIOpcPartUri(printTicketUri); printTicketResource = _xpsOMFactory.CreatePrintTicketResource(printTicketStream, printTicketPart); } catch (COMException) { Invalidate(); throw new PrintingCanceledException(); } return(printTicketResource); }
AcquireResourceStreamForXpsColorContext( string resourceId ) { XpsResourceStream resourceStream = null; if (_currentXpsColorContextRef == 0) { try { XpsPrintStream colorContextStreamWrapper = XpsPrintStream.CreateXpsPrintStream(); Uri colorContextUri = _xpsManager.GenerateUniqueUri(XpsS0Markup.ColorContextContentType); _colorContextResourceStream = new XpsResourceStream(colorContextStreamWrapper, colorContextUri); IStream _colorIStream = colorContextStreamWrapper.GetManagedIStream(); IOpcPartUri partUri = GenerateIOpcPartUri(colorContextUri); IXpsOMColorProfileResource colorResource = _xpsOMFactory.CreateColorProfileResource(_colorIStream, partUri); IXpsOMColorProfileResourceCollection colorCollection = _xpsPartResources.GetColorProfileResources(); colorCollection.Append(colorResource); } catch (COMException) { Invalidate(); throw new PrintingCanceledException(); } } _currentXpsColorContextRef++; resourceStream = _colorContextResourceStream; return(resourceStream); }
AcquireResourceStreamForXpsFont( string resourceId ) { XpsResourceStream resourceStream = null; ResourceStreamCacheItem resourceStreamCacheItem = (ResourceStreamCacheItem)_fontsCache[resourceId]; if (resourceStreamCacheItem == null) { resourceStreamCacheItem = new ResourceStreamCacheItem(); // // We need to create the corresponding part in the Xps package // and then acquire the Stream // if (_currentFixedPageXmlWriter != null) { try { Uri uri = GenerateUriForObfuscatedFont(); IOpcPartUri partUri = GenerateIOpcPartUri(uri); XpsPrintStream fontStreamWrapper = XpsPrintStream.CreateXpsPrintStream(); IStream fontIStream = fontStreamWrapper.GetManagedIStream(); IXpsOMFontResource fontResource = _xpsOMFactory.CreateFontResource(fontIStream, XPS_FONT_EMBEDDING.XPS_FONT_EMBEDDING_OBFUSCATED, partUri, 1); IXpsOMFontResourceCollection fontCollection = _xpsPartResources.GetFontResources(); fontCollection.Append(fontResource); XpsResourceStream fontResourceStream = new XpsResourceStream(fontStreamWrapper, uri); resourceStreamCacheItem.XpsResourceStream = fontResourceStream; _fontsCache[resourceId] = resourceStreamCacheItem; resourceStream = fontResourceStream; } catch (COMException) { Invalidate(); throw new PrintingCanceledException(); } } else { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoFixedPageWriter)); } } else { resourceStream = resourceStreamCacheItem.XpsResourceStream; resourceStreamCacheItem.IncRef(); } return(resourceStream); }
AcquireResourceStreamForXpsImage( string resourceId ) { XpsResourceStream resourceStream = null; if (resourceId == null) { throw new ArgumentNullException(nameof(resourceId)); } ContentType contentType = new ContentType(resourceId); if (ContentType.Empty.AreTypeAndSubTypeEqual(contentType)) { throw new ArgumentException(SR.Get(SRID.ReachPackaging_InvalidContentType, contentType.ToString())); } if (_currentXpsImageRef == 0) { try { _currentImageType = GetXpsImageTypeFromContentType(contentType); XpsPrintStream imageStreamWrapper = XpsPrintStream.CreateXpsPrintStream(); Uri imageUri = _xpsManager.GenerateUniqueUri(contentType); _imageResourceStream = new XpsResourceStream(imageStreamWrapper, imageUri); IStream imageIStream = imageStreamWrapper.GetManagedIStream(); IOpcPartUri partUri = GenerateIOpcPartUri(imageUri); IXpsOMImageResource imageResource = _xpsOMFactory.CreateImageResource(imageIStream, _currentImageType, partUri); IXpsOMImageResourceCollection imageCollection = _xpsPartResources.GetImageResources(); imageCollection.Append(imageResource); } catch (COMException) { Invalidate(); throw new PrintingCanceledException(); } } _currentXpsImageRef++; resourceStream = _imageResourceStream; return(resourceStream); }