public static void Run() { // ExStart:RowAndColumnFormat // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables(); // Instantiate Pdf document object Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Create a section in the Pdf Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); // Create a table Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table(); // Add table in the paragraphs collection of the section sec1.Paragraphs.Add(tab1); // Set the column widths of the table tab1.ColumnWidths = "60 100 100"; // Create a TextInfo instance Aspose.Pdf.Generator.TextInfo tinfo = new Aspose.Pdf.Generator.TextInfo(); // Set the font name to "Courier" for the TextInfo object tinfo.FontName = "Courier"; // Set default table border using the BorderInfo object tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F); // Apply the text format settings in TextInfo object to table cells tab1.DefaultCellTextInfo = tinfo; // Create an array of double values double[] darr = new Double[] { 1.5, 3.1415926, 100000, 20, 4000, 30.4512, 45.67, 890, 23.45 }; // Import the values in array to table tab1.ImportArray(darr, 0, 0, false); // Set background color for the first row Aspose.Pdf.Generator.TextInfo tinfo1 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo; tinfo1.BackgroundColor = new Aspose.Pdf.Generator.Color("#0000ff"); tab1.Rows[0].DefaultCellTextInfo = tinfo1; // Align text in the last column to right hand side Aspose.Pdf.Generator.TextInfo tinfo2 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo; tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right; tab1.SetColumnTextInfo(2, tinfo2); // We have to reset text format settings of the upper right cell tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right; tab1.Rows[0].Cells[2].DefaultCellTextInfo = tinfo1; // Save the Pdf pdf1.Save(dataDir + "RowAndColumnFormat_out.pdf"); // ExEnd:RowAndColumnFormat }
public static void Run() { // ExStart:RowAndColumnFormat // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables(); // Instantiate Pdf document object Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Create a section in the Pdf Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); // Create a table Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table(); // Add table in the paragraphs collection of the section sec1.Paragraphs.Add(tab1); // Set the column widths of the table tab1.ColumnWidths = "60 100 100"; // Create a TextInfo instance Aspose.Pdf.Generator.TextInfo tinfo = new Aspose.Pdf.Generator.TextInfo(); // Set the font name to "Courier" for the TextInfo object tinfo.FontName = "Courier"; // Set default table border using the BorderInfo object tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F); // Apply the text format settings in TextInfo object to table cells tab1.DefaultCellTextInfo = tinfo; // Create an array of double values double[] darr = new Double[] { 1.5, 3.1415926, 100000, 20, 4000, 30.4512, 45.67, 890, 23.45 }; // Import the values in array to table tab1.ImportArray(darr, 0, 0, false); // Set background color for the first row Aspose.Pdf.Generator.TextInfo tinfo1 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo; tinfo1.BackgroundColor = new Aspose.Pdf.Generator.Color("#0000ff"); tab1.Rows[0].DefaultCellTextInfo = tinfo1; // Align text in the last column to right hand side Aspose.Pdf.Generator.TextInfo tinfo2 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo; tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right; tab1.SetColumnTextInfo(2, tinfo2); // We have to reset text format settings of the upper right cell tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right; tab1.Rows[0].Cells[2].DefaultCellTextInfo = tinfo1; // Save the Pdf pdf1.Save(dataDir + "RowAndColumnFormat_out_.pdf"); // ExEnd:RowAndColumnFormat }
public static void Run() { // ExStart:ChangeTextFormat // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text(); // Instantiate Pdf instance by calling its empty constructor Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Create a new section in the Pdf object Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); // Set text color to blue in the whole section sec1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue"); // Add 1st paragraph (inheriting the text format settings from the section) // to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 1 ")); // Add 2nd paragraph (inheriting the text format settings from the section) // to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 2")); // Create 3rd paragraph (inheriting the text format settings from the section) Aspose.Pdf.Generator.Text t3 = new Aspose.Pdf.Generator.Text(sec1); // Create a segment "seg1" in the paragraph "t3" Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t3); // Assign some content to the segment seg1.Content = "paragraph 3 segment 1"; // Set the color of the segment to red seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Red"); // Add segment (with red text color) to the paragraph t3.Segments.Add(seg1); // Create a new segment "seg2" in the paragraph "t3" Aspose.Pdf.Generator.Segment seg2 = new Aspose.Pdf.Generator.Segment(t3); // Assign some content to the segment seg2.Content = "paragraph 3 segment 2"; // Set the color of the segment to green seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Green"); // Add segment (with green text color) to the paragraph t3.Segments.Add(seg2); // Add 3rd text paragraph to the section with overridden text format settings sec1.Paragraphs.Add(t3); // Add 4th paragraph (inheriting the text format settings from the section) // to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 4")); Aspose.Pdf.Generator.TextInfo info1 = t3.TextInfo.Clone() as Aspose.Pdf.Generator.TextInfo; // Modify the font side to 16 pt info1.FontSize = 16; // Set TextInfo property of the text paragraph to newly cloned instance "info1" t3.TextInfo = info1; // Save the document pdf1.Save(dataDir + "ChangeTextFormat_out_.pdf"); // ExEnd:ChangeTextFormat }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } //Instantiate Pdf instance by calling its empty constructor Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); //Create a new section in the Pdf object Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); //Set text color to blue in the whole section sec1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue"); //Add 1st paragraph (inheriting the text format settings from the section) //to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 1 ")); //Add 2nd paragraph (inheriting the text format settings from the section) //to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 2")); //Create 3rd paragraph (inheriting the text format settings from the section) Aspose.Pdf.Generator.Text t3 = new Aspose.Pdf.Generator.Text(sec1); //Create a segment "seg1" in the paragraph "t3" Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t3); //Assign some content to the segment seg1.Content = "paragraph 3 segment 1"; //Set the color of the segment to red seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Red"); //Add segment (with red text color) to the paragraph t3.Segments.Add(seg1); //Create a new segment "seg2" in the paragraph "t3" Aspose.Pdf.Generator.Segment seg2 = new Aspose.Pdf.Generator.Segment(t3); //Assign some content to the segment seg2.Content = "paragraph 3 segment 2"; //Set the color of the segment to green seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Green"); //Add segment (with green text color) to the paragraph t3.Segments.Add(seg2); //Add 3rd text paragraph to the section with overridden text format settings sec1.Paragraphs.Add(t3); //Add 4th paragraph (inheriting the text format settings from the section) //to the section sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text(sec1, "paragraph 4")); Aspose.Pdf.Generator.TextInfo info1 = t3.TextInfo.Clone() as Aspose.Pdf.Generator.TextInfo; //Modify the font side to 16 pt info1.FontSize = 16; //Set TextInfo property of the text paragraph to newly cloned instance "info1" t3.TextInfo = info1; //save the document pdf1.Save(dataDir + "output.pdf"); }