Пример #1
0
        private void createButton1_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            List <Group> groups = new List <Group>();

            for (int i = 1; i < 4; i++)
            {
                groups.Add(props.AddGroup("Layer " + i.ToString(), null));
            }
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            for (int i = 0; i < 1; i++)
            {
                doc.Page = doc.AddPage();
                Page   page   = (Page)doc.ObjectSoup[doc.Page];
                Writer writer = new Writer(props, page);
                foreach (Group group in groups)
                {
                    OptionalContent.Layer layer = writer.AddGroup(group);
                    writer.StartLayer(layer);
                    doc.AddText(group.EntryName.Text + "\r\n");
                    writer.EndLayer();
                    doc.AddText("Always Visible\r\n");
                    writer.StartLayer(layer);
                    doc.AddText(group.EntryName.Text + "\r\n\r\n");
                    writer.EndLayer();
                }
                doc.Flatten();
            }
            LoadPDF(doc);
        }
Пример #2
0
        private void createButton2_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            Group        parent = null;
            List <Group> groups = new List <Group>();

            // The Optional Content Group parent determines the nesting in the UI.
            // The presentation of the nesting is separate from the actual nesting
            // of visibility. In general you will want to ensure the two correspond
            // as in the code here.
            for (int i = 1; i <= 10; i++)
            {
                Group group = props.AddGroup("Layer " + i.ToString(), parent);
                groups.Add(group);
                parent = i == 5 ? null : group;
            }
            doc.Page     = doc.AddPage();
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            Page   page   = (Page)doc.ObjectSoup[doc.Page];
            Writer writer = new Writer(props, page);

            // This determines the nesting of actual visibility. Here we ensure that this
            // corresponds to the hierarchy specified in the UI so that it works in an
            // obvious way.
            for (int i = 0; i < groups.Count; i++)
            {
                Group group = groups[i];
                OptionalContent.Layer layer = writer.AddGroup(group);
                if (i == 5)
                {
                    while (writer.Depth > 0)
                    {
                        writer.EndLayer();
                    }
                }
                writer.StartLayer(layer);
                doc.AddText(group.EntryName.Text + "\r\n");
            }
            while (writer.Depth > 0)
            {
                writer.EndLayer();
            }
            doc.Flatten();
            LoadPDF(doc);
        }
Пример #3
0
        private void createButton3_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            List <Group> groups = new List <Group>();

            for (int i = 1; i < 4; i++)
            {
                groups.Add(props.AddGroup("Layer " + i.ToString(), null));
            }
            // membership policies are simple to use but limited in scope
            MembershipGroup alloff = props.AddMembershipGroup();

            alloff.Policy       = MembershipGroup.PolicyEnum.AllOff;
            alloff.PolicyGroups = groups;
            // membership visibility expressions are more complex but more powerful
            MembershipGroup mgve = props.AddMembershipGroup();
            ArrayAtom       ve   = mgve.MakeVisibilityExpression(MembershipGroup.LogicEnum.Or, groups);

            mgve.EntryVE = mgve.MakeVisibilityExpression(MembershipGroup.LogicEnum.Not, new ArrayAtom[] { ve });
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            for (int i = 0; i < 3; i++)
            {
                doc.Page = doc.AddPage();
                Page   page   = (Page)doc.ObjectSoup[doc.Page];
                Writer writer = new Writer(props, page);
                OptionalContent.Layer layer1 = writer.AddGroup(alloff);
                doc.AddText("The next line uses a Policy so that it is only visible if all layers are turned off...\r\n");
                writer.StartLayer(layer1);
                doc.AddText("I am normally invisible\r\n\r\n");
                writer.EndLayer();
                OptionalContent.Layer layer2 = writer.AddGroup(mgve);
                doc.AddText("The next line uses a Visibility Expression so that it is only visible if all layers are turned off...\r\n");
                writer.StartLayer(layer2);
                doc.AddText("I am normally invisible\r\n");
                writer.EndLayer();
                doc.Flatten();
            }
            LoadPDF(doc);
        }