// Simple bar graph static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/Folder license.SetLicense("Aspose.Words.lic"); } //createing new document Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Write text on the document builder.Write("Simple Bar graph using Aspose.Words \t"); //select the chart type (here chartType is bar) Shape shape1 = builder.InsertChart(ChartType.Bar, 432, 252); // save the document in the given path doc.Save("SimpleBarGraph.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); //Shows how to access the current node in a document builder. Node curNode = builder.CurrentNode; Paragraph curParagraph = builder.CurrentParagraph; // Shows how to move a cursor position to a specified node. builder.MoveTo(doc.FirstSection.Body.LastParagraph); // Shows how to move a cursor position to the beginning or end of a document. builder.MoveToDocumentEnd(); builder.Writeln("This is the end of the document."); builder.MoveToDocumentStart(); builder.Writeln("This is the beginning of the document."); doc.Save("outputDocument.doc"); }
static void Main(string[] args) { //---------------------------------------------------- // NPOI //---------------------------------------------------- //XWPFDocument doc = new XWPFDocument(); //doc.CreateParagraph(); //using (FileStream sw = File.Create("blank.docx")) //{ // doc.Write(sw); //} //---------------------------------------------------- // Aspose.Words //---------------------------------------------------- // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); doc.Save("blank.docx"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); FindReplaceOptions options = new FindReplaceOptions { MatchCase = false, FindWholeWordsOnly = true }; builder.Writeln("This document will be saved as a .doc file."); // Replace all occurences of ".doc" with ".docx". doc.Sections[0].Range.Replace(".doc", ".docx", options); builder.Writeln("Sad, mad."); // Replace all occurrences of 'sad' and 'mad' found using a regex pattern with 'bad'. doc.Sections[1].Range.Replace(new Regex("[s|m]ad"), "bad"); doc.Save("FindandReplaceTextinDocuments.docx"); }
static void Main(string[] args) { _client = new ElasticClient(new Uri(ConfigurationManager.AppSettings["ElasticsearchBaseUri"])); Log.Logger = new LoggerConfiguration() .ReadFrom.AppSettings() .WriteTo.Console(LogEventLevel.Verbose) .WriteTo.RollingFile(new JsonFormatter(), ConfigurationManager.AppSettings["JsonLogFilePathFormat"], fileSizeLimitBytes: LogFileSizeLimitBytes, retainedFileCountLimit: RetainedLogFileCountLimit) .CreateLogger(); var license = new License(); license.SetLicense(".\\Aspose.Total.lic"); var output = new List <Ai>(); output.AddRange(DoWork("A-Z.docx", true)); output.AddRange(DoWork("R&D.docx", false)); WriteToEs(output); Console.WriteLine("Any key to exit..."); Console.ReadLine(); }
protected override void OnInitializeControls(EventArgs e) { base.OnInitializeControls(e); // Check for license and apply if exists string licenseFile = Server.MapPath("~/App_Data/Aspose.Words.lic"); if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); license.SetLicense(licenseFile); } if (!IsPostBack) { if (confirmation == null) { Response.Redirect("~/Web/BookTrip/TripForm.aspx"); return; } itinerary.DataSource = confirmation.Reservation.Itinerary.Flights; itinerary.DataBind(); Session.Remove(Constants.ReservationConfirmationKey); Session.Remove(Constants.SuggestedFlightsKey); } }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); // Enter a dummy field into the document. DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertField("MERGEFIELD Field"); // GetText will retrieve all field codes and special characters Console.WriteLine("GetText() Result: " + doc.GetText()); string text = doc.GetText(); text = text.Replace(ControlChar.Cr, ControlChar.CrLf); Console.WriteLine("Replaced text Result: " + text); }
public void Init() { string licensePath = AppDomain.CurrentDomain.BaseDirectory + @"bin\Aspose.Total.Product.Family.lic"; License L = new License(); L.SetLicense(licensePath); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // ----- Set Bookmark builder.StartBookmark("AsposeBookmark"); builder.Writeln("Text inside a bookmark."); builder.EndBookmark("AsposeBookmark"); // ----- Get Bookmark // By index. Bookmark bookmark1 = doc.Range.Bookmarks[0]; // By name. Bookmark bookmark2 = doc.Range.Bookmarks["AsposeBookmark"]; doc.Save("AsposeBookmarks.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // The path to the document which is to be processed. string filePath = "../../data/document.doc"; FileFormatInfo info = FileFormatUtil.DetectFileFormat(filePath); if (info.HasDigitalSignature) { Console.WriteLine(string.Format("Document {0} has digital signatures, they will be lost if you open/save this document with Aspose.Words.", new FileInfo(filePath).Name)); } else { Console.WriteLine("Document has no digital signature."); } }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); // Enter a dummy field into the document. DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertField("MERGEFIELD Field"); // "GetText()" will retrieve all field codes and special characters. Console.WriteLine("GetText() Result: " + doc.GetText()); string text = doc.GetText(); text = text.Replace(ControlChar.Cr, ControlChar.CrLf); Console.WriteLine("Replaced text Result: " + text); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Please make sure to visit "); // Specify font formatting for the hyperlink. builder.Font.Color = Color.Blue; builder.Font.Underline = Underline.Single; // Insert the link. builder.InsertHyperlink("Aspose Website", "http://www.aspose.com", false); // Revert to default formatting. builder.Font.ClearFormatting(); builder.Write(" for more information."); doc.Save("Insert_Hyperlink_In_Document.doc"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world! This is page 1."); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("This is page 2."); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("This is page 3."); // Create an ImageSaveOptions object to pass to the Save method. ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png); // Save each page of the document to the local file system as an individual PNG image. for (int i = 0; i < doc.PageCount; i++) { options.PageSet = new PageSet(i); doc.Save($"Convert_Doc_to_Png.Page {i}.png", options); } }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert an image from the local file system. builder.Writeln("Original size:"); Shape shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg"); builder.InsertParagraph(); builder.Writeln("Re-sized:"); shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg"); // To change the shape size. // ConvertUtil Provides helper functions to convert between various measurement units, such as inches to points. shape.Width = ConvertUtil.InchToPoint(0.5); shape.Height = ConvertUtil.InchToPoint(0.5); builder.Document.Save("Image_ReSize.docx"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Some text is added."); Comment comment = new Comment(doc, "Aspose", "As", new DateTime()); builder.CurrentParagraph.AppendChild(comment); comment.Paragraphs.Add(new Paragraph(doc)); comment.FirstParagraph.Runs.Add(new Run(doc, "Comment text.")); doc.Save("InsertComments.docx"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world! This is page 1."); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("This is page 2."); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("This is page 3."); // Save the document as multipage TIFF. doc.Save("Convert_WordPage_Document_to_MultipageTIFF.tiff"); }
public Form1() { InitializeComponent(); Aspose.Words.License li = new Aspose.Words.License(); li.SetLicense(new MemoryStream(Properties.Resources.Aspose_Total)); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } // Load a document that contains tables. Document doc = new Document("../../data/document.doc"); // Get the first and second table in the document. // The rows from the second table will be appended to the end of the first table. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true); Table secondTable = (Table)doc.GetChild(NodeType.Table, 1, true); // Append all rows from the current table to the next. // Due to the design of tables even tables with different cell count and widths can be joined into one table. while (secondTable.HasChildNodes) { firstTable.Rows.Add(secondTable.FirstRow); } // Remove the empty table container. secondTable.Remove(); doc.Save("JoiningTables.docx"); }
public static void GeneratePreliminaryReport(ReportData reportData, string templatePath, string reportPath) { reportType = "PDF"; //Applying a license Aspose.Words.License license = new Aspose.Words.License(); license.SetLicense("Aspose.Words.lic"); //Fetchind Document from the template path Document doc = new Document(templatePath); if (reportData != null) { DataTable dtMergeFields = reportData.NonTabularData.Tables[0]; if (dtMergeFields != null && dtMergeFields.Rows.Count > 0) { //Binding data in PDF ProcessAndBindData(ref doc, reportData); } } // doc.UpdateTableLayout(); doc.Save(reportPath, Aspose.Words.SaveFormat.Pdf); GC.Collect(); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } // Create the Dataset and read the XML. DataSet customersDs = new DataSet(); customersDs.ReadXml("../../data/Customers.xml"); // Open a template document. Document doc = new Document("../../data/TestFile XML.doc"); // Execute mail merge to fill the template with data from XML using DataTable. doc.MailMerge.Execute(customersDs.Tables["Customer"]); // Save the output document. doc.Save("MailMergefromXMLDataSource.docx"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); // If the default font defined here cannot be found during rendering then the closest font on the machine is used instead. FontSettings.DefaultInstance.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = "Courier New"; DocumentBuilder builder = new DocumentBuilder(doc); // Aspose.Words will use that default font in cases where we write text in an inaccessible font, such as this. builder.Font.Name = "Non-existent font"; builder.Write("Hello world!"); // Now, the set default font is used in place of any missing fonts during any rendering calls. doc.Save("SpecifyDefaultFonts.pdf"); doc.Save("SpecifyDefaultFonts.xps"); }
private void BTN_ApplyLicense_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.AddExtension = true; openFileDialog.Filter = "Aspose License File (*.lic)|*.lic"; if (openFileDialog.ShowDialog() == DialogResult.OK) { string LicenseFile = openFileDialog.FileName; try { if (LicenseFile != "") { if (File.Exists(LicenseFile)) { AsposeWords.License Lic = new AsposeWords.License(); Lic.SetLicense(LicenseFile); if (Lic.IsLicensed) { LBL_LicenseStatus.Text = "Licensed"; BTN_ApplyLicense.Enabled = false; } } } } catch (Exception) { LBL_LicenseStatus.Text = "License not applied"; } } }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Image Before ReSize"); //insert image from disk Shape shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg"); // write text in document builder.Write("Image After ReSize "); //insert image from disk for resize shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg"); // To change the shape size. ( ConvertUtil Provides helper functions to convert between various measurement units. like Converts inches to points.) shape.Width = ConvertUtil.InchToPoint(0.5); shape.Height = ConvertUtil.InchToPoint(0.5); // save new document builder.Document.Save("ImageReSize.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // Create the Dataset and read the XML. DataSet customersDs = new DataSet(); customersDs.ReadXml("../../data/Customers.xml"); // Open a template document. Document doc = new Document("../../data/TestFile XML.doc"); // Execute mail merge to fill the template with data from XML using DataTable. doc.MailMerge.Execute(customersDs.Tables["Customer"]); // Save the output document. doc.Save("TestFile XML Out.doc"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Access the current node in a document builder. Node curNode = builder.CurrentNode; Paragraph curParagraph = builder.CurrentParagraph; // Move the builder's cursor position to a specified node. builder.MoveTo(doc.FirstSection.Body.LastParagraph); // Move the builder's cursor position to the beginning or end of a document. builder.MoveToDocumentEnd(); builder.Writeln("This is the end of the document."); builder.MoveToDocumentStart(); builder.Writeln("This is the beginning of the document."); doc.Save("MovingTheCursor.docx"); }
static PDFCevirici() { if (AsposeExcelLisans != null) return; //LisansExcelAdres = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), // "\\Aspose.Cells.lic"); LisansExcelAdres = HttpContext.Current.Server.MapPath("~/App_Data/Aspose.Cells.lic"); if (!File.Exists(LisansExcelAdres)) throw new FileNotFoundException("Lisans dosyası bulunamadı! Aranan Dosya : " + LisansExcelAdres); AsposeExcelLisans = new Aspose.Cells.License(); AsposeExcelLisans.SetLicense(LisansExcelAdres); if (AsposeWordLisans != null) return; /* LisansWordAdres = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), "\\Aspose.Words.lic"); */ LisansWordAdres = HttpContext.Current.Server.MapPath("~/App_Data/Aspose.Words.lic"); AsposeWordLisans = new Aspose.Words.License(); AsposeWordLisans.SetLicense(LisansWordAdres); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // Load the document. Document doc = new Document("../../data/document.doc"); // Get the first and second table in the document. // The rows from the second table will be appended to the end of the first table. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true); Table secondTable = (Table)doc.GetChild(NodeType.Table, 1, true); // Append all rows from the current table to the next. // Due to the design of tables even tables with different cell count and widths can be joined into one table. while (secondTable.HasChildNodes) firstTable.Rows.Add(secondTable.FirstRow); // Remove the empty table container. secondTable.Remove(); doc.Save("Table.CombineTables Out.doc"); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Hello world!"); FindReplaceOptions options = new FindReplaceOptions { MatchCase = false, FindWholeWordsOnly = true }; // Replace all instances of "Hello" with "Greetings". doc.Range.Replace("Hello", "Greetings", options); }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } string filePath = "../../data/document.doc"; // Determine whether this document contains a digital signature. FileFormatInfo info = FileFormatUtil.DetectFileFormat(filePath); if (info.HasDigitalSignature) { Console.WriteLine($"Document {new FileInfo(filePath).Name} has digital signatures, they will be lost if you open/save this document with Aspose.Words.", new FileInfo(filePath).Name); } else { Console.WriteLine("Document has no digital signature."); } }
static void Main(string[] args) { // Check for an Aspose.Words license file in the local file system and apply it, if it exists. string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); // Use the license from the bin/debug/ Folder. license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use the document builder to insert a bookmark which encases text. builder.StartBookmark("AsposeBookmark"); builder.Writeln("Text inside a bookmark."); builder.EndBookmark("AsposeBookmark"); // Below are two ways of accessing a bookmark in a document. // 1 - By index: Bookmark bookmark1 = doc.Range.Bookmarks[0]; // 2 - By name: Bookmark bookmark2 = doc.Range.Bookmarks["AsposeBookmark"]; doc.Save("WorkingWithBookmarks.docx"); }
static void Main(string[] args) { string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Footers.doc"; // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document wordDocument = new Document(filePath); HeaderFooterCollection footers = wordDocument.FirstSection.HeadersFooters; foreach (HeaderFooter footer in footers) { if (footer.HeaderFooterType == HeaderFooterType.FooterFirst || footer.HeaderFooterType == HeaderFooterType.FooterPrimary || footer.HeaderFooterType == HeaderFooterType.FooterEven) { Console.WriteLine(footer.GetText()); } } }
static void Main(string[] args) { Console.Clear(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; //Console.WriteLine("开始读取文件夹中的文件..........."); Console.WriteLine("Begin reading files from the folder..........."); //注册序列号 string license = "Aspose.Total.NET.lic"; Aspose.Words.License license_word = new Aspose.Words.License(); Aspose.Cells.License license_cells = new Aspose.Cells.License(); license_word.SetLicense(license); license_cells.SetLicense(license); Import(); Clear(); TaskCase1(); TaskCase2(); TaskCase3(); TaskCase4(); //Console.WriteLine("程序运行结束..........."); Console.WriteLine("End of program..........."); Console.ReadKey(); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Some text is added."); Comment comment = new Comment(doc, "Aspose", "As", new DateTime()); builder.CurrentParagraph.AppendChild(comment); comment.Paragraphs.Add(new Paragraph(doc)); comment.FirstParagraph.Runs.Add(new Run(doc, "Comment text.")); doc.Save("insertedComments.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // define document file location string fileDir = "../../data/"; // load the document. Document doc = new Document(fileDir + "document.doc"); //Create an ImageSaveOptions object to pass to the Save method ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png); // Save each page of the document as Png in data folder for (int i = 0; i < doc.PageCount; i++) { options.PageIndex = i; doc.Save(string.Format(i + "WordDocumentAsPNG out.Png", i), options); } }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); string watermarkText = "Aspose.Words for .NET"; // Create a watermark shape. This will be a WordArt shape. // You are free to try other shape types as watermarks. Shape watermark = new Shape(doc, ShapeType.TextPlainText); // Set up the text of the watermark. watermark.TextPath.Text = watermarkText; watermark.TextPath.FontFamily = "Arial"; watermark.Width = 500; watermark.Height = 100; // Text will be directed from the bottom-left to the top-right corner. watermark.Rotation = -40; // Remove the following two lines if you need a solid black text. watermark.Fill.Color = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark watermark.StrokeColor = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark // Place the watermark in the page center. watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page; watermark.WrapType = WrapType.None; watermark.VerticalAlignment = VerticalAlignment.Center; watermark.HorizontalAlignment = HorizontalAlignment.Center; // Create a new paragraph and append the watermark to this paragraph. Paragraph watermarkPara = new Paragraph(doc); watermarkPara.AppendChild(watermark); // Insert the watermark into all headers of each document section. foreach (Section sect in doc.Sections) { // There could be up to three different headers in each section, since we want // the watermark to appear on all pages, insert into all headers. insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary); insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst); insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven); } doc.Save("waterMarks.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); Table table = builder.StartTable(); builder.InsertCell(); // Set the borders for the entire table. table.SetBorders(LineStyle.Single, 2.0, Color.Black); // Set the cell shading for this cell. builder.CellFormat.Shading.BackgroundPatternColor = Color.Red; builder.Writeln("Cell #1"); builder.InsertCell(); // Specify a different cell shading for the second cell. builder.CellFormat.Shading.BackgroundPatternColor = Color.Green; builder.Writeln("Cell #2"); // End this row. builder.EndRow(); // Clear the cell formatting from previous operations. builder.CellFormat.ClearFormatting(); // Create the second row. builder.InsertCell(); // Create larger borders for the first cell of this row. This will be different // compared to the borders set for the table. builder.CellFormat.Borders.Left.LineWidth = 4.0; builder.CellFormat.Borders.Right.LineWidth = 4.0; builder.CellFormat.Borders.Top.LineWidth = 4.0; builder.CellFormat.Borders.Bottom.LineWidth = 4.0; builder.Writeln("Cell #3"); builder.InsertCell(); // Clear the cell formatting from the previous cell. builder.CellFormat.ClearFormatting(); builder.Writeln("Cell #4"); doc.Save("Table.SetBordersAndShading Out.doc"); }
static void Main(string[] args) { //---------------------------------------------------- // NPOI //---------------------------------------------------- //const int emusPerInch = 914400; //const int emusPerCm = 360000; //XWPFDocument doc = new XWPFDocument(); //XWPFParagraph p2 = doc.CreateParagraph(); //XWPFRun r2 = p2.CreateRun(); //r2.SetText("test"); //var widthEmus = (int)(400.0 * 9525); //var heightEmus = (int)(300.0 * 9525); //using (FileStream picData = new FileStream("../../image/HumpbackWhale.jpg", FileMode.Open, FileAccess.Read)) //{ // r2.AddPicture(picData, (int)PictureType.PNG, "image1", widthEmus, heightEmus); //} //using (FileStream sw = File.Create("test.docx")) //{ // doc.Write(sw); //} //---------------------------------------------------- // Aspose.Words //---------------------------------------------------- // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("test"); var widthEmus = (int)(400.0 * 9525); var heightEmus = (int)(300.0 * 9525); builder.InsertImage("../../image/HumpbackWhale.jpg", widthEmus, heightEmus); doc.Save("test.docx"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Start building a the table. builder.StartTable(); builder.InsertCell(); builder.Write("Row 1, Cell 1 Content"); // Build the second cell builder.InsertCell(); builder.Write("Row 1, Cell 2 Content"); // End previous row and start new builder.EndRow(); // Build the first cell of 2nd row builder.InsertCell(); builder.Write("Row 2, Cell 1 Content"); builder.InsertCell(); builder.Write("Row 2, Cell 2 Content"); builder.EndRow(); // End the table builder.EndTable(); Range range = doc.Sections[0].Range; range.Delete(); String text = doc.Range.Text; System.Console.WriteLine(text); System.Console.ReadKey(); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); doc.AcceptAllRevisions(); doc.Save("AsposeAcceptChanges.doc", SaveFormat.Doc); }
public static void Main() { Aspose.Words.License license = new Aspose.Words.License(); // This line attempts to set a license from several locations relative to the executable and Aspose.Words.dll. // You can also use the additional overload to load a license from a stream, this is useful for instance when the // license is stored as an embedded resource try { license.SetLicense("Aspose.Words.lic"); } catch (Exception e) { // We do not ship any license with this example, visit the Aspose site to obtain either a temporary or permanent license. Console.WriteLine("There was an error setting the license: " + e.Message); } }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertImage("../../data/HumpbackWhale.jpg"); doc.Save("insertedImage.docx"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc1 = new Document("../../data/doc1.doc"); Document doc2 = new Document("../../data/doc2.doc"); Document doc3 = doc1.Clone(); doc3.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting); doc3.Save("appendedDocument.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } string fileDir = "../../data/"; // open the document Document doc = new Document(fileDir + "document.doc"); // Save the document as multipage TIFF. doc.Save("OutputTiff.tiff"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // The encoding of the text file is automatically detected. Document doc = new Document("../../data/LoadTxt.txt"); // Save as any Aspose.Words supported format, such as DOCX. doc.Save("AsposeLoadTxt_Out.docx"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } // Load the document. Document doc = new Document("../../data/document.doc"); // Get the first table in the document. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true); // We will split the table at the third row (inclusive). Row row = firstTable.Rows[2]; // Create a new container for the split table. Table table = (Table)firstTable.Clone(false); // Insert the container after the original. firstTable.ParentNode.InsertAfter(table, firstTable); // Add a buffer paragraph to ensure the tables stay apart. firstTable.ParentNode.InsertAfter(new Paragraph(doc), firstTable); Row currentRow; do { currentRow = firstTable.LastRow; table.PrependChild(currentRow); } while (currentRow != row); doc.Save("Table.SplitTable Out.doc"); }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a Form Field string[] items = { "One", "Two", "Three" }; builder.InsertComboBox("DropDown", items, 0); doc.Save("FormFieldTest.docx"); }
public MainForm() { InitializeComponent(); string wordsLicenseFile = Path.Combine(Application.StartupPath, "Aspose.Words.lic"); if (File.Exists(wordsLicenseFile)) { //This shows how to license Aspose.Words. //If you don't specify a license, Aspose.Words works in evaluation mode. Aspose.Words.License license = new Aspose.Words.License(); license.SetLicense(wordsLicenseFile); } string cellsLicenseFile = Path.Combine(Application.StartupPath, "Aspose.Cells.lic"); if (File.Exists(cellsLicenseFile)) { //This shows how to license Aspose.Cells. //If you don't specify a license, Aspose.Cells works in evaluation mode. Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense(cellsLicenseFile); } }
public static void Main(string[] args) { Aspose.Words.License license = new Aspose.Words.License(); // Set the license using a relative path to the location of the license on disk. // This same overload can be used to load the license from an explict path, embedded resource // to set the license try { // test test // some more text // even more license.SetLicense("Aspose.Words.lic"); } catch (Exception e) { // test test Console.WriteLine("There was an error setting the license: " + e.Message); } }
static void Main(string[] args) { string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Footers.doc"; // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document wordDocument = new Document(filePath); HeaderFooterCollection footers = wordDocument.FirstSection.HeadersFooters; foreach (HeaderFooter footer in footers) { if (footer.HeaderFooterType == HeaderFooterType.FooterFirst || footer.HeaderFooterType == HeaderFooterType.FooterPrimary || footer.HeaderFooterType == HeaderFooterType.FooterEven) Console.WriteLine(footer.GetText()); } }
static void Main(string[] args) { // Check for license and apply if exists string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic"; if (File.Exists(licenseFile)) { // Apply Aspose.Words API License Aspose.Words.License license = new Aspose.Words.License(); // Place license file in Bin/Debug/ Folder license.SetLicense("Aspose.Words.lic"); } Document doc = new Document("../../data/document.doc"); // If the default font defined here cannot be found during rendering then the closest font on the machine is used instead. FontSettings.DefaultInstance.DefaultFontName = "Arial Unicode MS"; // Now the set default font is used in place of any missing fonts during any rendering calls. doc.Save("Rendering.SetDefaultFont_Out.pdf"); doc.Save("Rendering.SetDefaultFont_Out.xps"); }