/// <summary>
        /// Create text box.
        /// </summary>
        /// <param name="page">Pdf page.</param>
        /// <returns>text box.</returns>
        public FloatingBox CreateTextBox(Page page)
        {
            var floatingBox = new FloatingBox
            {
                Border  = new BorderInfo(BorderSide.All, 1, Color.Black),
                Padding = new MarginInfo(10f, 10f, 10f, 10f),
                Margin  = new MarginInfo(10f, 100f, 10f, 10f)
            };

            page.Paragraphs.Add(floatingBox);

            return(floatingBox);
        }
Beispiel #2
0
        private void AddressSection()
        {
            var box = new FloatingBox(524, 120)
            {
                ColumnInfo =
                {
                    ColumnCount  = 2,
                    ColumnWidths = "252 252"
                },
                Padding =
                {
                    Top = 20
                }
            };
            TextFragment fragment;

            BillFrom.Insert(0, "FROM:");
            foreach (var str in BillFrom)
            {
                fragment = new TextFragment(str);
                fragment.TextState.Font     = _timeNewRomanFont;
                fragment.TextState.FontSize = 12;
                // Add fragment to paragraph
                box.Paragraphs.Add(fragment);
            }

            fragment = new TextFragment("BILL TO:")
            {
                IsFirstParagraphInColumn = true
            };
            fragment.TextState.Font                = _timeNewRomanFont;
            fragment.TextState.FontSize            = 12;
            fragment.TextState.HorizontalAlignment = HorizontalAlignment.Right;
            box.Paragraphs.Add(fragment);

            foreach (var str in BillTo)
            {
                fragment = new TextFragment(str);
                fragment.TextState.Font                = _timeNewRomanFont;
                fragment.TextState.FontSize            = 12;
                fragment.TextState.HorizontalAlignment = HorizontalAlignment.Right;
                // Add fragment to paragraph
                box.Paragraphs.Add(fragment);
            }
            _pdfPage.Paragraphs.Add(box);
        }
Beispiel #3
0
        public static void AddImageStampAsBackgroundInFloatingBox()
        {
            //ExStart: AddImageStampAsBackgroundInFloatingBox
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_StampsWatermarks();

            // Instantiate Document object
            Document doc = new Document();
            // Add page to PDF document
            Page page = doc.Pages.Add();
            // Create FloatingBox object
            FloatingBox aBox = new FloatingBox(200, 100);

            // Set left position for FloatingBox
            aBox.Left = 40;
            // Set Top position for FloatingBox
            aBox.Top = 80;
            // Set the Horizontal alignment for FloatingBox
            aBox.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
            // Add text fragment to paragraphs collection of FloatingBox
            aBox.Paragraphs.Add(new TextFragment("main text"));
            // Set border for FloatingBox
            aBox.Border = new BorderInfo(BorderSide.All, Aspose.Pdf.Color.Red);
            // Add background image
            aBox.BackgroundImage = new Image
            {
                File = dataDir + "aspose-logo.jpg"
            };
            // Set background color for FloatingBox
            aBox.BackgroundColor = Aspose.Pdf.Color.Yellow;
            // Add FloatingBox to paragraphs collection of page object
            page.Paragraphs.Add(aBox);
            // Save the PDF document
            doc.Save(dataDir + "AddImageStampAsBackgroundInFloatingBox_out.pdf");
            //ExEnd: AddImageStampAsBackgroundInFloatingBox
        }