Created
January 7, 2020 07:49
-
-
Save aspose-com-gists/9d87de8e13e5ad79213ef7e37038e252 to your computer and use it in GitHub Desktop.
Aspose.Words for .NET - Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document("word.docx"); | |
// Provide PDFSaveOption compliance to PDF17 | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.Compliance = PdfCompliance.Pdf17; | |
// Convert Word to PDF | |
doc.Save("output.pdf", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document(); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
// Specify font formatting | |
Font font = builder.Font; | |
font.Size = 32; | |
font.Bold = true; | |
font.Color = System.Drawing.Color.Black; | |
font.Name = "Arial"; | |
font.Underline = Underline.Single; | |
// Insert text | |
builder.Writeln("This is the first page."); | |
builder.Writeln(); | |
// Change formatting for next elements. | |
font.Underline = Underline.None; | |
font.Size = 10; | |
font.Color = System.Drawing.Color.Blue; | |
builder.Writeln("This following is a table"); | |
// Insert a table | |
Table table = builder.StartTable(); | |
// Insert a cell | |
builder.InsertCell(); | |
// Use fixed column widths. | |
table.AutoFit(AutoFitBehavior.AutoFitToContents); | |
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; | |
builder.Write("This is row 1 cell 1"); | |
// Insert a cell | |
builder.InsertCell(); | |
builder.Write("This is row 1 cell 2"); | |
builder.EndRow(); | |
builder.InsertCell(); | |
builder.Write("This is row 2 cell 1"); | |
builder.InsertCell(); | |
builder.Write("This is row 2 cell 2"); | |
builder.EndRow(); | |
builder.EndTable(); | |
builder.Writeln(); | |
// Insert image | |
builder.InsertImage("image.png"); | |
// Insert page break | |
builder.InsertBreak(BreakType.PageBreak); | |
// all the elements after page break will be inserted to next page. | |
// Save the document | |
doc.Save("Document.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load document | |
Document doc = new Document("Document.docx"); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
// Access the paragraph | |
var paragraph=doc.Sections[0].Body.Paragraphs[0].Runs[0]; | |
paragraph.Text = "This is updated text"; | |
// Save the document | |
doc.Save("Document_updated.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the document from disk. | |
Document doc = new Document("document.docx"); | |
// Save as plain text | |
doc.Save("output.txt"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment