private void debug_createP(string fileFullName) { Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(); Aspose.Pdf.Page pdfPage = (Aspose.Pdf.Page)pdfDocument.Pages.Add(); Console.WriteLine("pdfPage.Rect = " + pdfPage.Rect); Console.WriteLine("pdfPage.PageInfo: Width - Height - PureHeight = " + pdfPage.PageInfo.Width + " - " + pdfPage.PageInfo.Height + " - " + pdfPage.PageInfo.PureHeight); Console.WriteLine("pdfPage.PageInfo: Margin.Top - Right - Bottom - Left = " + pdfPage.PageInfo.Margin.Top + " - " + pdfPage.PageInfo.Margin.Right + " - " + pdfPage.PageInfo.Margin.Bottom + " - " + pdfPage.PageInfo.Margin.Left); TextParagraph paragraph = new TextParagraph(); // append string lines paragraph.AppendLine("the quick brown fox jumps over the lazy dog"); paragraph.AppendLine("line2"); paragraph.AppendLine("line3"); Console.WriteLine("paragraph.Rectangle = " + paragraph.Rectangle); Console.WriteLine("paragraph.TextRectangle = " + paragraph.TextRectangle); // Create Graph instance Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)pdfPage.Rect.Width, (float)pdfPage.Rect.Height); // Add graph object to paragraphs collection of page instance pdfPage.Paragraphs.Add(graph); // Create Rectangle instance //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120); Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle((float)paragraph.Rectangle.LLX, (float)paragraph.Rectangle.LLY, (float)paragraph.Rectangle.Width, (float)paragraph.Rectangle.Height); //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle((float)paragraph.TextRectangle.LLX, (float)paragraph.TextRectangle.LLY, (float)paragraph.TextRectangle.Width, (float)paragraph.TextRectangle.Height); // Specify fill color for Graph object //rect.GraphInfo.FillColor = Aspose.Pdf.Color.Red; rect.GraphInfo.LineWidth = 2; rect.GraphInfo.Color = Aspose.Pdf.Color.Brown; // Add rectangle object to shapes collection of Graph object graph.Shapes.Add(rect); TextBuilder textBuilder = new TextBuilder(pdfPage); textBuilder.AppendParagraph(paragraph); pdfDocument.Save(fileFullName); }
public static void Run() { // ExStart:RotateTextUsingTextParagraphAndBuilder string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); // Initialize document object Document pdfDocument = new Document(); // Get particular page Page pdfPage = (Page)pdfDocument.Pages.Add(); for (int i = 0; i < 4; i++) { TextParagraph paragraph = new TextParagraph(); paragraph.Position = new Position(200, 600); // Specify rotation paragraph.Rotation = i * 90 + 45; // Create text fragment TextFragment textFragment1 = new TextFragment("Paragraph Text"); // Create text fragment textFragment1.TextState.FontSize = 12; textFragment1.TextState.Font = FontRepository.FindFont("TimesNewRoman"); textFragment1.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment1.TextState.ForegroundColor = Aspose.Pdf.Color.Blue; // Create text fragment TextFragment textFragment2 = new TextFragment("Second line of text"); // Set text properties textFragment2.TextState.FontSize = 12; textFragment2.TextState.Font = FontRepository.FindFont("TimesNewRoman"); textFragment2.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment2.TextState.ForegroundColor = Aspose.Pdf.Color.Blue; // Create text fragment TextFragment textFragment3 = new TextFragment("And some more text..."); // Set text properties textFragment3.TextState.FontSize = 12; textFragment3.TextState.Font = FontRepository.FindFont("TimesNewRoman"); textFragment3.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment3.TextState.ForegroundColor = Aspose.Pdf.Color.Blue; textFragment3.TextState.Underline = true; paragraph.AppendLine(textFragment1); paragraph.AppendLine(textFragment2); paragraph.AppendLine(textFragment3); // Create TextBuilder object TextBuilder textBuilder = new TextBuilder(pdfPage); // Append the text fragment to the PDF page textBuilder.AppendParagraph(paragraph); } // Save document pdfDocument.Save(dataDir + "TextFragmentTests_Rotated4_out.pdf"); // ExEnd:RotateTextUsingTextParagraphAndBuilder }
public static void UsingTextBuilderAndParagraph() { // ExStart:UsingTextBuilderAndParagraph // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); // Create Document instance Document pdfDocument = new Document(); // Add page to pages collection of Document Page page = pdfDocument.Pages.Add(); // Create TextBuilder instance TextBuilder builder = new TextBuilder(pdfDocument.Pages[1]); // Instantiate TextParagraph instance TextParagraph paragraph = new TextParagraph(); // Create TextState instance to specify font name and size TextState state = new TextState("Arial", 12); // Specify the character spacing state.CharacterSpacing = 1.5f; // Append text to TextParagraph object paragraph.AppendLine("This is paragraph with character spacing", state); // Specify the position for TextParagraph paragraph.Position = new Position(100, 550); // Append TextParagraph to TextBuilder instance builder.AppendParagraph(paragraph); dataDir = dataDir + "CharacterSpacingUsingTextBuilderAndParagraph_out_.pdf"; // Save resulting PDF document. pdfDocument.Save(dataDir); // ExEnd:UsingTextBuilderAndParagraph Console.WriteLine("\nCharacter spacing specified successfully using Text builder and paragraph.\nFile saved at " + dataDir); }
public static void UsingTextBuilderAndParagraph() { // ExStart:UsingTextBuilderAndParagraph // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); // Create Document instance Document pdfDocument = new Document(); // Add page to pages collection of Document Page page = pdfDocument.Pages.Add(); // Create TextBuilder instance TextBuilder builder = new TextBuilder(pdfDocument.Pages[1]); // Instantiate TextParagraph instance TextParagraph paragraph = new TextParagraph(); // Create TextState instance to specify font name and size TextState state = new TextState("Arial", 12); // Specify the character spacing state.CharacterSpacing = 1.5f; // Append text to TextParagraph object paragraph.AppendLine("This is paragraph with character spacing", state); // Specify the position for TextParagraph paragraph.Position = new Position(100, 550); // Append TextParagraph to TextBuilder instance builder.AppendParagraph(paragraph); dataDir = dataDir + "CharacterSpacingUsingTextBuilderAndParagraph_out.pdf"; // Save resulting PDF document. pdfDocument.Save(dataDir); // ExEnd:UsingTextBuilderAndParagraph Console.WriteLine("\nCharacter spacing specified successfully using Text builder and paragraph.\nFile saved at " + dataDir); }
public static void Text2(Document pdfDocument) { Page pdfPage = pdfDocument.Pages.Add(); int pos = 0; for (int i = 1; i <= 100; i++) { TextParagraph textParagraph = new TextParagraph(); TextFragment textFragment1 = new TextFragment("Text Fragment (1) " + i + " "); //textFragment.Margin.Top = 8; //textFragment1.IsInLineParagraph = true; TextFragment textFragment2 = new TextFragment("Text Fragment (2) " + i + " "); //textFragment2.IsInLineParagraph = true; textParagraph.AppendLine(textFragment1/*, textState*/); //textParagraph.AppendLine(textFragment2/*, textState*/); textParagraph.Position = new Position(20, pdfDocument.PageInfo.Height - (i - pos) * (textFragment1.Rectangle.Height + 8)); if (textParagraph.Position.YIndent < 0) { pdfPage = pdfDocument.Pages.Add(); pos = i - 1; textParagraph.Position = new Position(20, pdfDocument.PageInfo.Height - (i - pos) * (textFragment1.Rectangle.Height + 8)); } TextBuilder textBuilder = new TextBuilder(pdfPage); textBuilder.AppendParagraph(textParagraph); } }
public static void Run() { // ExStart:RotateTextUsingParagraph string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); // Initialize document object Document pdfDocument = new Document(); // Get particular page Page pdfPage = (Page)pdfDocument.Pages.Add(); TextParagraph paragraph = new TextParagraph(); paragraph.Position = new Position(200, 600); // Create text fragment TextFragment textFragment1 = new TextFragment("rotated text"); // Set text properties textFragment1.TextState.FontSize = 12; textFragment1.TextState.Font = FontRepository.FindFont("TimesNewRoman"); // Set rotation textFragment1.TextState.Rotation = 45; // Create text fragment TextFragment textFragment2 = new TextFragment("main text"); // Set text properties textFragment2.TextState.FontSize = 12; textFragment2.TextState.Font = FontRepository.FindFont("TimesNewRoman"); // Create text fragment TextFragment textFragment3 = new TextFragment("another rotated text"); // Set text properties textFragment3.TextState.FontSize = 12; textFragment3.TextState.Font = FontRepository.FindFont("TimesNewRoman"); // Set rotation textFragment3.TextState.Rotation = -45; // Append the text fragments to the paragraph paragraph.AppendLine(textFragment1); paragraph.AppendLine(textFragment2); paragraph.AppendLine(textFragment3); // Create TextBuilder object TextBuilder textBuilder = new TextBuilder(pdfPage); // Append the text paragraph to the PDF page textBuilder.AppendParagraph(paragraph); // Save document pdfDocument.Save(dataDir + "TextFragmentTests_Rotated2_out.pdf"); // ExEnd:RotateTextUsingParagraph }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Load source PDF form Aspose.Pdf.Facades.Form form1 = new Aspose.Pdf.Facades.Form(dataDir + "RadioButtonField.pdf"); Document PDF_Template_PDF_HTML = new Document(dataDir + "RadioButtonField.pdf"); foreach (var item in form1.FieldNames) { Console.WriteLine(item.ToString()); Dictionary <string, string> radioOptions = form1.GetButtonOptionValues(item); if (item.Contains("radio1")) { Aspose.Pdf.Forms.RadioButtonField field0 = PDF_Template_PDF_HTML.Form[item] as Aspose.Pdf.Forms.RadioButtonField; Aspose.Pdf.Forms.RadioButtonOptionField fieldoption = new Aspose.Pdf.Forms.RadioButtonOptionField(); fieldoption.OptionName = "Yes"; fieldoption.PartialName = "Yesname"; var updatedFragment = new Aspose.Pdf.Text.TextFragment("test123"); updatedFragment.TextState.Font = FontRepository.FindFont("Arial"); updatedFragment.TextState.FontSize = 10; updatedFragment.TextState.LineSpacing = 6.32f; // Create TextParagraph object TextParagraph par = new TextParagraph(); // Set paragraph position par.Position = new Position(field0.Rect.LLX, field0.Rect.LLY + updatedFragment.TextState.FontSize); // Specify word wraping mode par.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.ByWords; // Add new TextFragment to paragraph par.AppendLine(updatedFragment); // Add the TextParagraph using TextBuilder TextBuilder textBuilder = new TextBuilder(PDF_Template_PDF_HTML.Pages[1]); textBuilder.AppendParagraph(par); field0.DeleteOption("item1"); } } PDF_Template_PDF_HTML.Save(dataDir + "RadioButtonField_out.pdf"); // ExEnd:1 }
public static void AddNewLineFeed() { try { // ExStart:AddNewLineFeed // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); Aspose.Pdf.Document pdfApplicationDoc = new Aspose.Pdf.Document(); Aspose.Pdf.Page applicationFirstPage = (Aspose.Pdf.Page)pdfApplicationDoc.Pages.Add(); // Initialize new TextFragment with text containing required newline markers Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment("Applicant Name: " + Environment.NewLine + " Joe Smoe"); // Set text fragment properties if necessary textFragment.TextState.FontSize = 12; textFragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("TimesNewRoman"); textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Red; // Create TextParagraph object TextParagraph par = new TextParagraph(); // Add new TextFragment to paragraph par.AppendLine(textFragment); // Set paragraph position par.Position = new Aspose.Pdf.Text.Position(100, 600); // Create TextBuilder object TextBuilder textBuilder = new TextBuilder(applicationFirstPage); // Add the TextParagraph using TextBuilder textBuilder.AppendParagraph(par); dataDir = dataDir + "AddNewLineFeed_out.pdf"; // Save resulting PDF document. pdfApplicationDoc.Save(dataDir); // ExEnd:AddNewLineFeed Console.WriteLine("\nNew line feed added successfully.\nFile saved at " + dataDir); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Run() { // ExStart:RenderingReplaceableSymbols // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); Aspose.Pdf.Document pdfApplicationDoc = new Aspose.Pdf.Document(); Aspose.Pdf.Page applicationFirstPage = (Aspose.Pdf.Page)pdfApplicationDoc.Pages.Add(); // Initialize new TextFragment with text containing required newline markers Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment("Applicant Name: " + Environment.NewLine + " Joe Smoe"); // Set text fragment properties if necessary textFragment.TextState.FontSize = 12; textFragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("TimesNewRoman"); textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Red; // Create TextParagraph object TextParagraph par = new TextParagraph(); // Add new TextFragment to paragraph par.AppendLine(textFragment); // Set paragraph position par.Position = new Aspose.Pdf.Text.Position(100, 600); // Create TextBuilder object TextBuilder textBuilder = new TextBuilder(applicationFirstPage); // Add the TextParagraph using TextBuilder textBuilder.AppendParagraph(par); dataDir = dataDir + "RenderingReplaceableSymbols_out_.pdf"; pdfApplicationDoc.Save(dataDir); // ExEnd:RenderingReplaceableSymbols Console.WriteLine("\nReplaceable symbols render successfully duing pdf creation.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:RenderingReplaceableSymbols // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); Aspose.Pdf.Document pdfApplicationDoc = new Aspose.Pdf.Document(); Aspose.Pdf.Page applicationFirstPage = (Aspose.Pdf.Page)pdfApplicationDoc.Pages.Add(); // Initialize new TextFragment with text containing required newline markers Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment("Applicant Name: " + Environment.NewLine + " Joe Smoe"); // Set text fragment properties if necessary textFragment.TextState.FontSize = 12; textFragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("TimesNewRoman"); textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.LightGray; textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Red; // Create TextParagraph object TextParagraph par = new TextParagraph(); // Add new TextFragment to paragraph par.AppendLine(textFragment); // Set paragraph position par.Position = new Aspose.Pdf.Text.Position(100, 600); // Create TextBuilder object TextBuilder textBuilder = new TextBuilder(applicationFirstPage); // Add the TextParagraph using TextBuilder textBuilder.AppendParagraph(par); dataDir = dataDir + "RenderingReplaceableSymbols_out.pdf"; pdfApplicationDoc.Save(dataDir); // ExEnd:RenderingReplaceableSymbols Console.WriteLine("\nReplaceable symbols render successfully duing pdf creation.\nFile saved at " + dataDir); }
public static void AddTextUsingTextParagraph() { // ExStart:AddTextUsingTextParagraph // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); // Open document Document doc = new Document(); // Add page to pages collection of Document object Page page = doc.Pages.Add(); TextBuilder builder = new TextBuilder(page); // Create text paragraph TextParagraph paragraph = new TextParagraph(); // Set subsequent lines indent paragraph.SubsequentLinesIndent = 20; // Specify the location to add TextParagraph paragraph.Rectangle = new Aspose.Pdf.Rectangle(100, 300, 200, 700); // Specify word wraping mode paragraph.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.ByWords; // Create text fragment TextFragment fragment1 = new TextFragment("the quick brown fox jumps over the lazy dog"); fragment1.TextState.Font = FontRepository.FindFont("Times New Roman"); fragment1.TextState.FontSize = 12; // Add fragment to paragraph paragraph.AppendLine(fragment1); // Add paragraph builder.AppendParagraph(paragraph); dataDir = dataDir + "AddTextUsingTextParagraph_out.pdf"; // Save resulting PDF document. doc.Save(dataDir); // ExEnd:AddTextUsingTextParagraph Console.WriteLine("\nText using text paragraph added successfully.\nFile saved at " + dataDir); }