Exemplo n.º 1
0
 public void AddXObject(XObjectContentRecord xObject,
                        IPdfTokenScanner scanner,
                        ILookupFilterProvider filterProvider,
                        IResourceStore resourceStore)
 {
     if (top != null && xObject.Type == XObjectType.Image)
     {
         var image = XObjectFactory.ReadImage(xObject, scanner, filterProvider, resourceStore);
         top?.AddImage(image);
     }
 }
Exemplo n.º 2
0
        public void ApplyXObject(NameToken xObjectName)
        {
            var xObjectStream = resourceStore.GetXObject(xObjectName);

            // For now we will determine the type and store the object with the graphics state information preceding it.
            // Then consumers of the page can request the object(s) to be retrieved by type.
            var subType = (NameToken)xObjectStream.StreamDictionary.Data[NameToken.Subtype.Data];

            var state = GetCurrentState();

            var matrix = state.CurrentTransformationMatrix;

            if (subType.Equals(NameToken.Ps))
            {
                var contentRecord = new XObjectContentRecord(XObjectType.PostScript, xObjectStream, matrix, state.RenderingIntent,
                                                             state.CurrentStrokingColor?.ColorSpace ?? ColorSpace.DeviceRGB);

                xObjects[XObjectType.PostScript].Add(contentRecord);
            }
            else if (subType.Equals(NameToken.Image))
            {
                var contentRecord = new XObjectContentRecord(XObjectType.Image, xObjectStream, matrix, state.RenderingIntent,
                                                             state.CurrentStrokingColor?.ColorSpace ?? ColorSpace.DeviceRGB);

                images.Add(Union <XObjectContentRecord, InlineImage> .One(contentRecord));

                markedContentStack.AddXObject(contentRecord, pdfScanner, filterProvider, resourceStore);
            }
            else if (subType.Equals(NameToken.Form))
            {
                ProcessFormXObject(xObjectStream);
            }
            else
            {
                throw new InvalidOperationException($"XObject encountered with unexpected SubType {subType}. {xObjectStream.StreamDictionary}.");
            }
        }