Пример #1
0
        public xObjects::XObject ToXObject(
            Document context
            )
        {
            xObjects::FormXObject form;

            {
                form           = new xObjects::FormXObject(context, Box);
                form.Resources = (Resources)(context.Equals(Document)
          ? Resources                // Same document: reuses the existing resources.
          : Resources.Clone(context) // Alien document: clones the resources.
                                             );

                // Body (contents).
                {
                    IBuffer       formBody           = form.BaseDataObject.Body;
                    PdfDataObject contentsDataObject = BaseDataObject.Resolve(PdfName.Contents);
                    if (contentsDataObject is PdfStream)
                    {
                        formBody.Append(((PdfStream)contentsDataObject).Body);
                    }
                    else
                    {
                        foreach (PdfDirectObject contentStreamObject in (PdfArray)contentsDataObject)
                        {
                            formBody.Append(((PdfStream)contentStreamObject.Resolve()).Body);
                        }
                    }
                }
            }
            return(form);
        }
Пример #2
0
        public override xObjects::XObject ToXObject(Document context)
        {
            xObjects::FormXObject xObject = new xObjects::FormXObject(context, Size);

            {
                PrimitiveComposer composer = new PrimitiveComposer(xObject);
                this.ToInlineObject(composer);
                composer.Flush();
            }
            return(xObject);
        }
Пример #3
0
        public ContentScanner(xObjects::FormXObject formXObject, SKCanvas canvas, SKSize size)
        {
            objects      =
                contents = formXObject.Contents;

            canvasSize      =
                contextSize = size;

            renderContext = canvas;
            MoveStart();
        }
Пример #4
0
        /**
         * <summary>Instantiates a child-level content scanner for <see cref="PdfClown.Documents.Contents.XObjects.FormXObject">external form</see>.</summary>
         * <param name="formXObject">External form.</param>
         * <param name="parentLevel">Parent scan level.</param>
         */
        public ContentScanner(xObjects::FormXObject formXObject, ContentScanner parentLevel)
        {
            this.parentLevel = parentLevel;
            objects          =
                contents     = formXObject.Contents;

            canvasSize      =
                contextSize = parentLevel.contextSize;

            renderContext = parentLevel.RenderContext;
            MoveStart();
        }
Пример #5
0
        public xObjects::XObject ToXObject(
            Document context
            )
        {
            File contextFile = context.File;

            xObjects::FormXObject form       = new xObjects::FormXObject(context);
            PdfStream             formStream = form.BaseDataObject;

            // Header.
            {
                PdfDictionary formHeader = formStream.Header;
                // Bounding box.
                formHeader[PdfName.BBox] = (PdfDirectObject)GetInheritableAttribute(PdfName.MediaBox).Clone(contextFile);
                // Resources.
                {
                    PdfDirectObject resourcesObject = GetInheritableAttribute(PdfName.Resources);
                    // Same document?
                    /* NOTE: Try to reuse the resource dictionary whenever possible. */
                    formHeader[PdfName.Resources] = (context.Equals(Document) ?
                                                     resourcesObject
            : (PdfDirectObject)resourcesObject.Clone(contextFile));
                }
            }

            // Body (contents).
            {
                IBuffer       formBody           = formStream.Body;
                PdfDataObject contentsDataObject = BaseDataObject.Resolve(PdfName.Contents);
                if (contentsDataObject is PdfStream)
                {
                    formBody.Append(((PdfStream)contentsDataObject).Body);
                }
                else
                {
                    foreach (PdfDirectObject contentStreamObject in (PdfArray)contentsDataObject)
                    {
                        formBody.Append(((PdfStream)File.Resolve(contentStreamObject)).Body);
                    }
                }
            }

            return(form);
        }
Пример #6
0
        /**
         * <summary>Instantiates a child-level content scanner for <see cref="org.pdfclown.documents.contents.xObjects.FormXObject">external form</see>.</summary>
         * <param name="formXObject">External form.</param>
         * <param name="parentLevel">Parent scan level.</param>
         */
        public ContentScanner(
            xObjects::FormXObject formXObject,
            ContentScanner parentLevel
            )
        {
            this.parentLevel = parentLevel;
            this.objects     = this.contents = formXObject.Contents;

            OnStart += delegate(
                ContentScanner scanner
                )
            {
                // Adjust the initial graphics state to the external form context!
                scanner.State.Ctm.Multiply(formXObject.Matrix);

                /*
                 * TODO: On rendering, clip according to the form dictionary's BBox entry!
                 */
            };
            MoveStart();
        }
Пример #7
0
   public override xObjects::XObject ToXObject(
 Document context
 )
   {
       xObjects::FormXObject xObject = new xObjects::FormXObject(context);
         {
       xObject.Size = Size;
       PrimitiveComposer composer = new PrimitiveComposer(xObject);
       this.ToInlineObject(composer);
       composer.Flush();
         }
         return xObject;
   }