I am trying to set the icon for the push button but the image is never rendered. I tried to follow the same process described on https://www.e-iceblue.com/Tutorials/Spi ... -in-C.html but no luck till now. Below is my code.
- Code: Select all
PdfFont fontpdf = new PdfFont(PdfFontFamily.TimesRoman, 15f, PdfFontStyle.Bold);
PdfBrush brushpdf = PdfBrushes.Black;
PdfButtonField pushButton = new PdfButtonField(page0, "PushButton")
{
ToolTip = "Testing of Push button",
Bounds = new RectangleF(0, 0, 100, 100),
BorderColor = Color.Aqua,
BorderStyle = PdfBorderStyle.Underline,
BorderWidth = 0.5f,
ReadOnly = false,
BackColor = Color.Beige,
Export = true,
Flatten = false,
Font = fontpdf,
ForeColor = Color.Red,
HighlightMode = PdfHighlightMode.Push,
//IconLayout = pushButtonIconLayout.Spaces
//Location = new PointF(50,50),
LayoutMode = PdfButtonLayoutMode.IconOnly,
MappingName = "Push Button",
Required = true,
//RolloverIcon
//RolloverText
//Size = new SizeF(10,10),
Text = "Chintal",
TextAlignment = PdfTextAlignment.Center,
Visible = true
};
pushButton.IconLayout.Spaces = new float[] { 25f, 10f };
pushButton.IconLayout.ScaleMode = PdfButtonIconScaleMode.Proportional;
pushButton.IconLayout.ScaleReason = PdfButtonIconScaleReason.IconIsBigger;
pushButton.IconLayout.IsFitBounds = false;
pushButton.Icon = PdfImage.FromFile(@"C:\PDF\_1.png");
doc.Form.Fields.Add(pushButton);
//save the file
doc.SaveToFile(@"C:\PDF\Testing.pdf");