Hi every one,
I want to insert a textbox in my PDF document, I use the below code, but it when I open the PDF document, it can not show itself, but when I click the blank part of the PDF document, it shows itself. can anyone tell me why? I use a PDF comonent Spire.PDF. The code is shown as below:
using System.Text;
using Spire.Pdf;
using System.Drawing;
using Spire.Pdf.Fields;
using Spire.Pdf.Graphics;
namespace PDFtextbox
{
class Program
{
static void Main(string[] args)
{
PdfDocument pdfDoc = new PdfDocument();
pdfDoc.LoadFromFile(@"C:\Spire.PDF\Demos\Data\smile.pdf");
PdfPageBase page = pdfDoc.Pages[0];
PdfTextBoxField textField = new PdfTextBoxField(page, "textBox1");
float x = page.Canvas.ClientSize.Width / 5;
float y =(float) (page.Canvas.ClientSize.Height / 1.9);
textField.Bounds = new RectangleF(x, y, 3 * x, 40);
textField.BorderWidth = 1f;
textField.BorderStyle = PdfBorderStyle.Solid;
textField.Text = "Smile to the world, the world will smile back to you";
textField.BorderColor = new Spire.Pdf.Graphics.PdfRGBColor(Color.Olive);
textField.BackColor = new PdfRGBColor(Color.LightYellow);
textField.Font = new PdfFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Regular);
textField.ForeColor = new PdfRGBColor(Color.Green);
pdfDoc.SaveToFile(@"result.pdf");
System.Diagnostics.Process.Start(@"result.pdf");
}
}
}
Thanks in advance!
Never give up! Smile to the world!
http://excelcsharp.blog.com/