示例#1
0
        public static void Run(string outputPdfPath)
        {
            // Create an output document and set it's properties
            MergeDocument document = new MergeDocument(Util.GetResourcePath("PDFs/fw9_18.pdf"));

            document.Creator = "StampPDF";
            document.Author  = "ceTe Software";
            document.Title   = "Stamp PDF";

            // Create a template to place an image behind each page in the PDF
            Template backgroundTemplate = new Template();

            document.Template = backgroundTemplate;
            backgroundTemplate.Elements.Add(new BackgroundImage(Util.GetResourcePath("Images/DPDFLogo_Watermark.png")));

            // Create a label for the stamp and rotate it 20 degrees
            Label label = new Label("Stamped with Merger for .NET.", 0, 250, 500, 100, Font.Helvetica, 24, TextAlign.Center, RgbColor.Red);

            label.Angle = -20;

            // Create an anchor group to keep the label anchored regardless of page size
            AnchorGroup anchorGroup = new AnchorGroup(500, 100, Align.Center, VAlign.Top);

            anchorGroup.Add(label);

            // Create a stamp template and add the anchor group containing the label to it
            Template stampTemplate = new Template();

            document.StampTemplate = stampTemplate;
            stampTemplate.Elements.Add(anchorGroup);

            // Outputs the stamped document to the current web page
            document.Draw(outputPdfPath);
        }
示例#2
0
        public void Restore(BinaryReader reader, List <Gump> gumps)
        {
            var version = reader.ReadInt32();
            var count   = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var group      = new AnchorGroup();
                var groupGumps = group.Restore(reader, gumps);

                // Rebuild reverse map
                foreach (var g in groupGumps)
                {
                    this[g] = group;
                }
            }
        }
示例#3
0
        public void DropControl(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                AnchorDirection direction = GetAnchorDirection(host, x, y);

                if (this[host] == null)
                {
                    this[host] = new AnchorGroup(host);
                }

                if (this[host].IsEmptyDirection(host, direction))
                {
                    this[host].AnchorControlAt(draggedControl, host, direction);
                    this[draggedControl] = this[host];
                }
            }
        }
示例#4
0
        public void DropControl(AnchorableGump draggedControl, AnchorableGump host, int x, int y)
        {
            if (host.AnchorGroupName == draggedControl.AnchorGroupName && this[draggedControl] == null)
            {
                Point?relativePosition = GetAnchorDirection(draggedControl, host, x, y);
                if (relativePosition.HasValue)
                {
                    if (this[host] == null)
                    {
                        this[host] = new AnchorGroup(host);
                    }

                    if (this[host].IsEmptyDirection(draggedControl, host, relativePosition.Value))
                    {
                        this[host].AnchorControlAt(draggedControl, host, relativePosition.Value);
                        this[draggedControl] = this[host];
                    }
                }
            }
        }
示例#5
0
        public AnchorGroup this[AnchorableGump control]
        {
            get
            {
                AnchorGroup group = null;
                reverseMap.TryGetValue(control, out group);

                return(group);
            }

            private set
            {
                if (reverseMap.ContainsKey(control) && value == null)
                {
                    reverseMap.Remove(control);
                }
                else
                {
                    reverseMap.Add(control, value);
                }
            }
        }