Hi admin,
With Telerik reporting (RadPdfProcessing), could we able to do bellow?
1. Load existed an AcroForm as template
2. Auto fill data to this template with data in the database
3. Generate to new non editable PDF file
If can do, please post the guideline
Thank you for supporting
Best regards,
4 Answers, 1 is accepted
0
Accepted
Hello Hanh,
Using the PdfProcessing library you can import document containing AcroForm and iterate the form fields using the AcroForm class. The AcroForm class exposes the FormFields collection where you can use the collection indexer to get a form field instance by name. More information of the form field properties can be found in the FormField properties section of the documentation. Sample project demonstrating the import of a PDF document, modify the values of the interactive forms and save it back to the file system can be found in our SDK examples.
In order to generate a non-editable PDF file, you will need to flatten the form fields of the document. Currently the API for flattening form fields is not implemented in the PdfProcessing library. We have logged a feature request in our feedback portal: Implement API for flattening form fields, where you can vote to increase the priority and subscribe to be notified for any status updates. As a workaround, sample implementation how to achieve flattening of form fields can be found in the description of the item.
I hope this helps.
Regards,
Georgi
Progress Telerik
Using the PdfProcessing library you can import document containing AcroForm and iterate the form fields using the AcroForm class. The AcroForm class exposes the FormFields collection where you can use the collection indexer to get a form field instance by name. More information of the form field properties can be found in the FormField properties section of the documentation. Sample project demonstrating the import of a PDF document, modify the values of the interactive forms and save it back to the file system can be found in our SDK examples.
In order to generate a non-editable PDF file, you will need to flatten the form fields of the document. Currently the API for flattening form fields is not implemented in the PdfProcessing library. We have logged a feature request in our feedback portal: Implement API for flattening form fields, where you can vote to increase the priority and subscribe to be notified for any status updates. As a workaround, sample implementation how to achieve flattening of form fields can be found in the description of the item.
I hope this helps.
Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0

Hanh
Top achievements
Rank 1
answered on 23 Jul 2019, 07:08 AM
Hello Georgi,
Thanks for the sample. It's work for me.
(y) Nice supporter, thank you again.
Best regards,
0

Hanh
Top achievements
Rank 1
answered on 13 Aug 2019, 03:03 PM
Hi Georgi,
The example code is not work if i use AcroForm with signature certificate...
Can you support?
0
Hi Hanh,
In order do sign the document you need to use the following code snippet just before exporting the document.
Regards,
Nikolay Demirev
Progress Telerik
In order do sign the document you need to use the following code snippet just before exporting the document.
byte
[] fileAllBytes;
using
(Stream certificateStream = File.OpenRead(certificateFileName))
{
using
(MemoryStream ms =
new
MemoryStream())
{
certificateStream.CopyTo(ms);
fileAllBytes = ms.ToArray();
}
}
if
(fileAllBytes.Length == 0)
{
return
;
}
FormSource formSource =
new
Telerik.Windows.Documents.Fixed.Model.Resources.FormSource();
formSource.Size =
new
Size(420, 150);
X509Certificate2 certificate =
new
X509Certificate2(fileAllBytes, certificatePassword);
SignatureField signatureField = document.AcroForm.FormFields.Where(f => f.FieldType == FormFieldType.Signature).FirstOrDefault()
as
SignatureField;
signatureField.Signature =
new
Signature(certificate);
SignatureWidget widget = signatureField.Widgets.FirstOrDefault();
if
(widget !=
null
)
{
formSource = widget.Content.NormalContentSource;
FixedContentEditor ed =
new
FixedContentEditor(formSource);
ed.TextProperties.FontSize = 80;
ed.Position.Translate(30, 0);
ed.DrawText(
"John Doe"
);
ed.Position.Translate(0, 90);
ed.TextProperties.FontSize = 25;
ed.DrawText(
"Digitally signed on: "
+ DateTime.Now.ToString());
ed.Position.Translate(40, 120);
ed.TextProperties.FontSize = 20;
ed.DrawText(
"(Click here to view the signature info)"
);
}
document.Pages[0].Annotations.Add(widget);
Regards,
Nikolay Demirev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.