Hello, I am trying to Aspose.PDF for .NET latest version to create interactive PDF, and i want to change the appearance of Submit button with no luck, could you please guide me how to achieve it
below code snippet i am using to create the submit button
Another Question, i want when the submit button get pressed to upload the pdf document to specific server using REST API (POST HTTP) with below signature, is that correct
[OperationContract]
[WebInvoke(UriTemplate = “UploadDocument”)]
void UploadDocument(Stream doc);
public static bool XFACreateButton(this string sourceFilePath, string name, string url, int pageNo, int startX, int startY, int endX, int endY, string targetFilePath = “”)
{
try
{
if (System.IO.File.Exists(sourceFilePath))
{
if (string.IsNullOrEmpty(targetFilePath))
{
targetFilePath = sourceFilePath;
}
Aspose.Pdf.Document document = new Aspose.Pdf.Document(sourceFilePath);
var pHeight = Convert.ToInt32(document.Pages[pageNo].Rect.Height);
var rect = new Aspose.Pdf.Rectangle(startX, pHeight - startY, endX, pHeight - endY);
FormEditor formEditor = new FormEditor(document);
formEditor.AddSubmitBtn(name, pageNo, "Submit", url, (float)rect.LLX, (float)rect.LLY, (float)rect.URX, (float)rect.URY);
formEditor.SetFieldAppearance(name, AnnotationFlags.Print);
formEditor.SetSubmitFlag(name, Aspose.Pdf.Facades.SubmitFormFlag.Pdf);
document.Save(targetFilePath);
document = new Aspose.Pdf.Document(targetFilePath);
foreach (var field in document.Form)
{
if (field.FullName == name)
{
ButtonField button = ((ButtonField)field);
button.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Gray);
Border border = new Border(button);
border.Width = 2;
border.Dash = new Dash(1, 1);
button.Border = border;
button.DefaultAppearance.TextColor = System.Drawing.Color.Red;
document.Save(targetFilePath);
}
}
return true;
}
}
catch (Exception ex)
{
Logger.AddException(ex.Message", "Extension.XFACreateButton");
}
return false;
}