⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xdptest.cs

📁 PDF文件格式解析库源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using AnotherPDFLib.XFA;
using AnotherPDFLib.Forms;

namespace AnotherPDFLibTest
{
    public class XdpTest
    {

        public static XdpDocument CreateDocument()
        {
            XdpDocument xdp = new XdpDocument();
            xdp.Form.Name = "form1";
            xdp.Form.Locale = "zh_CN";
            xdp.Form.Layout = Layout.Flow;

            Page page = Page.A4.Landscape;
            page.Name = "LandscapePage";
            page.Margin = 30;
            page.MarginTop = 45;
            PageNumber pageNum = new PageNumber("- {0}-", new Font("宋体", 9));
            pageNum.Alignment = Alignment.BottomCenter;
            pageNum.Left = page.Size.Width / 2;
            pageNum.Bottom = page.Size.Height - page.MarginBottom;
            page.PageArea.Add(pageNum.BuildXfaNode());
            xdp.Form.PageSet.Add(page);

            Form table1 = new Table1().BuildForm(page);
            Form table2 = new Table2().BuildForm(page);
            Form table3 = new Table3().BuildForm(page);
            Form table4 = new Table4().BuildForm(page);
            Form table5 = new Table5().BuildForm(page);
            Form table6 = new Table6().BuildForm(page);

            xdp.Form.Controls.AddRange(new Control[]{
                table1,table2,table3,table4,table5,table6
            });
            return xdp;
        }

        public static XdpDocument CreateDocumentFromXFA()
        {
            XdpDocument xdp = new XdpDocument();
            //xdp.Form.name = "form1";
            //xdp.Form.locale = "zh_CN";
            //xdp.Form.layout = layout.tb;

            pageArea pagearea = new pageArea();
            pagearea.name = "Page1";
            pagearea.medium.stock = "a4";
            pagearea.medium.@short = measurement.millimeters(210);
            pagearea.medium.@long = measurement.millimeters(279);
            pagearea.medium.orientation = orientation.landscape;

            contentArea contentarea = new contentArea();
            contentarea.name = "content1";
            contentarea.x = measurement.millimeters(6);
            contentarea.y = measurement.millimeters(12);
            contentarea.w = measurement.millimeters(284);
            contentarea.h = measurement.millimeters(170);
            pagearea.Add(contentarea);


            //xdp.Form.pageSet.name = "masterpages";
            //xdp.Form.pageSet.Add(pagearea);

            text txt = new text();
            txt.value = "test";

            field field = new field();
            field.ui.control = new button();
            field.caption.value.internalvalue = txt;
            field.border.edge.thickness = measurement.millimeters(0.5F);
            field.x = measurement.millimeters(20);
            field.y = measurement.millimeters(50);

            draw lbl = new draw();
            lbl.x = measurement.millimeters(20);
            lbl.y = measurement.millimeters(70);
            lbl.value.internalvalue = txt;

            area area = new area();
            area.Add(field);
            area.Add(lbl);
            pagearea.Add(area);

            subform subform2 = new subform();
            subform2.name = "form2";
            subform2.x = measurement.points(15);
            subform2.y = measurement.points(15);
            subform2.w = measurement.points(300);
            subform2.h = measurement.points(300);
            subform2.@break.after = breakTarget.contentArea;
            subform2.@break.afterTarget = "content1";

            draw graph = new draw();
            graph.x = measurement.points(20);
            graph.y = measurement.points(20);
            graph.w = measurement.points(200);
            graph.h = measurement.points(200);

            arc circle = new arc();
            circle.edge.thickness = measurement.points(2);
            circle.fill.color.value = "255,255,255";
            graph.value.graph = circle;
            subform2.Add(graph);
            //xdp.Form.Add(subform2);

            subform subform3 = new subform();
            subform3.name = "form3";
            subform3.x = measurement.points(15);
            subform3.y = measurement.points(15);
            subform3.w = measurement.points(300);
            subform3.h = measurement.points(300);
            proto pr = new proto();
            pr.Add(subform3);
            //xdp.Form.Add(pr);
            return xdp;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -