Hi There,
I am trying to get all Pdf fields (textbox, checkbox, date etc). When I tried following code I am getting 4 fields only. Am I missing something?
Aspose.Pdf.dll
Version: 9.9.0.0
Code:
public static void Main(string[] args)
{
Document pdfDocument = new Aspose.Pdf.Document("…//template.pdf");
//get values from all fields
foreach (Field formField in pdfDocument.Form)
{
Console.WriteLine("Field name : {0} ", formField.PartialName);
}
Console.ReadLine();
}
Result:
Filed name: Petitioner
Filed name: Respondent
Filed name: No
Filed name: Calendar
I have attached template.pdf file.
Thanks
John
Hi John,
Thanks for your inquiry. I have tested the scenario and unable to notice any issue. It seems you are evaluating Aspose.Pdf without a valid license. Aspose.Pdf evaluation version has two limitations, the evaluation watermark and at most four elements of any collection can be viewed. Please make a request for a 30-day temporary license to evaluate our product without any limitation. Hopefully, your issue will be resolved.
Please feel free to contact us for any further assistance.
Best Regards,
Hi John,
Thanks for your inquiry. It is good to know that provided information helped you to resolve the issue.
Please evaluate our product and please feel free to ask any question and concern. We will be more than happy to extend our support.
Best Regards,
Hi,
The following code, newly generated pdf file is not editable. Source file "template.pdf" is editable. I have attached template.pdf in my first post.
How can I keep new newly generated pdf file editable?
Aspose.Pdf.dll
Version: 9.9.0.0
Code:
public static void Main(string[] args)
{
Document pdfDocument = new Aspose.Pdf.Document("..//template.pdf");
//test field
//should be editable after save
TextBoxField textBoxField = pdfDocument.Form.Fields[2] as TextBoxField;
textBoxField.Value = "Test data editable";
pdfDocument.Save("..//Aspose_editable.pdf");
}
Result:
"Aspose_editable.pdf" is not editable.
Expected Result
"Aspose_editable.pdf" should be editable.
Thanks
John
Hi John,
Thanks for your inquiry. To preserve the extended rights of forms you need to use incremental approach for save. Please check following documentation link for details, it will resolve the issue.
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal,
I saw your attached “template(1).pdf”. This is exactly what I needed in the output. I went through different approaches one by one per your suggested link but not success. I get attached popup message when I open newly generated pdf.
Would you mind sharing me the code snippet?
Aspose.Pdf.dll
Version: 9.9.0.0
Code:
public static void Main(string[] args)
{
////approach 1 - failed
var pdfDocument1 = new Aspose.Pdf.Document("…//template.pdf");
var frm = new Aspose.Pdf.Facades.Form(pdfDocument1);
frm.FillField(pdfDocument1.Form.Fields[2].FullName, “Test data editable”);
pdfDocument1.Save("…//Aspose_editable.pdf");
////approach 2 - failed
var fs2 = new FileStream("…//template.pdf", FileMode.Open, FileAccess.ReadWrite);
var pdfDocument2 = new Aspose.Pdf.Document(fs2);
var textBoxField = pdfDocument2.Form.Fields[2] as TextBoxField;
textBoxField.Value = “Test data editable”;
pdfDocument2.Save();
fs2.Close();
//approach 3 - failed
var fs3 = new FileStream("…//template.pdf", FileMode.Open, FileAccess.ReadWrite);
var form = new Aspose.Pdf.Facades.Form(fs3);
form.FillField(form.FieldNames[2], “Test data editable”);
form.Save("…//Aspose_editable.pdf");
fs3.Close();
}
Thanks
John
Hi John,
Thanks for your feedback. I have used following code snippet to fill form field and preserve the extended right. I have tested it with both 9.9.0 and 10.0.0 over win 7 64bit and vs 2010, but I am unable to notice any issue. We will appreciate it if you please share your environment details and a console project to replicate the issue at our end, so I can guide you accordingly.
FileStream fs = new FileStream(myDir + "template(3).pdf", FileMode.Open, FileAccess.ReadWrite);
Document pdfDocument = new Aspose.Pdf.Document(fs);
TextBoxField textBoxField = pdfDocument55.Form.Fields[2] as TextBoxField;
textBoxField.Value = "Test data editable";
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal,
Here, I have attached following items.
1) my test console project.
2) I am using VS 2013. VS2013.jpg screenshot
3) I am using Windows 8.1. PCWin8.jpg screenshot.
4) I am using Aspose.Pdf.dll Version: 9.9.0.0
Thanks
John
Hi John,
Thanks for your feedback. I am preparing the required platform to simulate the environment as of yours. As soon as everything is setup, I will test the issue on my end and will suggest accordingly.
We are sorry for the inconvenience faced.
Best Regards,
Hi John,
Thanks for your patience. We have tested your shared project and noticed the reported issue when we fill a form and preserve extended rights in evaluation mode (without valid license implementation). So logged a ticket PDFNEWNET-38109 in our issue tracking system for further investigation and resolution. However with
implementation of a valid license you may avoid this issue. If you are evaluating Aspose.Pdf without a license you may request a
30 days temporary license for evaluation.
We are sorry for the inconvenience caused.
Best Regards,
Hi John,
Thanks for feedback. It is good to know that you accomplished your requirement with licensee implementation. However we will fix the above reported evaluation mode issue and will update here within this forum thread.
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal,
I am facing another issue. I am saving the pdf file in the database. When I open the pdf file from the database, I am losing extended features and unable to edit pdf fields. I have a valid Aspose license to execute the following code.
Aspose.Pdf.dll
Version: 9.9.0.0
Code:
var fs = new FileStream("template.pdf", FileMode.Open, FileAccess.ReadWrite);
var doc = new Aspose.Pdf.Document(fs);
var textBoxField = doc.Form.Fields[2] as TextBoxField;
textBoxField.Value = "edit this field";
doc.Save(fs, Aspose.Pdf.SaveFormat.Pdf);
// Convert to byte array
BinaryReader rdr = new BinaryReader(fs);
byte[] fileData = rdr.ReadBytes((int)fs.Length);
rdr.Close();
// Close
fs.Close();
// Save to database..Internal process
//SaveDB(fileData)
// Retrieve from database
var newStream = new MemoryStream(fileData);
var newdoc = new Aspose.Pdf.Document(newStream);
var fileNameLocation = string.Concat(@"c:\temp\openFromDb.pdf");
newdoc.Save(fileNameLocation);
System.Diagnostics.Process.Start(fileNameLocation);
Thanks
John
Hi John,
Thanks for your inquiry. I have tested the scenario with the latest version of Aspose.Pdf for .NET 10.0.0 and noticed the issue. We have logged a ticket PDFNEWNET-38126 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,
Hi Tilal,
Thank you for all your help. I found another issue related to the extend feature.
In the following code, when I add highlighted (JavaScript) code, I am losing the extended feature and unable to edit PDF fields.
var fs = new FileStream("template.pdf", FileMode.Open, FileAccess.ReadWrite);
var doc = new Aspose.Pdf.Document(fs);
var textBoxField = doc.Form.Fields[2] as TextBoxField;
textBoxField.Value = "edit this field"
doc.Form.Fields[2].Actions.OnEnter = new JavasScriptAction("app.alert('Show message')");
doc.Save(fs, Aspose.Pdf.SaveFormat.Pdf);
fs.Close();
Thanks,
John
Hi John
tilal.ahmad:
Thanks for your inquiry. I have tested the scenario with latest version of Aspose.Pdf for .NET 10.0.0 and noticed the issue. We have logged a ticket PDFNEWNET-38126 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
In reference to PDFNEWNET-38126, we have further looked into issue and would like to suggest you that you should use incremental updates i.e. use Save() method without parameters as following. Moreover you may save the resultant memory stream into database and later can load data into memory stream and use Document() method with memory stream parameter.
byte[] data = File.ReadAllBytes(myDir + "template (1).pdf");
MemoryStream ms = new MemoryStream();
ms.Write(data, 0, data.Length);
Document doc = new Aspose.Pdf.Document(ms);
TextBoxField textBoxField = doc.Form.Fields[2] as TextBoxField;
textBoxField.Value = "edit this field";
doc.Save();
// you may write memory stream to database or file
using (FileStream file = new FileStream(myDir+"extendedrights.pdf", FileMode.Create, FileAccess.Write)){
ms.WriteTo(file);
}
...
Please feel free to contact us for any further assistance.
Best Regards,
Hi John,
JohnRayner:
Thank you for all your help. I found another issue related to extend feature. In the following code, when I add highlighted (javascript) code I am loosing extended feature and unable to edit pdf fields.
Thanks for your inquiry. We have managed to reproduce the extended rights issue while adding JavaScript to filed action with latest version of Aspose.Pdf for .NET 10.0.0. We have logged a ticket PDFNEWNET-38132 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,
Hi Tilal
Thanks for your help.
PDFNEWNET-38126 : Edit pdf is working fine.
Is there any update on PDFNEWNET-38132 ?
Thanks
John
Hi John,
Thanks for your feedback. It is good to know that your previous issue is resolved. However in reference to PDFNEWNET-38132, please note we have recently noticed the issue and it is still pending for investigation due to other issues, already under investigation and resolution. We will update you as soon as we made some significant progress towards issue resolution.
We are sorry for the inconvenience.
Best Regards,