'When using javascript in pdf its not working in all browsers
When inject javascript in file and give that reference in pdf its not working in all browser using itextsharp using pdfstamper..
function Signature1() {
this.getField('BtnSignature').display = display.hidden;
this.getField('Text1').display = display.visible;
var cResponse=app.response({cQuestion:'Enter your Name',cTitle:'SIGNATURE'});
if(cResponse==null)
{app.alert('please enter name');cResponse=0;}
else
{this.getField('Text1').value=cResponse;this.getField('BtnSignature1').setFocus();}
}
code side
Rectangle rect;
rect = new Rectangle(pos.Left, pos.Bottom, pos.Right, pos.Top);
PushbuttonField button = new PushbuttonField(pdfStamper.Writer, rect, "BtnSignature");
button.BackgroundColor = new GrayColor(0.75f);
button.BorderColor = GrayColor.GRAYBLACK;
button.BorderWidth = 1;
button.BorderStyle = PdfBorderDictionary.STYLE_BEVELED;
button.TextColor = GrayColor.GRAYBLACK;
button.FontSize = 9;
button.Text = "Sign Here";
button.Layout = PushbuttonField.LAYOUT_ICON_LEFT_LABEL_RIGHT;
button.ScaleIcon = PushbuttonField.SCALE_ICON_ALWAYS;
button.ProportionalIcon = true;
button.IconHorizontalAdjustment = 0;
button.Visibility = PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT;
field = button.Field;
//string strJava = string.Empty;
//strJava = "this.getField('BtnSignature').display = display.hidden;";
//strJava += "this.getField('Text1').display = display.visible;var cResponse=app.response({cQuestion:'Enter your Name',cTitle:'SIGNATURE'});if(cResponse==null){app.alert('please enter name');cResponse=0;}else{this.getField('Text1').value=cResponse;this.getField('BtnSignature1').setFocus();}";
field.Action = PdfAction.JavaScript("this.Signature1()", pdfStamper.Writer);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
