Esempio n. 1
0
 public static void RenderDrawingMLToDisk(string dataDir, DrawingML drawingML)
 {
     //ExStart
     //ExFor:DrawingML.GetShapeRenderer
     //ExFor:ShapeRenderer.Save(String, ImageSaveOptions)
     //ExFor:DrawingML
     //ExId:RenderDrawingMLToDisk
     //ExSummary:Shows how to render a DrawingML image independent of the document to a JPEG image on the disk.
     // Save the DrawingML image to disk in JPEG format and using default options.
     drawingML.GetShapeRenderer().Save(dataDir + "TestFile.RenderDrawingML Out.jpg", null);
     //ExEnd
 }
Esempio n. 2
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir     = Path.GetFullPath("../../../Data/");
            string srcFileName = dataDir + "Test.docx";

            Console.WriteLine("Loading {0}. Size {1}.", srcFileName, GetFileSize(srcFileName));
            Document doc = new Document(srcFileName);

            // 220ppi Print - said to be excellent on most printers and screens.
            // 150ppi Screen - said to be good for web pages and projectors.
            // 96ppi Email - said to be good for minimal document size and sharing.
            const int desiredPpi = 150;

            // In .NET this seems to be a good compression / quality setting.
            const int jpegQuality = 90;

            // Resample images to desired ppi and save.
            int count = Resampler.Resample(doc, desiredPpi, jpegQuality);

            Console.WriteLine("Resampled {0} images.", count);

            if (count != 1)
            {
                Console.WriteLine("We expected to have only 1 image resampled in this test document!");
            }

            string dstFileName = srcFileName + ".Resampled Out.docx";

            doc.Save(dstFileName);
            Console.WriteLine("Saving {0}. Size {1}.", dstFileName, GetFileSize(dstFileName));

            // Verify that the first image was compressed by checking the new Ppi.
            doc = new Document(dstFileName);
            DrawingML shape    = (DrawingML)doc.GetChild(NodeType.DrawingML, 0, true);
            double    imagePpi = shape.ImageData.ImageSize.WidthPixels / ConvertUtil.PointToInch(shape.Size.Width);

            Debug.Assert(imagePpi < 150, "Image was not resampled successfully.");

            Console.WriteLine("Press any key.");
            Console.ReadLine();
        }
Esempio n. 3
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Load the documents which store the shapes we want to render.
            Document doc  = new Document(dataDir + "TestFile.doc");
            Document doc2 = new Document(dataDir + "TestFile.docx");

            // Retrieve the target shape from the document. In our sample document this is the first shape.
            Shape     shape     = (Shape)doc.GetChild(NodeType.Shape, 0, true);
            DrawingML drawingML = (DrawingML)doc2.GetChild(NodeType.DrawingML, 0, true);

            // Test rendering of different types of nodes.
            RenderShapeToDisk(dataDir, shape);
            RenderShapeToStream(dataDir, shape);
            RenderShapeToGraphics(dataDir, shape);
            RenderDrawingMLToDisk(dataDir, drawingML);
            RenderCellToImage(dataDir, doc);
            RenderRowToImage(dataDir, doc);
            RenderParagraphToImage(dataDir, doc);
            FindShapeSizes(shape);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            // Sample infrastructure.
            string exeDir  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar;
            string dataDir = new Uri(new Uri(exeDir), @"../../Data/").LocalPath;

            // Load the documents which store the shapes we want to render.
            Document doc  = new Document(dataDir + "RenderShapes.doc");
            Document doc2 = new Document(dataDir + "RenderShapes.docx");

            // Retrieve the target shape from the document. In our sample document this is the first shape.
            Shape     shape     = (Shape)doc.GetChild(NodeType.Shape, 0, true);
            DrawingML drawingML = (DrawingML)doc2.GetChild(NodeType.DrawingML, 0, true);

            // Test rendering of different types of nodes.
            RenderShapeToDisk(dataDir, shape);
            RenderShapeToStream(dataDir, shape);
            RenderShapeToGraphics(dataDir, shape);
            RenderDrawingMLToDisk(dataDir, drawingML);
            RenderCellToImage(dataDir, doc);
            RenderRowToImage(dataDir, doc);
            RenderParagraphToImage(dataDir, doc);
            FindShapeSizes(shape);
        }
Esempio n. 5
0
 public static void RenderDrawingMLToDisk(string dataDir, DrawingML drawingML)
 {
     //ExStart
     //ExFor:DrawingML.GetShapeRenderer
     //ExFor:ShapeRenderer.Save(String, ImageSaveOptions)
     //ExFor:DrawingML
     //ExId:RenderDrawingMLToDisk
     //ExSummary:Shows how to render a DrawingML image independent of the document to a JPEG image on the disk.
     // Save the DrawingML image to disk in JPEG format and using default options.
     drawingML.GetShapeRenderer().Save(dataDir + "TestFile.RenderDrawingML Out.jpg", null);
     //ExEnd
 }