Esempio n. 1
0
        public virtual void Render(
            PixelFarm.Drawing.Pdf.MyPdfDocument doc,
            Stream outputStream)
        {
            // Constructs an area tree renderer and supplies the renderer options
            PdfRenderer renderer = new PdfRenderer(outputStream);

            if (renderOptions != null)
            {
                renderer.Options = renderOptions;
            }

            // Create the stream-renderer.
            StreamRenderer sr = new StreamRenderer(renderer);

            // Create the tree builder and give it the stream renderer.
            FOTreeBuilder tb = new FOTreeBuilder();

            tb.SetStreamRenderer(sr);

            // Setup the mapping between xsl:fo elements and our fo classes.
            StandardElementMapping sem = new StandardElementMapping();

            sem.AddToBuilder(tb);
            //// Start processing the xml document.
            tb.Parse(doc);
        }
Esempio n. 2
0
        /// <summary>
        ///     Executes the conversion reading the source tree from the input
        ///     reader, converting it to a format dictated by the render and
        ///     writing it to the supplied output stream.
        /// </summary>
        /// <remarks>
        ///     The evaluation copy of this class will output an evaluation
        ///     banner to standard out
        /// </remarks>
        /// <param name="inputReader">
        ///     Reader that provides fast, non-cached, forward-only access
        ///     to XML data
        /// </param>
        /// <param name="outputStream">
        ///     Any subclass of the Stream class, e.g. FileStream
        /// </param>
        public void Render(XmlReader inputReader, Stream outputStream)
        {
            if (activeDriver != null)
            {
                throw new SystemException("ActiveDriver is set.");
            }

            try
            {
                activeDriver = this;

                try
                {
                    // Constructs an area tree renderer and supplies the renderer options
                    PdfRenderer renderer = new PdfRenderer(outputStream);

                    if (renderOptions != null)
                    {
                        renderer.Options = renderOptions;
                    }

                    // Create the stream-renderer.
                    StreamRenderer sr = new StreamRenderer(renderer);

                    // Create the tree builder and give it the stream renderer.
                    FOTreeBuilder tb = new FOTreeBuilder();
                    tb.SetStreamRenderer(sr);

                    // Setup the mapping between xsl:fo elements and our fo classes.
                    StandardElementMapping sem = new StandardElementMapping();
                    sem.AddToBuilder(tb);

                    // Start processing the xml document.
                    tb.Parse(inputReader);
                }
                finally
                {
                    if (CloseOnExit)
                    {
                        // Flush and close the output stream
                        outputStream.Flush();
                        outputStream.Close();
                    }
                }
            }
            finally
            {
                activeDriver = null;
            }
        }