示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        AcquireXmlWriterForFixedPage()
        {
            XmlWriter xmlWriter = null;

            if (_currentFixedPageWriterRef == 0)
            {
                _currentPageContentStream = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
                _currentResourceStream    = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);

                _currentResourceXmlWriter    = new XmlTextWriter(_currentResourceStream);
                _currentPageContentXmlWriter = new XmlTextWriter(_currentPageContentStream);

                _currentFixedPagePrintStream = XpsPrintStream.CreateXpsPrintStream();
                _currentFixedPageXmlWriter   = new XmlTextWriter(_currentFixedPagePrintStream, Encoding.UTF8);

                _currentFixedPageUri = _xpsManager.GenerateUniqueUri(XpsS0Markup.FixedPageContentType);

                _currentFixedPageLinkTargetStream = new List <String>();
            }

            _currentFixedPageWriterRef++;

            xmlWriter = _currentFixedPageXmlWriter;

            return(xmlWriter);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }