Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Apr 15, 2019 6:04 pm

Hi

I'm stamping pdf files by adding a 2 text boxes, One I'm adding just a string and another one I'm adding today's date by running a javascript. I'm having a hardtime to format the text box removing the Back color and also the border, take a look in the attached pictures:

my code:
//Create TextBox to add today date
PdfTextBoxField txtboxDate = new PdfTextBoxField(newPage, "Today" + i.ToString());
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 9f);
txtboxDate.Bounds = new RectangleF(x + 310, y, 50, 15);
txtboxDate.BorderWidth = 0.75f;
txtboxDate.BorderStyle = PdfBorderStyle.Solid;
actionDate = new PdfJavaScriptAction(scriptDate);
txtboxDate.Actions.Calculate = actionDate;
newPdf.Form.Fields.Add(txtboxDate);

//Create TextBox to add DataSourceStamp
PdfTextBoxField txtboxDataSourceStamp = new PdfTextBoxField(newPage, "Note" + i.ToString());
txtboxDataSourceStamp.Bounds = new RectangleF(x, y, 310, 15);
txtboxDataSourceStamp.BorderWidth = 0.75f;
txtboxDataSourceStamp.BorderStyle = PdfBorderStyle.Solid;
txtboxDataSourceStamp.BorderColor = Color.White;
txtboxDataSourceStamp.BackColor = Color.Transparent;
txtboxDataSourceStamp.ForeColor = Color.Transparent;
txtboxDataSourceStamp.Text = DataSourceStamp;
newPdf.Form.Fields.Add(txtboxDataSourceStamp);


AdobeReader.jpg


FoxItPdf.jpg


WhatIWant.jpg


Thank You,
Thank You

[email protected]
 
Posts: 57
Joined: Tue Mar 19, 2019 6:41 pm

Tue Apr 16, 2019 9:38 am

Hi,

Thanks for your inquiry.
Firstly, you can refer to the following code snippet to remove the Border of the textbox
Code: Select all
txtboxDataSourceStamp.BorderWidth = 0.0f;

As for removing the background color of the textbox, actually, it takes effect when testing your code. You can find that there is no backcolor while opening the generated PDF by Adobe Acorbat, but the blue backcolor indeed exsits while opeing it by Adobe Reader. In fact, this difference is caused by Adobe Reader's own design. To verify it, you can manually add a textbox field without backcolor in Adobe Acorbat, and then open it by Adobe Reader, you can find the default blue backcolor also exists. Sorry our Spire.PDF have no way to control the default backcolor of textbox in Adobe Reader. However, to achieve the effect you want,you could set the textbox to be ReadOnly. After that, there will be no backcolor in Adobe Reader. Please feel free to contact us if you have any question.
Code: Select all
txtboxDataSourceStamp.ReadOnly = true;

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Tue Apr 16, 2019 8:41 pm

Thanks for the reply.
Thank You

[email protected]
 
Posts: 57
Joined: Tue Mar 19, 2019 6:41 pm

Wed Apr 17, 2019 11:14 am

Hi,

Thanks for your feedback.
If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you all the best!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF