public static void UsingFloatingBox() { // ExStart:UsingFloatingBox // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles(); // Instantiate Pdf instance Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Add a section into the pdf document Aspose.Pdf.Generator.Section section = pdf.Sections.Add(); // Initializes a new instance of the FloatingBox class Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(140, 80); // Indicate the horizontal positioning type of the floating box box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin; // Float value that indicates left position of the paragraph box1.Left = 2; // Indicate the vertical alignment type of the floating box box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page; // Float value that indicates top position of the paragraph box1.Top = 10; // Add the macros to the paragraphs collection of the FloatingBox box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Page: ($p/ $P )")); // Add a floatingBox to the section section.Paragraphs.Add(box1); // Save the document pdf.Save(dataDir + "PageNumber_using_FloatingBox_out.pdf"); // ExEnd:UsingFloatingBox }
public static void SecondApproach() { // ExStart:SecondApproach // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles(); // Create a PDF object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add(); // Create a text object Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1); // Create a Floating Box object that will hold image file Aspose.Pdf.Generator.FloatingBox TextFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(117, 21); // Specify the ZIndex value for TextFloatingBox TextFloatingBox1.ZIndex = 1; TextFloatingBox1.Left = -4; TextFloatingBox1.Top = -4; // Add Floating box to paragraphs collection of Section1 sec1.Paragraphs.Add(TextFloatingBox1); // Add the text object to Paragraphs collection of FloatingBox TextFloatingBox1.Paragraphs.Add(t1); Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1); // Add the contents for Segment1 seg1.Content = "paragraph 3 segment 1"; // Specify the Font fore color for segement1 seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red"); // Specify the font size information for segment1 seg1.TextInfo.FontSize = 12; // Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect t1.Opacity = 0F; // Add the segment to segments collection of Text1 t1.Segments.Add(seg1); // JPeg image cover the underlayer text Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1); image1.ImageInfo.File = dataDir + "aspose-logo.jpg"; image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; // Create a Floating Box object that will hold image file Aspose.Pdf.Generator.FloatingBox ImageFloatingBox = new Aspose.Pdf.Generator.FloatingBox(117, 21); // Add Floating box to paragraphs collection of Section1 sec1.Paragraphs.Add(ImageFloatingBox); // Specify the left margin of FloatingBox1 ImageFloatingBox.Left = -4; // Specify the Top margin of FloatingBox1 ImageFloatingBox.Top = -4; // Specify the ZIndex of ImageFloatingBox ImageFloatingBox.ZIndex = 2; // Add the image file to paragraphs collection of FloatingBox ImageFloatingBox.Paragraphs.Add(image1); // Save the reusltant PDF document pdf.Save(dataDir + @"Multilayer-2ndApproach_out_.pdf"); // ExEnd:SecondApproach }
public static void SecondApproach() { // ExStart:SecondApproach // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles(); // Create a PDF object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add(); // Create a text object Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1); // Create a Floating Box object that will hold image file Aspose.Pdf.Generator.FloatingBox TextFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(117, 21); // Specify the ZIndex value for TextFloatingBox TextFloatingBox1.ZIndex = 1; TextFloatingBox1.Left = -4; TextFloatingBox1.Top = -4; // Add Floating box to paragraphs collection of Section1 sec1.Paragraphs.Add(TextFloatingBox1); // Add the text object to Paragraphs collection of FloatingBox TextFloatingBox1.Paragraphs.Add(t1); Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1); // Add the contents for Segment1 seg1.Content = "paragraph 3 segment 1"; // Specify the Font fore color for segement1 seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red"); // Specify the font size information for segment1 seg1.TextInfo.FontSize = 12; // Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect t1.Opacity = 0F; // Add the segment to segments collection of Text1 t1.Segments.Add(seg1); // JPeg image cover the underlayer text Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1); image1.ImageInfo.File = dataDir + "aspose-logo.jpg"; image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; // Create a Floating Box object that will hold image file Aspose.Pdf.Generator.FloatingBox ImageFloatingBox = new Aspose.Pdf.Generator.FloatingBox(117, 21); // Add Floating box to paragraphs collection of Section1 sec1.Paragraphs.Add(ImageFloatingBox); // Specify the left margin of FloatingBox1 ImageFloatingBox.Left = -4; // Specify the Top margin of FloatingBox1 ImageFloatingBox.Top = -4; // Specify the ZIndex of ImageFloatingBox ImageFloatingBox.ZIndex = 2; // Add the image file to paragraphs collection of FloatingBox ImageFloatingBox.Paragraphs.Add(image1); // Save the reusltant PDF document pdf.Save(dataDir + @"Multilayer-2ndApproach_out.pdf"); // ExEnd:SecondApproach }
public static void Run() { try { // ExStart:PositionFloatingBox // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General(); // Instantiate Pdf instance by calling its empty constructor Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Create section object and add it to sections collection of PDF Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); // Create FloatingBox with 108 as width and 80 as height Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(108, 80); // Add FloatingBox to paragraphs collection of section object sec1.Paragraphs.Add(box1); // ExStart:PositionFloatingBox-1 // Specify the Horizontal Positioning type for FloatingBox as Margin box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin; // Set the left margin information as 200 box1.Left = 200; // Specify the Vertical Positioning type for FloatingBox object box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page; // Set the Top margin information as 300 box1.Top = 300; // ExEnd:PositionFloatingBox-1 // Add sample text string to paragraphs collection of FloatingBox object box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello.")); dataDir = dataDir + "PositionFloatingBox_out.pdf"; // Save the resultant PDF pdf1.Save(dataDir); // ExEnd:PositionFloatingBox } catch (Exception ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); } }
public static void Run() { try { // ExStart:PositionFloatingBox // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General(); // Instantiate Pdf instance by calling its empty constructor Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Create section object and add it to sections collection of PDF Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); // Create FloatingBox with 108 as width and 80 as height Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(108, 80); // add FloatingBox to paragraphs collection of section object sec1.Paragraphs.Add(box1); // ExStart:PositionFloatingBox-1 // Specify the Horizontal Positioning type for FloatingBox as Margin box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin; // Set the left margin information as 200 box1.Left = 200; // Specify the Vertical Positioning type for FloatingBox object box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page; // Set the Top margin information as 300 box1.Top = 300; // ExEnd:PositionFloatingBox-1 // Add sample text string to paragraphs collection of FloatingBox object box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello.")); dataDir = dataDir + "PositionFloatingBox_out_.pdf"; // Save the resultant PDF pdf1.Save(dataDir); // ExEnd:PositionFloatingBox } catch (Exception ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); } }
public static void Run() { // ExStart:CustomizingWatermark // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures(); // Instantiate the Pdf object Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); // Add a section to the Pdf object Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "This is text in section1."); text1.Left = 30; text1.Top = 100; sec1.Paragraphs.Add(text1); Aspose.Pdf.Generator.Section sec2 = pdf1.Sections.Add(); Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec2, "This is text in section2."); text2.Left = 30; text2.Top = 100; sec2.Paragraphs.Add(text2); // Setting image watermark Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(); image1.ImageInfo.File = dataDir + "aspose-logo.jpg"; image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; image1.ImageScale = 0.1f; Aspose.Pdf.Generator.FloatingBox watermark1 = new Aspose.Pdf.Generator.FloatingBox(108, 80); watermark1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Page; watermark1.BoxHorizontalAlignment = Aspose.Pdf.Generator.BoxHorizontalAlignmentType.Center; watermark1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page; watermark1.BoxVerticalAlignment = Aspose.Pdf.Generator.BoxVerticalAlignmentType.Center; watermark1.Paragraphs.Add(image1); // Graph watermark Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(100, 400); float[] posArr = new float[] { 0, 0, 200, 80, 300, 40, 350, 90 }; Aspose.Pdf.Generator.Curve curve1 = new Aspose.Pdf.Generator.Curve(graph1, posArr); graph1.Shapes.Add(curve1); Aspose.Pdf.Generator.FloatingBox watermark2 = new Aspose.Pdf.Generator.FloatingBox(108, 80); watermark2.Paragraphs.Add(graph1); // Text watermark Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text("Text Watermark"); Aspose.Pdf.Generator.FloatingBox watermark3 = new Aspose.Pdf.Generator.FloatingBox(108, 80); watermark3.Left = 50; watermark3.Top = 500; watermark3.Paragraphs.Add(text3); pdf1.Watermarks.Add(watermark1); pdf1.Watermarks.Add(watermark2); pdf1.Watermarks.Add(watermark3); dataDir = dataDir + "CustomizingWatermark_out.pdf"; // Save the Pdf pdf1.Save(dataDir); // ExEnd:CustomizingWatermark }
public static void UsingFloatingBox() { // ExStart:UsingFloatingBox // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles(); // Instantiate Pdf instance Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Add a section into the pdf document Aspose.Pdf.Generator.Section section = pdf.Sections.Add(); // Initializes a new instance of the FloatingBox class Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(140, 80); // Indicate the horizontal positioning type of the floating box box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin; // Float value that indicates left position of the paragraph box1.Left = 2; // Indicate the vertical alignment type of the floating box box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page; // Float value that indicates top position of the paragraph box1.Top = 10; // Add the macros to the paragraphs collection of the FloatingBox box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Page: ($p/ $P )")); // Add a floatingBox to the section section.Paragraphs.Add(box1); // Save the document pdf.Save( dataDir + "PageNumber_using_FloatingBox_out.pdf"); // ExEnd:UsingFloatingBox }