protected override Item LoadItem(Item item, LoadOptions options)
        {
            Assert.ArgumentNotNull(item, "item");

            var itemData = new ItemData(item);

            var configuration = _helper.GetConfigurationForItem(itemData);

            if (configuration == null) return base.LoadItem(item, options);

            var sourceStore = configuration.Resolve<ISourceDataStore>();
            var targetStore = configuration.Resolve<ITargetDataStore>();

            var targetItem = targetStore.GetByPathAndId(itemData.Path, itemData.Id, itemData.DatabaseName);

            if (targetItem == null)
            {
                Log.Warn("Unicorn: Unable to load item because it was not serialized.", this);
                return base.LoadItem(item, options);
            }

            sourceStore.Save(targetItem);

            return Database.GetItem(item.Uri);
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Load only specific sheets with data and formulas
            // Other objects, items etc. would be discarded

            // Instantiate LoadOptions specified by the LoadFormat
            LoadOptions loadOptions7 = new LoadOptions(LoadFormat.Xlsx);

            // Set the LoadDataOption
            LoadDataOption dataOption = new LoadDataOption();
            // Specify the sheet(s) in the template file to be loaded
            dataOption.SheetNames = new string[] { "Sheet2" };
            dataOption.ImportFormula = true;
            // Only data and formatting should be loaded.
            loadOptions7.LoadDataAndFormatting = true;
            // Specify the LoadDataOption
            loadOptions7.LoadDataOptions = dataOption;

            // Create a Workbook object and opening the file from its path
            Workbook wb = new Workbook(dataDir + "Book1.xlsx", loadOptions7);
            Console.WriteLine("File data imported successfully!");
            // ExEnd:1
            
            }
        public static ApprovalStatus GetForKey(String code, LoadOptions options)
        {
            ApprovalStatus status = null;

            if (options == LoadOptions.DiskOnly)
            {
                status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
                cache[code] = status;
            }
            else
            {
                try
                {
                    status = cache[code];
                }
                catch (KeyNotFoundException ex)
                {
                    if (options == LoadOptions.CacheFirst)
                    {
                        status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
                        cache[code] = status;
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
            return status;
        }
        public static void Run() 
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a sample workbook and add some data inside the first worksheet
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["P30"].PutValue("This is sample data.");

            // Save the workbook in memory stream
            MemoryStream ms = new MemoryStream();
            workbook.Save(ms, SaveFormat.Xlsx);
            ms.Position = 0;

            // Now load the workbook from memory stream with A5 paper size
            LoadOptions opts = new LoadOptions(LoadFormat.Xlsx);
            opts.SetPaperSize(PaperSizeType.PaperA5);
            workbook = new Workbook(ms, opts);

            // Save the workbook in pdf format
            workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a5_out.pdf");

            // Now load the workbook again from memory stream with A3 paper size
            ms.Position = 0;
            opts = new LoadOptions(LoadFormat.Xlsx);
            opts.SetPaperSize(PaperSizeType.PaperA3);
            workbook = new Workbook(ms, opts);

            // Save the workbook in pdf format
            workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a3_out.pdf");
            // ExEnd:1          
        }
        public static void Run()
        {
            // ExStart:LoadWorkbookWithSpecificCultureInfoDateFormat
            using (var inputStream = new MemoryStream())
            {
                using (var writer = new StreamWriter(inputStream))
                {
                    writer.WriteLine("<html><head><title>Test Culture</title></head><body><table><tr><td>10-01-2016</td></tr></table></body></html>");
                    writer.Flush();

                    var culture = new CultureInfo("en-GB");
                    culture.NumberFormat.NumberDecimalSeparator = ",";
                    culture.DateTimeFormat.DateSeparator = "-";
                    culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
                    LoadOptions options = new LoadOptions(LoadFormat.Html);
                    options.CultureInfo = culture;

                    using (var workbook = new Workbook(inputStream, options))
                    {
                        var cell = workbook.Worksheets[0].Cells["A1"];
                        Assert.AreEqual(CellValueType.IsDateTime, cell.Type);
                        Assert.AreEqual(new DateTime(2016, 1, 10), cell.DateTimeValue);
                    }
                }
            }
            // ExEnd:LoadWorkbookWithSpecificCultureInfoDateFormat
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            string sampleFile = "Sample.out.xlsx";
            string samplePath = dataDir + sampleFile;

            // Create a sample workbook
            // and put some data in first cell of all 3 sheets
            Workbook createWorkbook = new Workbook();
            createWorkbook.Worksheets["Sheet1"].Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets.Add("Sheet2").Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets.Add("Sheet3").Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets["Sheet3"].IsVisible = false;
            createWorkbook.Save(samplePath);

            // Load the sample workbook
            LoadDataOption loadDataOption = new LoadDataOption();
            loadDataOption.OnlyVisibleWorksheet = true;
            LoadOptions loadOptions = new LoadOptions();
            loadOptions.LoadDataAndFormatting = true;
            loadOptions.LoadDataOptions = loadDataOption;

            Workbook loadWorkbook = new Workbook(samplePath, loadOptions);
            Console.WriteLine("Sheet1: A1: {0}", loadWorkbook.Worksheets["Sheet1"].Cells["A1"].Value);
            Console.WriteLine("Sheet1: A2: {0}", loadWorkbook.Worksheets["Sheet2"].Cells["A1"].Value);
            Console.WriteLine("Sheet1: A3: {0}", loadWorkbook.Worksheets["Sheet3"].Cells["A1"].Value);
        }
 public bool ConvertToRtfPwd(string source, string target, string password)
 {
     LoadOptions lo = new LoadOptions(password);
     Document doc = new Document(source, lo);
     doc.Save(target, SaveFormat.Rtf);
     return true;
 }
        static void Main(string[] args)
        {
            LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
            Workbook newWorkbook = new Workbook(TextFile, loadOptions);

            newWorkbook.Save(fileName);
        }
 /// <summary>
 /// Converts XmlDocument to XDocument using load options.
 /// </summary>
 /// <param name="document">
 /// The input document to be converted.
 /// </param>
 /// <param name="options">
 /// The options for the conversion.
 /// </param>
 /// <returns>
 /// Resulting XDocument.
 /// </returns>
 public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
 {
     using (XmlNodeReader reader = new XmlNodeReader(document))
     {
         return XDocument.Load(reader, options);
     }
 }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Define a new Workbook.
            Workbook workbook;

            // Set the load data option with selected sheet(s).
            LoadDataOption dataOption = new LoadDataOption();
            dataOption.SheetNames = new string[] { "Sheet2" };

            // Load the workbook with the spcified worksheet only.
            LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
            loadOptions.LoadDataOptions = dataOption;
            loadOptions.LoadDataAndFormatting = true;

            // Creat the workbook.
            workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

            // Perform your desired task.

            // Save the workbook.
            workbook.Save(dataDir+ "outputFile.out.xlsx");
            // ExEnd:1
            
        }
        public static void Run()
        {
            // ExStart:ReadVisioDiagram
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadSaveConvert();

            // Call the diagram constructor to load a VSD stream
            FileStream st = new FileStream(dataDir + "Drawing1.vsdx", FileMode.Open);
            Diagram vsdDiagram = new Diagram(st);
            st.Close();

            // Call the diagram constructor to load a VDX diagram
            Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx");

            /*
             * Call diagram constructor to load a VSS stencil
             * providing load file format
            */
            Diagram vssDiagram = new Diagram(dataDir + "Basic.vss", LoadFileFormat.VSS);

            /*
             * Call diagram constructor to load diagram from a VSX file
             * providing load options
            */
            LoadOptions loadOptions = new LoadOptions(LoadFileFormat.VSX);
            Diagram vsxDiagram = new Diagram(dataDir + "Drawing1.vsx", loadOptions);
            // ExEnd:ReadVisioDiagram
        }
 private static void DeserializeDatabase(bool force)
 {
     foreach (string path2 in Factory.GetDatabaseNames())
       {
     var options = new LoadOptions { ForceUpdate = force, DisableEvents = true };
     Manager.LoadTree(Path.Combine(PathUtils.Root, path2), options);
       }
 }
 public static XDocument ToXDocument(this XmlDocument xmlDocument, LoadOptions options = LoadOptions.None)
 {
     using (var nodeReader = new XmlNodeReader(xmlDocument))
     {
         nodeReader.MoveToContent();
         return XDocument.Load(nodeReader, options);
     }
 }
Exemple #14
0
 public bool ConvertToDocPwd(string source, string target, string password)
 {
     // TODO: Add logging
     LoadOptions lo = new LoadOptions(password);
     Document document = new Document(source, lo);
     document.Save(target, SaveFormat.Doc);
     return true;
 }
 public XmlActionResult(string xml, string fileName,
     EncodingType encoding = EncodingType.UTF8,
     LoadOptions loadOptions = System.Xml.Linq.LoadOptions.None)
 {
     XmlContent = xml;
     FileName = fileName;
     Encoding = encoding;
     LoadOptions = loadOptions;
 }
 private static string GetTargetDatabase(string path, LoadOptions options)
 {
     if (options.Database != null)
     {
         return options.Database.Name;
     }
     string path2 = PathUtils.UnmapItemPath(path, PathUtils.Root);
     ItemReference itemReference = ItemReference.Parse(path2);
     return itemReference.Database;
 }
Exemple #17
0
 /// <summary>
 /// Word转为图片
 /// </summary>
 /// <param name="source">word文件路径</param>
 /// <param name="target">图片保存的文件夹路径</param>
 /// <param name="resolution">分辨率</param>
 /// <param name="format">图片格式</param>
 public static bool ConverToImage(string source, string target, int resolution = 300, AsposeConvertDelegate d=null)
 {
     double percent = 0.0;
     int page = 0;
     int total = 0;
     double second = 0;
     string path = "";
     string message = "";
     DateTime startTime = DateTime.Now;
     if (!FileUtil.CreateDirectory(target))
     {
         throw new DirectoryNotFoundException();
     }
     if (!File.Exists(source))
     {
         throw new FileNotFoundException();
     }
     if (d != null)
     {
         second = (DateTime.Now - startTime).TotalSeconds;
         percent = 0.1;
         message = "正在解析文件!";
         d.Invoke(percent, page, total, second, path, message);
     }
     LoadOptions loadOptions = new LoadOptions();
     loadOptions.LoadFormat = LoadFormat.Auto;
     Document doc = new Document(source, loadOptions);
     total = doc.PageCount;
     if (d != null)
     {
         second = (DateTime.Now - startTime).TotalSeconds;
         percent = 0.2;
         message = "开始转换文件,共" + total + "页!";
         d.Invoke(percent, page, total, second, path, message);
     }
     logger.Info("ConverToImage - source=" + source + ", target=" + target + ", resolution=" + resolution + ", pageCount=" + total);
     for (page = 0; page < total; page++)
     {
         ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
         options.PrettyFormat = false;
         options.Resolution = resolution;
         options.PageIndex = page;
         options.PageCount = 1;
         path = target + "\\" + (page + 1) + ".png";
         doc.Save(path, options);
         if (d != null)
         {
             second = (DateTime.Now - startTime).TotalSeconds;
             percent = 0.2 + (page + 1) * 0.8 / total;
             message = "正在转换第" + (page + 1) + "/" + total + "页!";
             d.Invoke(percent, (page + 1), total, second, path, message);
         }
     }
     return true;
 }
Exemple #18
0
        /// <summary>
        /// This should be a part of the I/O layer
        /// </summary>
        /// <param name="loadOptions">Load options.</param>
        /// <param name="inputUri">This could be a file or a url</param>
        public static XDocument Load(string inputUri, LoadOptions loadOptions)
        {
            if (inputUri.Contains("://"))
            {
                using (Stream stream = UriResolver.GetStream(inputUri))
                {
                    return XDocument.Load(stream, loadOptions);
                }
            }

            return XDocument.Load(inputUri, loadOptions);
        }
 public static XRootNamespace Load(string xmlFile, LoadOptions options)
 {
     XRootNamespace root = new XRootNamespace();
     root.doc = System.Xml.Linq.XDocument.Load(xmlFile, options);
     XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
     if (typedRoot == null)
     {
         throw new LinqToXsdException("Invalid root element in xml document.");
     }
     root.rootObject = typedRoot;
     return root;
 }
Exemple #20
0
 public static XRoot Load(TextReader textReader, LoadOptions options)
 {
     XRoot root = new XRoot();
     root.doc = System.Xml.Linq.XDocument.Load(textReader, options);
     XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
     if (typedRoot == null)
     {
         throw new LinqToXsdException("Invalid root element in xml document.");
     }
     root.rootObject = typedRoot;
     return root;
 }
Exemple #21
0
 /// <summary>
 /// PPT转为图片
 /// </summary>
 /// <param name="source">源文件路径</param>
 /// <param name="target">图片保存的文件夹路径</param>
 /// <param name="dpi">dpi</param>
 /// <param name="format">图片格式</param>
 public static bool ConverToImage(string source, string target, float scale=1.5F, AsposeConvertDelegate d = null)
 {
     double percent = 0.0;
     int page = 0;
     int total = 0;
     double second = 0;
     string path = "";
     string message = "";
     DateTime startTime = DateTime.Now;
     if (!FileUtil.CreateDirectory(target))
     {
         throw new DirectoryNotFoundException();
     }
     if (!File.Exists(source))
     {
         throw new FileNotFoundException();
     }
     if (d != null)
     {
         second = (DateTime.Now - startTime).TotalSeconds;
         percent = 0.1;
         message = "正在解析文件!";
         d.Invoke(percent, page, total, second, path, message);
     }
     LoadOptions loadOptions = new LoadOptions();
     loadOptions.LoadFormat = LoadFormat.Auto;
     Presentation pre = new Presentation(source, loadOptions);
     total = pre.Slides.Count;
     if (d != null)
     {
         second = (DateTime.Now - startTime).TotalSeconds;
         percent = 0.2;
         message = "开始转换文件,共" + total + "页!";
         d.Invoke(percent, page, total, second, path, message);
     }
     logger.Info("ConverToImage - source=" + source + ", target=" + target + ", scale=" + scale + ", pageCount=" + total);
     for (page = 0; page < total; page++)
     {
         Slide slide = (Slide)pre.Slides[page];
         Bitmap bitmap = slide.GetThumbnail(scale, scale);
         path = target + "\\" + (page + 1) + "_.png";
         bitmap.Save(path, ImageFormat.Png);
         if (d != null)
         {
             second = (DateTime.Now - startTime).TotalSeconds;
             percent = 0.2 + (page + 1) * 0.8 / total;
             message = "正在转换第" + (page + 1) + "/" + total + "页!";
             d.Invoke(percent, (page + 1), total, second, path, message);
         }
     }
     return true;
 }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //Specify the LoadOptions
            LoadOptions opt = new LoadOptions();
            //Set the memory preferences
            opt.MemorySetting = MemorySetting.MemoryPreference;

            //Instantiate the Workbook
            //Load the Big Excel file having large Data set in it
            Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);
        }
 public static XRootNamespace Load(string xmlFile, LoadOptions options)
 {
     var root = new XRootNamespace {
                               _doc = XDocument.Load(xmlFile, options)
                             };
       var typedRoot = XTypedServices.ToXTypedElement(root._doc.Root, LinqToXsdTypeManager.Instance);
       if ((typedRoot == null))
       {
     throw new LinqToXsdException("Invalid root element in xml document.");
       }
       root._rootObject = typedRoot;
       return root;
 }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
             // Opening Microsoft Excel 2007 Xlsx Files
            // Instantiate LoadOptions specified by the LoadFormat.
            LoadOptions loadOptions2 = new LoadOptions(LoadFormat.Xlsx);

            // Create a Workbook object and opening the file from its path
            Workbook wbExcel2007 = new Workbook(dataDir + "Book_Excel2007.xlsx", loadOptions2);
            Console.WriteLine("Microsoft Excel 2007 workbook opened successfully!");
            // ExEnd:1
            }
Exemple #25
0
        public override void Init(Stream sourceStream, LoadOptions loadOptions = null)
        {
            if (sourceStream == null || loadOptions == null || loadOptions.audioStreamInfo == null) {
                throw new System.ArgumentException ("sourceStream and loadOptions.audioStreamInfo are required");
            }

            reader = new AtomicBinaryReader (sourceStream);

            // set all the audio stream info we know
            audioStreamInfo = loadOptions.audioStreamInfo;
            audioStreamInfo.lengthBytes = reader.StreamLength;

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

 // Instantiate LoadOptions specified by the LoadFormat.
            LoadOptions loadOptions4 = new LoadOptions(LoadFormat.CSV);

            // Create a Workbook object and opening the file from its path
            Workbook wbCSV = new Workbook(dataDir + "Book_CSV.csv", loadOptions4);
            Console.WriteLine("CSV file opened successfully!");
            // ExEnd:1
            }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            //Specify the LoadOptions
            LoadOptions opt = new LoadOptions();
            //Set the memory preferences
            opt.MemorySetting = MemorySetting.MemoryPreference;

            //Instantiate the Workbook
            //Load the Big Excel file having large Data set in it
            Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);
            
        }
Exemple #28
0
        public void Run(HelperCode.Configuration config, Authentication auth)
        {
            if (!Directory.Exists(outputPath))
            {
                Console.WriteLine("Create a directory at '{0}' or modify the outputPath variable in the application to reference an existing directory.", outputPath);
                return;
            }

            try
            {
                //Download the CSDL
                using (HttpClient httpClient = new HttpClient())
                {
                    httpClient.BaseAddress = new Uri(config.ServiceUrl);
                    httpClient.Timeout = new TimeSpan(0, 2, 0);
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", auth.AcquireToken().AccessToken);

                    HttpResponseMessage metadataResponse = httpClient.GetAsync("/api/data/$metadata").Result;
                    LoadOptions options = new LoadOptions();

                    csdl = XDocument.Parse(metadataResponse.Content.ReadAsStringAsync().Result, options);

                    Console.WriteLine("CSDL downloaded from {0}", config.ServiceUrl + "/api/data/$metadata");
                }

                //Retrieve a list of all the names in order to build links between documents.
             entityTypeNames =   getEntityTypesNames();
             complexTypeNames =   getComplexTypesNames();
             enumTypeNames =   getEnumTypesNames();

                //Retrieve information about entity relationships from the application metadata
               relationshipMetadata =    getRelationshipMetadata(entityTypeNames, config, auth);

                //Write each page
                writeEntityTypePage();

                writeActionsPage();

                writeFunctionsPage();

                writeEnumsPage();

                writeComplexTypesPage();

            }
            catch (TimeoutException ex) { DisplayException(ex); }

            catch (HttpRequestException ex) { DisplayException(ex); }
        }
        public static void Run()
        {
        // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
              // Get the Excel file into stream
            FileStream stream = new FileStream(dataDir + "Book_Excel97_2003.xls", FileMode.Open);

            // Instantiate LoadOptions specified by the LoadFormat.
            LoadOptions loadOptions1 = new LoadOptions(LoadFormat.Excel97To2003);

            // Create a Workbook object and opening the file from the stream
            Workbook wbExcel97 = new Workbook(stream, loadOptions1);
            Console.WriteLine("Microsoft Excel 97 - 2003 workbook opened successfully!");
            // ExEnd:1
            }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Specify the LoadOptions
            LoadOptions options = new LoadOptions();

            // Set the memory preferences
            options.MemorySetting = MemorySetting.MemoryPreference;

            // Load the Big Excel file having large Data set in it
            Workbook book = new Workbook(dataDir + "sample.xlsx", options);
            Console.WriteLine("File has been loaded successfully");
            // ExEnd:1
        }
Exemple #31
0
        /// <summary>
        /// Create a new <see cref="XDocument"/> containing the contents of the
        /// passed in <see cref="XmlReader"/>.
        /// </summary>
        /// <param name="reader">
        /// An <see cref="XmlReader"/> containing the XML to be read into the new
        /// <see cref="XDocument"/>.
        /// </param>
        /// <param name="options">
        /// A set of <see cref="LoadOptions"/>.
        /// </param>
        /// <returns>
        /// A new <see cref="XDocument"/> containing the contents of the passed
        /// in <see cref="XmlReader"/>.
        /// </returns>
        public static XDocument Load(XmlReader reader, LoadOptions options)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.ReadState == ReadState.Initial)
            {
                reader.Read();
            }
            XDocument d = new XDocument();

            if ((options & LoadOptions.SetBaseUri) != 0)
            {
                string baseUri = reader.BaseURI;
                if (baseUri != null && baseUri.Length != 0)
                {
                    d.SetBaseUri(baseUri);
                }
            }
            if ((options & LoadOptions.SetLineInfo) != 0)
            {
                IXmlLineInfo li = reader as IXmlLineInfo;
                if (li != null && li.HasLineInfo())
                {
                    d.SetLineInfo(li.LineNumber, li.LinePosition);
                }
            }
            if (reader.NodeType == XmlNodeType.XmlDeclaration)
            {
                d.Declaration = new XDeclaration(reader);
            }
            d.ReadContentFrom(reader, options);
            if (!reader.EOF)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedEndOfFile);
            }
            if (d.Root == null)
            {
                throw new InvalidOperationException(SR.InvalidOperation_MissingRoot);
            }
            return(d);
        }
Exemple #32
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Specify the load options and filter the data
            // We do not want to load charts
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.LoadFilter = new LoadFilter(LoadDataFilterOptions.All & ~LoadDataFilterOptions.Chart);

            // Load the workbook with specified load options
            Workbook workbook = new Workbook(dataDir + "sample.xlsx", loadOptions);

            // Save the workbook in output format
            workbook.Save(dataDir + "LoadExcelFileWithoutChart_out.pdf", SaveFormat.Pdf);
            // ExEnd:1
        }
Exemple #33
0
        internal static XElement LoadCore(XmlReader r, LoadOptions options)
        {
            r.MoveToContent();
            if (r.NodeType != XmlNodeType.Element)
            {
                throw new InvalidOperationException("The XmlReader must be positioned at an element");
            }
            XName    name = XName.Get(r.LocalName, r.NamespaceURI);
            XElement e    = new XElement(name);

            e.FillLineInfoAndBaseUri(r, options);

            if (r.MoveToFirstAttribute())
            {
                do
                {
                    // not sure how current Orcas behavior makes sense here though ...
                    if (r.LocalName == "xmlns" && r.NamespaceURI == XNamespace.Xmlns.NamespaceName)
                    {
                        e.SetAttributeValue(XNamespace.None.GetName("xmlns"), r.Value);
                    }
                    else
                    {
                        e.SetAttributeValue(XName.Get(r.LocalName, r.NamespaceURI), r.Value);
                    }
                    e.LastAttribute.FillLineInfoAndBaseUri(r, options);
                } while (r.MoveToNextAttribute());
                r.MoveToElement();
            }
            if (!r.IsEmptyElement)
            {
                r.Read();
                e.ReadContentFrom(r, options);
                r.ReadEndElement();
                e.explicit_is_empty = false;
            }
            else
            {
                e.explicit_is_empty = true;
                r.Read();
            }
            return(e);
        }
Exemple #34
0
        public void Implicit_Join_On_Nullable_NotNullable()
        {
            // Arrange
            var repository = new MemoryRepository(new CoreTestsMappingSourceManager());

            ClassG1 g1 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g1);

            ClassG1 g2 = new ClassG1()
            {
                RowId = Guid.NewGuid()
            };

            repository.Insert(g2);

            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g1.RowId.Value
            });
            repository.Insert(new ClassG2()
            {
                RowIdRef = g2.RowId.Value
            });

            // Act
            LoadOptions options = new LoadOptions();

            options.LoadWith <ClassG1>(g => g.ClassG2s);

            var reloadedG1 = repository.All <ClassG1>(options).Where(g => g.RowId == g1.RowId).First();

            // Assert
            Assert.IsNotNull(reloadedG1.ClassG2s);
            Assert.AreEqual(2, reloadedG1.ClassG2s.Count);
        }
Exemple #35
0
        static void FontSettingsWithLoadOptions()
        {
            // ExStart:FontSettingsWithLoadOptions
            // The path to the documents directory.
            string                dataDir          = RunExamples.GetDataDir_WorkingWithDocument();
            FontSettings          fontSettings     = new FontSettings();
            TableSubstitutionRule substitutionRule = fontSettings.SubstitutionSettings.TableSubstitution;

            // If "UnknownFont1" font family is not available then substitute it by "Comic Sans MS".
            substitutionRule.AddSubstitutes("UnknownFont1", new string[] { "Comic Sans MS" });

            LoadOptions lo = new LoadOptions();

            lo.FontSettings = fontSettings;
            Document doc = new Document(dataDir + "myfile.html", lo);

            // ExEnd:FontSettingsWithLoadOptions
            Console.WriteLine("\nFile created successfully.\nFile saved at " + dataDir);
        }
Exemple #36
0
        static void Main(string[] args)
        {
            string rootPath    = Path.GetFullPath(@"..\..\");
            string storagePath = Path.Combine(rootPath, @"Storage");
            string outputPath  = Path.Combine(rootPath, @"Output");
            string imagesPath  = Path.Combine(rootPath, @"Images");

            // setup a configuration
            SignatureConfig config = new SignatureConfig()
            {
                StoragePath = storagePath,
                OutputPath  = outputPath,
                ImagesPath  = imagesPath
            };

            // instantiating the handler
            SignatureHandler handler = new SignatureHandler(config);

            // setup PDF image signature options
            PdfSignImageOptions pdfImageSignatureOptions = new PdfSignImageOptions(@"Autograph_of_Benjamin_Franklin.png");

            pdfImageSignatureOptions.DocumentPageNumber = 1;
            pdfImageSignatureOptions.Top    = 500;
            pdfImageSignatureOptions.Width  = 50;
            pdfImageSignatureOptions.Height = 20;

            // Set a license if you have one
            License license = new License();

            license.SetLicense(@"GroupDocs.Signature3.lic");

            SaveOptions saveOptions = new SaveOptions(OutputType.String);
            // sign the document
            LoadOptions loadOptions = new LoadOptions();
            string      fileName    = handler.Sign <string>(@"candy.pdf", pdfImageSignatureOptions, saveOptions);

            Console.WriteLine("Document signed successfully. The output filename: {0}", fileName);

            loadOptions.Password = "******";
            fileName             = handler.Sign <string>(@"candyPassword123.pdf", pdfImageSignatureOptions, loadOptions, saveOptions);
            Console.WriteLine("Document signed successfully. The output filename: {0}", fileName);
        }
Exemple #37
0
        private void DisplayImage()
        {
            try
            {
                //check if we've reached the end of the images to show
                if (imageFileNameIndex >= imageFileNames.Length)
                {
                    slideShowTimer.Stop();
                    this.DialogResult = DialogResult.OK;
                }

                if (slideShowTimer.Enabled)
                {
                    LoadOptions lo = new LoadOptions();
                    if (imageIsCameraRaw[imageFileNameIndex])
                    {
                        lo.CameraRawEnabled = true;
                    }

                    if (imageXView1.Image != null)
                    {
                        imageXView1.Image.Dispose();
                        imageXView1.Image = null;
                    }
                    imageXView1.Image = ImageX.FromFile(imagXpress1, imageFileNames[imageFileNameIndex], imagePageNumbers[imageFileNameIndex], lo);

                    ImageLabel.Text = String.Format("{0}, Page: {1}, Image {2} of {3}", imageFileNames[imageFileNameIndex],
                                                    imagePageNumbers[imageFileNameIndex], imageFileNameIndex + 1, imageFileNames.Length);
                    //center label
                    ImageLabel.Left    = this.Width / 2 - ImageLabel.Width / 2;
                    ImageLabel.Visible = true;

                    imageFileNameIndex++;
                    slideShowTimer.Interval = 3000;
                }
            }
            catch (ImageXException)
            {
                //error loading image, don't interrupt slide show
                imageFileNameIndex++;
            }
        }
        public static Type ResolveByRef(this Type type, LoadOptions options)
        {
            ArgumentAssert.IsNotNull(type, "type");

            if (type.IsValueType)
            {
                if (options.IsSet(LoadOptions.ValueAsAddress))
                {
                    return(_byRefTypes(type));
                }
            }
            else
            {
                if (options.IsSet(LoadOptions.ReferenceAsAddress))
                {
                    return(_byRefTypes(type));
                }
            }
            return(type);
        }
Exemple #39
0
        public static LoadBase Create(LoadOptions info)
        {
            LoadBase load;

            switch (info.LoadType)
            {
            case LoadOptions.ELoadType.GCode: load = new LoadGCode(); break;

            case LoadOptions.ELoadType.HPGL: load = new LoadHPGL(); break;

            case LoadOptions.ELoadType.Image: load = new LoadImage(); break;

            case LoadOptions.ELoadType.ImageHole: load = new LoadImageHole(); break;

            default: return(null);
            }
            load.LoadOptions = info;

            return(load);
        }
Exemple #40
0
        public static void Run()
        {
            Console.WriteLine("Running example TiffDataRecovery");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create an instance of LoadOptions and set LoadOptions properties
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.DataRecoveryMode    = DataRecoveryMode.ConsistentRecover;
            loadOptions.DataBackgroundColor = Color.Red;

            // Create an instance of Image and load a damaged image by passing the instance of LoadOptions
            using (Image image = Image.Load(dataDir + "SampleTiff1.tiff", loadOptions))
            {
                // Do some work
            }

            Console.WriteLine("Finished example TiffDataRecovery");
        }
Exemple #41
0
        internal async Task ReadContentFromAsync(XmlReader r, LoadOptions o, CancellationToken cancellationToken)
        {
            if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
            {
                await ReadContentFromAsync(r, cancellationToken).ConfigureAwait(false);

                return;
            }
            if (r.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
            }

            ContentReader cr = new ContentReader(this, r, o);

            do
            {
                cancellationToken.ThrowIfCancellationRequested();
            }while (cr.ReadContentFrom(this, r, o) && await r.ReadAsync().ConfigureAwait(false));
        }
Exemple #42
0
        public static void SaveAsWord(this RichTextBox rich, string fileName)
        {
            string        content  = rich.Rtf;
            ASCIIEncoding encoding = new ASCIIEncoding();

            byte[]       dataBytes = encoding.GetBytes(content);
            MemoryStream stream    = new MemoryStream(dataBytes);

            LoadOptions loadOptions = new LoadOptions
            {
                LoadFormat = LoadFormat.Rtf
            };
            Document doc = new Document(stream, loadOptions);

            Stream outstream = File.OpenWrite(fileName);

            doc.Save(outstream, SaveFormat.Docx);
            stream.Close();
            outstream.Close();
        }
        /// <summary>
        /// Converts passed Serialized text into Custom.ItemWebAPI.Pipelines.Advance.Serialize.Entities:LoadOption object
        /// Remember for this at origin it should be serialized using XML Formatter
        /// </summary>
        /// <param name="arrBytes">XML text representation of LoadOption object</param>
        /// <returns>Custom.ItemWebAPI.Pipelines.Advance.Serialize.Entities.LoadOptions</returns>
        public static LoadOptions DeSerializeLoadOptions(string options)
        {
            LoadOptions loOptions = null;

            try
            {
                if (options != null && options.Length > 0)
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(LoadOptions));
                    using (TextReader reader = new StringReader(options))
                    {
                        loOptions = (LoadOptions)serializer.Deserialize(reader);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(loOptions);
        }
Exemple #44
0
        public async Task GetOption1()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(AzureUri);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(api + "/1");

                response.IsSuccessStatusCode.Should().BeTrue();

                if (response.IsSuccessStatusCode)
                {
                    LoadOptions l = await response.Content.ReadAsAsync <LoadOptions>();

                    l.Should().NotBeNull();
                }
            }
        }
        public static void Run()
        {
            // ExStart:PasswordProtectedDoc
            // ExFor:Document
            // ExFor:LoadOptions
            // ExFor:LoadOptions.DocumentPassword
            // ExSummary:Shows how to an encrypted document.

            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

            LoadOptions loadOptions = new LoadOptions {
                DocumentPassword = "******"
            };
            Document doc = new Document(dataDir + "Sample1.one", loadOptions);

            // ExEnd:PasswordProtectedDoc

            Console.WriteLine("\nPassword protected document loaded successfully.");
        }
Exemple #46
0
        public static void Run()
        {
            // ExStart:SpecifyFontsUsedWithPresentation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            byte[] memoryFont1 = File.ReadAllBytes("customfonts\\CustomFont1.ttf");
            byte[] memoryFont2 = File.ReadAllBytes("customfonts\\CustomFont2.ttf");

            ILoadOptions loadOptions = new LoadOptions();

            loadOptions.DocumentLevelFontSources.FontFolders = new string[] { "assets\\fonts", "global\\fonts" };
            loadOptions.DocumentLevelFontSources.MemoryFonts = new byte[][] { memoryFont1, memoryFont2 };
            using (IPresentation presentation = CreatePresentation("MyPresentation.pptx", loadOptions))
            {
                //work with the presentation
                //CustomFont1, CustomFont2 as well as fonts from assets\fonts & global\fonts folders and their subfolders are available to the presentation
            }
            // ExEnd:SpecifyFontsUsedWithPresentation
        }
Exemple #47
0
 void ReadContent(XmlReader reader, LoadOptions options)
 {
     if (reader.ReadState == ReadState.Initial)
     {
         reader.Read();
     }
     if (reader.NodeType == XmlNodeType.XmlDeclaration)
     {
         Declaration = new XDeclaration(
             reader.GetAttribute("version"),
             reader.GetAttribute("encoding"),
             reader.GetAttribute("standalone"));
         reader.Read();
     }
     ReadContentFrom(reader, options);
     if (Root == null)
     {
         throw new InvalidOperationException("The document element is missing.");
     }
 }
Exemple #48
0
        private static async Task <XDocument> LoadAsyncInternal(XmlReader reader, LoadOptions options, CancellationToken cancellationToken)
        {
            if (reader.ReadState == ReadState.Initial)
            {
                await reader.ReadAsync().ConfigureAwait(false);
            }

            XDocument d = InitLoad(reader, options);
            await d.ReadContentFromAsync(reader, options, cancellationToken).ConfigureAwait(false);

            if (!reader.EOF)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedEndOfFile);
            }
            if (d.Root == null)
            {
                throw new InvalidOperationException(SR.InvalidOperation_MissingRoot);
            }
            return(d);
        }
Exemple #49
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Filter worksheets using CustomLoadFilter class
            LoadOptions loadOpts = new LoadOptions();

            loadOpts.LoadFilter = new CustomLoadFilter();

            // Load the workbook with filter defined in CustomLoadFilter class
            Workbook workbook = new Workbook(dataDir + "sampleCustomFilter.xlsx", loadOpts);

            // Take the image of all worksheets one by one
            for (int i = 0; i < workbook.Worksheets.Count; i++)
            {
                // Access worksheet at index i
                Worksheet worksheet = workbook.Worksheets[i];

                // Create an instance of ImageOrPrintOptions
                // Render entire worksheet to image
                ImageOrPrintOptions imageOpts = new ImageOrPrintOptions();
                imageOpts.OnePagePerSheet = true;
                imageOpts.ImageFormat     = ImageFormat.Png;

                // Convert worksheet to image
                SheetRender render = new SheetRender(worksheet, imageOpts);
                render.ToImage(0, dataDir + worksheet.Name + ".png");
            }

            // ExEnd:1
        }
        protected void BTN_Attach_Click(object sender, EventArgs e)
        {
            QuoteName = (String.IsNullOrEmpty(QuoteName) ? "Aspose .NET Quote Generator" : QuoteName);
            Stream      stream      = GenerateStreamFromString(editor1.InnerText);
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.LoadFormat = LoadFormat.Html;

            Document myDoc = new Document(stream, loadOptions);

            MemoryStream memStream = new MemoryStream();

            myDoc.Save(memStream, SaveOptions.CreateSaveOptions(SaveFormat.Docx));


            byte[] byteData = memStream.ToArray();
            // Encode the data using base64.
            string encodedData = System.Convert.ToBase64String(byteData);

            Entity NewNote = new Entity("annotation");

            // Im going to add Note to entity
            NewNote.Attributes.Add("objectid", new EntityReference("quote", QuoteId));
            NewNote.Attributes.Add("subject", QuoteName);

            // Set EncodedData to Document Body
            NewNote.Attributes.Add("documentbody", encodedData);

            // Set the type of attachment
            NewNote.Attributes.Add("mimetype", @"application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            NewNote.Attributes.Add("notetext", "Document Created using template");

            // Set the File Name
            NewNote.Attributes.Add("filename", QuoteName + ".docx");
            Guid NewNoteId = Service.Create(NewNote);

            if (NewNoteId != Guid.Empty)
            {
                LBL_Message.Text = "Successfully added to Quote";
            }
        }
        public static async Task RoundtripSyncAsyncMatches_Stream(bool document, LoadOptions loadOptions, SaveOptions saveOptions)
        {
            // Roundtrip XML using synchronous and Stream
            MemoryStream syncOutput = new MemoryStream();

            using (Stream syncStream = FilePathUtil.getStream(GetTestFileName()))
            {
                if (document)
                {
                    XDocument syncDoc = XDocument.Load(syncStream, loadOptions);
                    syncDoc.Save(syncOutput, saveOptions);
                }
                else
                {
                    XElement syncElement = XElement.Load(syncStream, loadOptions);
                    syncElement.Save(syncOutput, saveOptions);
                }
            }

            // Roundtrip XML using asynchronous and Stream
            MemoryStream asyncOutput = new MemoryStream();

            using (Stream asyncStream = FilePathUtil.getStream(GetTestFileName()))
            {
                if (document)
                {
                    XDocument asyncDoc = await XDocument.LoadAsync(asyncStream, loadOptions, CancellationToken.None);

                    await asyncDoc.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
                }
                else
                {
                    XElement asyncElement = await XElement.LoadAsync(asyncStream, loadOptions, CancellationToken.None);

                    await asyncElement.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
                }
            }

            // Compare to make sure the synchronous and asynchronous results are the same
            Assert.Equal(syncOutput.ToArray(), asyncOutput.ToArray());
        }
Exemple #52
0
        /// <summary>
        /// Loads by copying Unity-imported `AudioClip`'s raw audio memory to native side. You are free to unload the `AudioClip`'s audio data without affecting what's loaded at the native side.
        ///
        /// Hard requirements :
        /// - Load type MUST be Decompress On Load so Native Audio could read raw PCM byte array from your compressed audio.
        /// - If you use Load In Background, you must call `audioClip.LoadAudioData()` beforehand and ensure that `audioClip.loadState` is `AudioDataLoadState.Loaded` before calling `NativeAudio.Load`. Otherwise it would throw an exception. If you are not using Load In Background but also not using Preload Audio Data, Native Audio can load for you if not yet loaded.
        /// - Must not be ambisonic.
        ///
        /// It supports all compression format, force to mono, overriding to any sample rate, and quality slider.
        ///
        /// If this is the first time loading any audio it will call `NativeAudio.Initialize()` automatically which might take a bit more time.
        ///
        /// [iOS] Loads an audio into OpenAL's output audio buffer. (Max 256) This buffer will be paired to one of 16 OpenAL source when you play it.
        ///
        /// [Android] Loads an audio into a `short*` array at unmanaged native side. This array will be pushed into one of available `SLAndroidSimpleBufferQueue` when you play it.
        /// The resampling of audio will occur at this moment to match your player's device native rate. The SLES audio player must be created to match the device rate
        /// to enable the special "fast path" audio. What's left is to make our audio compatible with that fast path player, which the resampler will take care of.
        ///
        /// You can change the sampling quality of SRC (libsamplerate) library per audio basis with the `LoadOptions` overload.
        /// </summary>
        /// <param name="audioClip">
        /// Hard requirements :
        /// - Load type MUST be Decompress On Load so Native Audio could read raw PCM byte array from your compressed audio.
        /// - If you use Load In Background, you must call `audioClip.LoadAudioData()` beforehand and ensure that `audioClip.loadState` is `AudioDataLoadState.Loaded` before calling `NativeAudio.Load`. Otherwise it would throw an exception. If you are not using Load In Background but also not using Preload Audio Data, Native Audio can load for you if not yet loaded.
        /// - Must not be ambisonic.
        /// </param>
        /// <returns> An object that stores a number. Native side can pair this number with an actual loaded audio data when you want to play it. You can `Play`, `Prepare`, or `Unload` with this object. `Load` returns null on error, for example : wrong name, or calling in Editor </returns>
        public static NativeAudioPointer Load(AudioClip audioClip, LoadOptions loadOptions)
        {
            AssertAudioClip(audioClip);
            if (!initialized)
            {
                NativeAudio.Initialize();
            }

            //We have to wait for GC to collect this big array, or you could do `GC.Collect()` immediately after.
            short[] shortArray = AudioClipToShortArray(audioClip);

#if UNITY_IOS
            int startingIndex = _SendByteArray(shortArray, shortArray.Length * 2, audioClip.channels, audioClip.frequency, loadOptions.resamplingQuality);
            if (startingIndex == -1)
            {
                throw new Exception("Error loading NativeAudio with AudioClip named : " + audioClip.name);
            }
            else
            {
                float length = _LengthBySource(startingIndex);
                return(new NativeAudioPointer(audioClip.name, startingIndex, length));
            }
#elif UNITY_ANDROID
            //The native side will interpret short array as byte array, thus we double the length.
            int startingIndex = sendByteArray(shortArray, shortArray.Length * 2, audioClip.channels, audioClip.frequency, loadOptions.resamplingQuality);


            if (startingIndex == -1)
            {
                throw new Exception("Error loading NativeAudio with AudioClip named : " + audioClip.name);
            }
            else
            {
                float length = lengthBySource(startingIndex);
                return(new NativeAudioPointer(audioClip.name, startingIndex, length));
            }
#else
            //Load is defined on editor so that autocomplete shows up, but it is a stub. If you mistakenly use the pointer in editor instead of forwarding to normal sound playing method you will get a null reference error.
            return(null);
#endif
        }
Exemple #53
0
        int loadTexture(string textureFileName, LoadOptions options)
        {
            int textureId = -1;

            try
            {
                Bitmap map = new Bitmap(textureFileName);
                textureId = loadTextureFromBitmap(map, options);
            }
            catch (FileNotFoundException e)
            {
                Logger.LogError(Logger.ErrorState.Limited, "Load texture did not find file:" + e.Message);
            }
            catch (ArgumentException e)
            {
                Logger.LogError(Logger.ErrorState.Limited, "Load texture did not find file:" + e.Message);
            }


            return(textureId);
        }
        public void TempFolder()
        {
            //ExStart
            //ExFor:LoadOptions.TempFolder
            //ExSummary:Shows how to use the hard drive instead of memory when loading a document.
            // When we load a document, various elements are temporarily stored in memory as the save operation occurs.
            // We can use this option to use a temporary folder in the local file system instead,
            // which will reduce our application's memory overhead.
            LoadOptions options = new LoadOptions();

            options.TempFolder = ArtifactsDir + "TempFiles";

            // The specified temporary folder must exist in the local file system before the load operation.
            Directory.CreateDirectory(options.TempFolder);

            Document doc = new Document(MyDir + "Document.docx", options);

            // The folder will persist with no residual contents from the load operation.
            Assert.That(Directory.GetFiles(options.TempFolder), Is.Empty);
            //ExEnd
        }
Exemple #55
0
        private void button1_Click(object sender, EventArgs e)
        {
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.LoadFormat = LoadFormat.WordML;
            Aspose.Words.Document doc = new Aspose.Words.Document("tmpTest.docx", loadOptions);

            using (Aspose.Words.Rendering.AsposeWordsPrintDocument printDocument = new Aspose.Words.Rendering.AsposeWordsPrintDocument(doc))
            {
                //PageSettings ps = Miles.Coro.Common.Print.PrintConfigManager.GetPageSettings(Doc.DocBuilder.ReportName);
                //printDocument.DefaultPageSettings = ps;

                PrintPreviewDialog previewDlg = new PrintPreviewDialog();
                previewDlg.Document                 = printDocument;
                previewDlg.ShowInTaskbar            = true;
                previewDlg.MinimizeBox              = true;
                previewDlg.PrintPreviewControl.Zoom = 1.5d;
                previewDlg.WindowState              = FormWindowState.Maximized;
                previewDlg.ShowDialog();
            }
        }
Exemple #56
0
        }//WarningCallback


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


            //Create load options and set the WarningCallback property
            //to catch warnings while loading workbook
            LoadOptions options = new LoadOptions();

            options.WarningCallback = new WarningCallback();

            //Load the source excel file
            Workbook book = new Workbook(dataDir + "sampleDuplicateDefinedName.xlsx", options);

            //Save the workbook
            book.Save(dataDir + "outputDuplicateDefinedName.xlsx");

            // ExEnd:GetWarningsWhileLoadingExcelFile
        }
Exemple #57
0
        private void Parse(DirectoryInfo directoryInfo)
        {
            var fileInfos = directoryInfo.GetFiles("*.item");

            foreach (var fileInfo in fileInfos)
            {
                var streamReader = new StreamReader(fileInfo.FullName);

                var syncItem = SyncItem.ReadItem(new Tokenizer(streamReader), true);
                var options  = new LoadOptions {
                    DisableEvents = true, ForceUpdate = true, UseNewID = false
                };

                ItemSynchronization.PasteSyncItem(syncItem, options, true);
            }

            foreach (var info in directoryInfo.GetDirectories())
            {
                Parse(info);
            }
        }
Exemple #58
0
        public static void Run()
        {
            string filePath           = TestFiles.SAMPLE_TXT_SHIFT_JS_ENCODED;
            string outputDirectory    = Utils.GetOutputDirectoryPath();
            string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");

            LoadOptions loadOptions = new LoadOptions
            {
                Encoding = Encoding.GetEncoding("shift_jis")
            };

            using (Viewer viewer = new Viewer(filePath, loadOptions))
            {
                HtmlViewOptions options =
                    HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);

                viewer.View(options);
            }

            Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
        }
Exemple #59
0
        public void LoadMetadata(
            [Parameter("Path to the source metadata extract file")]
            string metadataFile,
            [Parameter("Path to the load log file; if not specified, defaults to same path " +
                       "and name as the source metadata file.",
                       DefaultValue = null)]
            string logFile,
            LoadOptions options)
        {
            if (logFile == null || logFile == "")
            {
                logFile = Path.ChangeExtension(metadataFile, ".log");
            }

            // Ensure metadata file exists and logFile is writeable
            FileUtilities.EnsureFileExists(metadataFile);
            FileUtilities.EnsureFileWriteable(logFile);

            HFM.Try("Loading metadata",
                    () => HsvMetadataLoad.Load(metadataFile, logFile));
        }
        public void SetSpecifyFontFolders()
        {
            FontSettings fontSettings = new FontSettings();

            fontSettings.SetFontsFolders(new string[] { MyDir + @"MyFonts\", @"C:\Windows\Fonts\" }, true);

            // Using load options
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.FontSettings = fontSettings;
            Document doc = new Document(MyDir + "Rendering.doc", loadOptions);

            FolderFontSource folderSource = ((FolderFontSource)doc.FontSettings.GetFontsSources()[0]);

            Assert.AreEqual(MyDir + @"MyFonts\", folderSource.FolderPath);
            Assert.True(folderSource.ScanSubfolders);

            folderSource = ((FolderFontSource)doc.FontSettings.GetFontsSources()[1]);
            Assert.AreEqual(@"C:\Windows\Fonts\", folderSource.FolderPath);
            Assert.True(folderSource.ScanSubfolders);
        }