예제 #1
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Defining string variables to store paths to font folders & font file
            string fontFolder1 = dataDir + "Arial";
            string fontFolder2 = dataDir + "Calibri";
            string fontFile    = dataDir + "arial.ttf";

            // Setting first font folder with SetFontFolder method
            // Second parameter directs the API to search the subfolders for font files
            FontConfigs.SetFontFolder(fontFolder1, true);

            // Setting both font folders with SetFontFolders method
            // Second parameter prohibits the API to search the subfolders for font files
            FontConfigs.SetFontFolders(new string[] { fontFolder1, fontFolder2 }, false);

            // Defining FolderFontSource
            FolderFontSource sourceFolder = new FolderFontSource(fontFolder1, false);

            // Defining FileFontSource
            FileFontSource sourceFile = new FileFontSource(fontFile);

            // Defining MemoryFontSource
            MemoryFontSource sourceMemory = new MemoryFontSource(System.IO.File.ReadAllBytes(fontFile));

            // Setting font sources
            FontConfigs.SetFontSources(new FontSourceBase[] { sourceFolder, sourceFile, sourceMemory });
            // ExEnd:1
        }
예제 #2
0
        public static void Run()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            // Defining string variables to store paths to font folders & font file
            string fontFolder1 = sourceDir + "Arial";
            string fontFolder2 = sourceDir + "Calibri";
            string fontFile    = sourceDir + "Arial.ttf";

            // Setting first font folder with SetFontFolder method
            // Second parameter directs the API to search the subfolders for font files
            FontConfigs.SetFontFolder(fontFolder1, true);

            // Setting both font folders with SetFontFolders method
            // Second parameter prohibits the API to search the subfolders for font files
            FontConfigs.SetFontFolders(new string[] { fontFolder1, fontFolder2 }, false);

            // Defining FolderFontSource
            FolderFontSource sourceFolder = new FolderFontSource(fontFolder1, false);

            // Defining FileFontSource
            FileFontSource sourceFile = new FileFontSource(fontFile);

            // Defining MemoryFontSource
            MemoryFontSource sourceMemory = new MemoryFontSource(System.IO.File.ReadAllBytes(fontFile));

            // Setting font sources
            FontConfigs.SetFontSources(new FontSourceBase[] { sourceFolder, sourceFile, sourceMemory });

            Console.WriteLine("SetCustomFontFolders executed successfully.");
        }
예제 #3
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // config.EnableCors();
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                "DefaultApi",
                "api/{controller}/{action}/{id}",
                new { id = RouteParameter.Optional }
                );

            config.EnableCors();

            // Set aspose cells font folder
            FontConfigs.SetFontFolder(AppSettings.FontFolderPath, true);

            // Set GridJs cache/font folder
            var imageCacheDir = AppSettings.ImageCache;
            var fileCacheDir  = AppSettings.FileCache;

            if (!Directory.Exists(imageCacheDir))
            {
                Directory.CreateDirectory(imageCacheDir);
            }
            if (!Directory.Exists(fileCacheDir))
            {
                Directory.CreateDirectory(fileCacheDir);
            }
            GridJs.Config.PictureCacheDirectory = imageCacheDir;
            GridJs.Config.FileCacheDirectory    = fileCacheDir;
            GridJs.Config.SetFontFolder(AppSettings.FontFolderPath, true);

            // Set GridJs license
            var license = new GridJs.License();

            license.SetLicense("Aspose.Total.lic");
        }