static StandardElementMapping()
        {
            foObjs = new Hashtable();

            // Declarations and Pagination and Layout Formatting Objects
            foObjs.Add("root", Root.GetMaker());
            foObjs.Add("declarations", Declarations.GetMaker());
            foObjs.Add("color-profile", ColorProfile.GetMaker());
            foObjs.Add("page-sequence", PageSequence.GetMaker());
            foObjs.Add("layout-master-set", LayoutMasterSet.GetMaker());
            foObjs.Add("page-sequence-master", PageSequenceMaster.GetMaker());
            foObjs.Add("single-page-master-reference", SinglePageMasterReference.GetMaker());
            foObjs.Add("repeatable-page-master-reference", RepeatablePageMasterReference.GetMaker());
            foObjs.Add("repeatable-page-master-alternatives", RepeatablePageMasterAlternatives.GetMaker());
            foObjs.Add("conditional-page-master-reference", ConditionalPageMasterReference.GetMaker());
            foObjs.Add("simple-page-master", SimplePageMaster.GetMaker());
            foObjs.Add("region-body", RegionBody.GetMaker());
            foObjs.Add("region-before", RegionBefore.GetMaker());
            foObjs.Add("region-after", RegionAfter.GetMaker());
            foObjs.Add("region-start", RegionStart.GetMaker());
            foObjs.Add("region-end", RegionEnd.GetMaker());
            foObjs.Add("flow", Flow.Flow.GetMaker());
            foObjs.Add("static-content", StaticContent.GetMaker());
            foObjs.Add("title", Title.GetMaker());

            // Block-level Formatting Objects
            foObjs.Add("block", Block.GetMaker());
            foObjs.Add("block-container", BlockContainer.GetMaker());

            // Inline-level Formatting Objects
            foObjs.Add("bidi-override", BidiOverride.GetMaker());
            foObjs.Add("character", Character.GetMaker());
            foObjs.Add("initial-property-set", InitialPropertySet.GetMaker());
            foObjs.Add("external-graphic", ExternalGraphic.GetMaker());
            foObjs.Add("instream-foreign-object", InstreamForeignObject.GetMaker());
            foObjs.Add("inline", Inline.GetMaker());
            foObjs.Add("inline-container", InlineContainer.GetMaker());
            foObjs.Add("leader", Leader.GetMaker());
            foObjs.Add("page-number", PageNumber.GetMaker());
            foObjs.Add("page-number-citation", PageNumberCitation.GetMaker());

            // Formatting Objects for Tables
            foObjs.Add("table-and-caption", TableAndCaption.GetMaker());
            foObjs.Add("table", Table.GetMaker());
            foObjs.Add("table-column", TableColumn.GetMaker());
            foObjs.Add("table-caption", TableCaption.GetMaker());
            foObjs.Add("table-header", TableHeader.GetMaker());
            foObjs.Add("table-footer", TableFooter.GetMaker());
            foObjs.Add("table-body", TableBody.GetMaker());
            foObjs.Add("table-row", TableRow.GetMaker());
            foObjs.Add("table-cell", TableCell.GetMaker());

            // Formatting Objects for Lists
            foObjs.Add("list-block", ListBlock.GetMaker());
            foObjs.Add("list-item", ListItem.GetMaker());
            foObjs.Add("list-item-body", ListItemBody.GetMaker());
            foObjs.Add("list-item-label", ListItemLabel.GetMaker());

            // Dynamic Effects: Link and Multi Formatting Objects
            foObjs.Add("basic-link", BasicLink.GetMaker());
            foObjs.Add("multi-switch", MultiSwitch.GetMaker());
            foObjs.Add("multi-case", MultiCase.GetMaker());
            foObjs.Add("multi-toggle", MultiToggle.GetMaker());
            foObjs.Add("multi-properties", MultiProperties.GetMaker());
            foObjs.Add("multi-property-set", MultiPropertySet.GetMaker());

            // Out-of-Line Formatting Objects
            foObjs.Add("float", Float.GetMaker());
            foObjs.Add("footnote", Footnote.GetMaker());
            foObjs.Add("footnote-body", FootnoteBody.GetMaker());

            // Other Formatting Objects
            foObjs.Add("wrapper", Wrapper.GetMaker());
            foObjs.Add("marker", Marker.GetMaker());
            foObjs.Add("retrieve-marker", RetrieveMarker.GetMaker());
        }
Esempio n. 2
0
        internal void Parse(PixelFarm.Drawing.Pdf.MyPdfDocument doc)
        {
            //TEST CODE ONLY ***

            var root_maker = Root.GetMaker();
            //
            var layout_master_set_maker = LayoutMasterSet.GetMaker();
            var simplpe_page_master     = SimplePageMaster.GetMaker();
            var region_body             = RegionBody.GetMaker();
            var region_before           = RegionBefore.GetMaker();
            var region_after            = RegionAfter.GetMaker();

            //
            var pageSeq_maker = PageSequence.GetMaker();
            var flow_maker    = Flow.Flow.GetMaker();
            var block_maker   = Flow.Block.GetMaker();


            string nsuri = "http://www.w3.org/1999/XSL/Format";

            streamRenderer.StartRenderer();

            //1. root
            Root rootObj = CreateAndAppend <Root>(null,
                                                  root_maker,
                                                  nsuri,
                                                  "root",
                                                  CreateAttributes());
            //2.
            LayoutMasterSet masterSet = CreateAndAppend(rootObj, layout_master_set_maker, nsuri,
                                                        "layout-master-set",
                                                        CreateAttributes());
            {
                SimplePageMaster simpleMaster = CreateAndAppend(
                    masterSet, simplpe_page_master, nsuri,
                    "simple-page-master",
                    CreateAttributes(
                        new AttrKeyValue("master-name", "simple"),
                        new AttrKeyValue("page-height", "29.7cm"),
                        new AttrKeyValue("margin-top", "1cm"),
                        new AttrKeyValue("margin-bottom", "2cm"),
                        new AttrKeyValue("margin-left", "2.5cm"),
                        new AttrKeyValue("margin-right", "2.5cm")
                        ));
                RegionBody rgnBody = CreateAndAppend(simpleMaster, region_body, nsuri, "region-body",
                                                     CreateAttributes(new AttrKeyValue("margin-top", "3cm")));
                RegionBefore rgnBefore = CreateAndAppend(simpleMaster, region_before, nsuri, "region-before",
                                                         CreateAttributes(new AttrKeyValue("extent", "3cm")));
                RegionAfter rgnAfter = CreateAndAppend(simpleMaster, region_after, nsuri, "region-after",
                                                       CreateAttributes(new AttrKeyValue("extent", "1.5cm")));
                simpleMaster.End();
            }

            List <PixelFarm.Drawing.Pdf.MyPdfPage> pages = doc.Pages;
            int page_count = pages.Count;

            for (int i = 0; i < page_count; ++i)
            {
                PixelFarm.Drawing.Pdf.MyPdfPage   p      = pages[i];
                PixelFarm.Drawing.Pdf.MyPdfCanvas canvas = p.Canvas;

                PageSequence page_seq = CreateAndAppend(rootObj, pageSeq_maker, nsuri, "page-sequence",
                                                        CreateAttributes(new AttrKeyValue("master-reference", "simple")));

                Flow.Flow flow_obj = CreateAndAppend(page_seq, flow_maker, nsuri, "flow",
                                                     CreateAttributes(new AttrKeyValue("flow-name", "xsl-region-body")));

                Flow.Block block_obj = CreateAndAppend(
                    flow_obj, block_maker, nsuri, "block",
                    CreateAttributes(new AttrKeyValue("font-size", "18pt"),
                                     new AttrKeyValue("color", "black"),
                                     new AttrKeyValue("text-align", "center")
                                     ));

                //very simple
                List <PixelFarm.Drawing.Pdf.MyPdfTextBlock> textElems = canvas.TextElems;
                //first sample ,

                int elem_count = textElems.Count;
                for (int n = 0; n < elem_count; ++n)
                {
                    PixelFarm.Drawing.Pdf.MyPdfTextBlock textBlock = textElems[n];
                    string txt = textBlock.Text;
                    //
                    char[] charBuff = txt.ToCharArray();
                    block_obj.AddCharacters(charBuff, 0, charBuff.Length);
                }

                streamRenderer.Render(page_seq);
            }
            FonetDriver.ActiveDriver.FireFonetInfo("Parsing of document complete, stopping renderer");
            streamRenderer.StopRenderer();
        }