public static object PDNAnchorEdgeToAnchorEdge(PDNAnchorEdge anchorEdge)
        {
            Type  anchorEdgeType   = Util.GetAssemblyPaintDotNet().GetType("PaintDotNet.AnchorEdge");
            Array anchorEdgeValues = System.Enum.GetValues(anchorEdgeType);

            for (int i = 0; i < anchorEdgeValues.Length; i++)
            {
                if (anchorEdgeValues.GetValue(i).ToString().Equals(anchorEdge.ToString()))
                {
                    return(anchorEdgeValues.GetValue(i));
                }
            }

            throw new Exception("Could not convert anchor type: " + anchorEdge.ToString());
        }
        public static PaintDotNet.Document CanvasResize(PaintDotNet.Document doc, System.Drawing.Size newSize, PDNAnchorEdge anchor, PaintDotNet.ColorBgra background)
        {
            Type   canvasSizeActionType = GetAssemblyPaintDotNet().GetType("PaintDotNet.Actions.CanvasSizeAction");
            object anchorEdge           = PDNUtilities.PDNAnchorEdgeToAnchorEdge(anchor);

            PaintDotNet.Document newDoc = (PaintDotNet.Document)canvasSizeActionType.GetMethod("ResizeDocument").Invoke(null, new object[] { doc, newSize, anchorEdge, background });

            return(newDoc);
        }