Hello, I'm using a demo version of Aspose.PDF.Kit v5.0.0. We are reviewing the software before we plan on purchasing.
I'm trying to set my submit button on a PDF to send the entire PDF instead of just the PDF form fields. I'msetting the FormEditor.SubmitFlag to SubmitFormFlag.PDF, which did not seem to work. FYI, I created the FormEditor using a Stream.
Ex.
FormEditor form = new FormEditor(proc.StandardOutput.BaseStream, output);
form.SubmitFlag = SubmitFormFlag.Pdf;
form.AddSubmitBtn("SubmitForm", 1, "Submit PDF", myUrl, 50, 550, 150, 650);
form.Save();
I also tried to set the submit form button using FormEditor.SetSubmitFlag(), but the method return false. The strange thing is that when I tried to use Form.GeSubmitFlags() on the submit button, it returned "20" - very odd, since this is not one of the enumeration members
Ex.
FormEditor form = new FormEditor(proc.StandardOutput.BaseStream, output);
form.SubmitFlag = SubmitFormFlag.Pdf;
form.AddSubmitBtn("SubmitForm", 1, "Submit PDF", myUrl, 50, 550, 150, 650);
bool setFlag = form.SetSubmitFlag("SubmitForm", SubmitFormFlag.Pdf);
form.Save();
if (!setFlag) {
Form pdfform = new Form(output);
throw new Exception("Error Setting Submit Flag:" + pdfform.GetSubmitFlags("SubmitForm"));
}
I noticed that this has been reported before, and was fixed in v4.1.0 (see https://forum.aspose.com/t/119997).
Thank you very much
This message was posted using Aspose.Live 2 Forum
Hi David,
Please share the input PDF file you’re using at your end, so we could test the issue in detail. You’ll be updated with the results accordingly.
We’re sorry for the inconvenience.
Regards,
I’ve attached two PDFs.
The first one is the the input PDF, which just has basic form fields.
The other is the output, to which I added a submit button using
Aspose.Pdf.Kit that is supposed to be submitting the entire PDF (it instead posts HTML form fields).
Here’s a snippet of code that was used to generate the submit button.
FormEditor pdf_editor = new FormEditor(_pdfpath, Path.GetFileNameWithoutExtension(_pdfpath) + “_mod.pdf”);
pdf_editor.SubmitFlag = SubmitFormFlag.Pdf;
pdf_editor.AddSubmitBtn(“SubmitForm”, 1, “Submit PDF”, someUrl, 35, 210, 115, 235);
pdf_editor.Save();
Hi David,
Thank you very much for sharing the PDF files and the code snippet. We’ll test the issue at our end and update you shortly.
We’re sorry for the inconvenience.
Regards,
Hi David,
Could you please try to use the following code snippet at your end and see if it works for you?
//add submit button and save the file
FormEditor editor = new FormEditor(“sample_submit_pdf.pdf”, “output.pdf”);
editor.AddSubmitBtn(“SubmitForm”, 1, “Submit PDF”, “http:[//localhost:2219/ReceivePdf/Default.aspx](https://localhost:2219/ReceivePdf/Default.aspx)”, 100, 500, 300, 600);
editor.Save();
//set submit flag
editor = new FormEditor(“output.pdf”, “output1.pdf”);
editor.SetSubmitFlag(“SubmitForm”, SubmitFormFlag.Pdf);
editor.Save();
//get submit flag’s value
Form form = new Form(“output1.pdf”, “output2.pdf”);
SubmitFormFlag flag = form.GetSubmitFlags(“SubmitForm”);
form.Save();
Console.WriteLine(“Flag = {0}”, flag);
Console.ReadLine();
If you still find any issue or have more questions, please do let us know.
Regards,
Yes, that worked - output1.pdf was able to be submitted as a PDF. So I guess it’s safe to assume that SetSubmitFlag() does not work on form fields that have not yet been saved to the PDF. That’s a little disappointing, but it shouldn’t be a problem.
So when is appropriate to use the FormEditor.SubmitFlag property?
Hi David,
I’m glad to know that it is working fine at your end. I’m afraid that in order to make the SetSubmitFlag work, you need to save the form field first. Moreover, please do not use SubmitFlag property at the moment; it might cause problems, rather use the SetSubmitFlag method.
If you find any further questions, please do let us know.
Regards,