Beispiel #1
0
        [Test] //ExSkip
        public void ImageFolder()
        {
            Document doc = new Document(MyDir + "Rendering.docx");

            ImageUriPrinter callback = new ImageUriPrinter(ArtifactsDir + "XamlFlowImageFolderAlias");

            // Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
            // to modify how we save the document to the XAML save format.
            XamlFlowSaveOptions options = new XamlFlowSaveOptions();

            Assert.AreEqual(SaveFormat.XamlFlow, options.SaveFormat);

            // Use the "ImagesFolder" property to assign a folder in the local file system into which
            // Aspose.Words will save all the document's linked images.
            options.ImagesFolder = ArtifactsDir + "XamlFlowImageFolder";

            // Use the "ImagesFolderAlias" property to use this folder
            // when constructing image URIs instead of the images folder's name.
            options.ImagesFolderAlias = ArtifactsDir + "XamlFlowImageFolderAlias";

            options.ImageSavingCallback = callback;

            // A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
            // We must ensure the folder exists before the callback's streams can put their resources into it.
            Directory.CreateDirectory(options.ImagesFolderAlias);

            doc.Save(ArtifactsDir + "XamlFlowSaveOptions.ImageFolder.xaml", options);

            foreach (string resource in callback.Resources)
            {
                Console.WriteLine($"{callback.ImagesFolderAlias}/{resource}");
            }
            TestImageFolder(callback); //ExSkip
        }
Beispiel #2
0
        [Test] //ExSkip
        public void ImageFolder()
        {
            // Open a document which contains images
            Document doc = new Document(MyDir + "Rendering.docx");

            ImageUriPrinter callback = new ImageUriPrinter(ArtifactsDir + "XamlFlowImageFolderAlias");

            XamlFlowSaveOptions options = new XamlFlowSaveOptions
            {
                SaveFormat          = SaveFormat.XamlFlow,
                ImagesFolder        = ArtifactsDir + "XamlFlowImageFolder",
                ImagesFolderAlias   = ArtifactsDir + "XamlFlowImageFolderAlias",
                ImageSavingCallback = callback
            };

            // A folder specified by ImagesFolderAlias will contain the images instead of ImagesFolder
            // We must ensure the folder exists before the streams can put their images into it
            Directory.CreateDirectory(options.ImagesFolderAlias);

            doc.Save(ArtifactsDir + "XamlFlowSaveOptions.ImageFolder.xaml", options);

            foreach (string resource in callback.Resources)
            {
                Console.WriteLine($"{callback.ImagesFolderAlias}/{resource}");
            }
            TestImageFolder(callback); //ExSkip
        }
Beispiel #3
0
        //ExEnd

        private void TestImageFolder(ImageUriPrinter callback)
        {
            Assert.AreEqual(9, callback.Resources.Count);
            foreach (string resource in callback.Resources)
            {
                Assert.True(File.Exists($"{callback.ImagesFolderAlias}/{resource}"));
            }
        }