Why my textbox in PDF can not show?

Posted by Megan00 under C# on 7/16/2012 | Points: 10 | Views : 1886 | Status : [Member] | Replies : 3
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/



Responses

Posted by: Premalatha on: 7/16/2012 [Member] Starter | Points: 25

Up
0
Down
First,
You have to check your given correct Path or not,
pdfDoc.LoadFromFile(@"C:\Spire.PDF\Demos\Data\smile.pdf")

Premalatha
Software Engineer

Megan00, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 7/17/2012 [Member] Starter | Points: 25

Up
0
Down
yes, the path is correct and the problem is that the textbox do not show itself in PDF.

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Megan00, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 7/17/2012 [Member] Starter | Points: 25

Up
0
Down
And when I launch the project, the PDF opens and the textbox can show only when I click the blank location of it. so can u help me?

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Megan00, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response