Exemplo n.º 1
0
        private void AddImage(AsposePageDocumentInfo doc, string imageFile)
        {
            XpsDocument document = doc.Document as XpsDocument;

            string signatureImageName = imageFile;

            XpsPath path = document.AddPath(document.CreatePathGeometry("M 413.65,0 L 611.95,0 L 611.95,99.15 L 413.65,99.15 Z"));

            path.Clip = document.CreatePathGeometry("M 0.000008454,0 L 612,0 L 612,792 L 0.000008454,792 Z ");
            var imageBrush = document.CreateImageBrush(signatureImageName, new RectangleF(0, 0, 350.05f, 150.02f), new RectangleF(0, 0, 1f, 1f));

            imageBrush.Transform = document.CreateMatrix(198.3f, 0, 0, 99.15f, 413.65f, 0);
            imageBrush.TileMode  = XpsTileMode.None;
            path.Fill            = imageBrush;
        }
Exemplo n.º 2
0
        private void AddDrawing(AsposePageDocumentInfo doc, string signatureImageStr, string outPath)
        {
            byte[] imageBytes             = Convert.FromBase64String(signatureImageStr);
            var    signatureImageFileName = outPath.Replace("xps", "png");

            System.IO.File.WriteAllBytes(signatureImageFileName, imageBytes);

            XpsDocument document = doc.Document as XpsDocument;
            XpsPath     path     = document.AddPath(document.CreatePathGeometry("M 413.65,0 L 611.95,0 L 611.95,99.15 L 413.65,99.15 Z"));

            path.Clip = document.CreatePathGeometry("M 0.000008454,0 L 612,0 L 612,792 L 0.000008454,792 Z ");
            var imageBrush = document.CreateImageBrush(signatureImageFileName, new RectangleF(0, 0, 350.05f, 150.02f), new RectangleF(0, 0, 1f, 1f));

            imageBrush.Transform = document.CreateMatrix(198.3f, 0, 0, 99.15f, 413.65f, 0);
            imageBrush.TileMode  = XpsTileMode.None;
            path.Fill            = imageBrush;
        }
Exemplo n.º 3
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithImages();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Add Image
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 30,20 l 258.24,0 0,56.64 -258.24,0 Z"));

            //Creating a matrix is optional, it can be used for proper positioning
            path.RenderTransform = doc.CreateMatrix(0.7f, 0f, 0f, 0.7f, 0f, 20f);
            //Create Image Brush
            path.Fill = doc.CreateImageBrush(dataDir + "QL_logo_color.tif", new RectangleF(0f, 0f, 258.24f, 56.64f), new RectangleF(50f, 20f, 193.68f, 42.48f));
            // Save resultant XPS document
            doc.Save(dataDir + "AddImage_out.xps");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithImages();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Tile image
            // ImageBrush filled rectangle in the right top bellow
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 10,160 L 228,160 228,305 10,305"));

            path.Fill = doc.CreateImageBrush(dataDir + "R08LN_NN.jpg", new RectangleF(0f, 0f, 128f, 96f), new RectangleF(0f, 0f, 64f, 48f));
            ((XpsImageBrush)path.Fill).TileMode = XpsTileMode.Tile;
            path.Fill.Opacity = 0.5f;
            // Save resultant XPS document
            doc.Save(dataDir + "AddTiledImage_out.xps");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithTransparency();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            //Add Canvas to XpsDocument instance
            XpsCanvas canvas = doc.AddCanvas();
            // Rectangle with opacity masked by ImageBrush
            XpsPath path = canvas.AddPath(doc.CreatePathGeometry("M 10,180 L 228,180 228,285 10,285"));

            path.Fill        = doc.CreateSolidColorBrush(doc.CreateColor(1.0f, 0.0f, 0.0f));
            path.OpacityMask = doc.CreateImageBrush(dataDir + "R08SY_NN.tif", new RectangleF(0f, 0f, 128f, 192f),
                                                    new RectangleF(0f, 0f, 64f, 96f));
            ((XpsImageBrush)path.OpacityMask).TileMode = XpsTileMode.Tile;
            // Save resultant XPS document
            doc.Save(dataDir + "OpacityMask_out.xps");
            // ExEnd:1
        }