pdf_output plugin method for Forms (new feature request?)

Hi,
I have a use case for a client that wants to be able to email a PDF form to their clients part filled in by data from their Servoy solution.
The pdf_output plugin nearly does what I need with the ‘convertPDFFormToPDFDocument’, but I don’t want the PDF file fully “flattened”, just a new PDF form created with some form values filled in from database, but other form values left blank for their client to fill in and then save & email back (does not need to go back in to Servoy database!)
So code something like a ‘convertPDFFormToNewPDFForm’ instead of the ‘convertPDFFormToPDFDocument’

	var pdfform = plugins.file.readFile('TestPDFForm.pdf');
	//var field_values = plugins.file.readFile('c:/temp/1040a-data.fdf');//read adobe fdf values or
	var field_values = new Array()//construct field values
	field_values[0] = 'first_name=Rafi'
	field_values[1] = 'last_name=Galibov'
	var result_pdf_doc = plugins.pdf_output.convertPDFFormToNewPDFForm(pdfform, field_values);
	if (result_pdf_doc != null) {
		plugins.file.writeFile( + 'UpdatedTestPDFForm.pdf', result_pdf_doc);
	}

as the convertPDFFormToPDFDocument does create a new PDF with filled in values, but stops any other fields on form from working…
(I’m not sure much has been done with this plug in for a long time & certainly the docs don’t seem to have been updated for a long time…)

Otherwise, does anyone have an easy way of doing what I’m asking?

Thanks

Rafi

^^^ BUMP ^^^

Anybody?? (more specifically from Servoy that might be able to update the plugin…?)
Thanks

Hi Rafi,

I suggest you file a feature request in the support system.

Hope this helps.

ROCLASI:
I suggest you file a feature request in the support system.

Hi Robert
apologies for not replying sooner ;-)
I will do that, but had hoped someone might have had some other easy/clever solution… ;-)
Thanks

Feature request created

We have a new Servoy solution that offers PDF forms as a service, that might help. Currently it allows PDF form templates to be uploaded and new records to be created for each template. It works with forms in the common PDF acroform format (not xml) with text and checkbox fields. Scripts within PDF forms are not supported. In the solution a form record popup provides the following actions:
Edit Record
Duplicate Record
Email Document
Fill to another Form
Combine forms and sort
Protect Document
Share editable link
Delete Record

We are adding a new option to allow the submission of data from an outside source that fills to any PDF form and emails the form. This should be available by the end of next week. If interested in testing, please let me know.

Anyone can create a new account now, to try the above listed action items, at https://FillinPDF.com

Dean Westover, President
Choices Software, Inc.

^^^ ANOTHER BUMP ^^^
No reply from Servoy & no action on my support case.
This is becoming more pressing for me from my client that needs this feature added.
Please can someone from Servoy have a look??
Have a good weekend
Thanks
Rafi

Hey Rafi,

I am looking for a similar capability.

In my case I have a complex government form and have successfully obtained the field names (using a python script no less).

Now I want to assign values to the field name and then write the values back to the form.

Did you manage to resolve your question?

Did you examine other pdf libraries for javascript?

Tom

Hi Tom,

I’d forgotten about this as client then decided it wasn’t so urgent…

However, I think Servoy did do something to make things work, but without testing again, I think this code might be a starting point for you…

function testPDFForm() {
application.output ( 'testPDFForm entry...' );
	// this is a test of exporting a PDF form from system
	var dir = '';
	var copy_dir = '';
	var fileNameSeperator = '';
	var fnSeps = '';
	var form_name = '/Users/rafig/PDFForm/TestPDFForm.pdf' ;
	if (utils.stringPosition(application.getOSName(), 'Mac', 1, 1) > 0) {
		// it's Mac
		dir = '/Users/rafig/PDFForm';
		copy_dir = dir + 'Copy';
		fileNameSeperator = '/';
		fnSeps = 8;
	} else {
		// it's Window, so do something here
	}

	var pdfform = plugins.file.readFile(form_name);
	//var field_values = plugins.file.readFile('c:/temp/1040a-data.fdf');//read adobe fdf values or
	var field_values = new Array()//construct field values
	field_values[0] = 'first_name=Rafi'; // set PDF form field 'first_name' to value
	field_values[1] = 'last_name=Galibov'; // set PDF form field 'last_name' to value
	var result_pdf_doc = plugins.pdf_output.convertPDFFormToPDFDocument(pdfform, field_values);
	if (result_pdf_doc != null) {
		plugins.file.writeFile(dir + '/TestPDFFormFlatten.pdf', result_pdf_doc);
	}

}

Thanks Rafi,

Your code is similar to the pdf plugin docs.

I will try this soon.

The latest (2025.6.2) pdf plugin appears to have a parameter added to only partially flatten (those fields filled):

byte[] convertPDFFormToPDFDocument(pdf_form:byte[], field_values:Object, partialFlattening:Boolean)

Convert a PDF form to a PDF document. The PDF form can be have all the fields flattened or just the fields specified by values.

@sample

var pdfform = plugins.file.readFile('c:/temp/1040a-form.pdf');
//var field_values = plugins.file.readFile('c:/temp/1040a-data.fdf');//read adobe fdf values or
var field_values = new Array()//construct field values
field_values[0] = 'f1-1=John C.J.'
field_values[1] = 'f1-2=Longlasting'
var result_pdf_doc = plugins.pdf_output.convertPDFFormToPDFDocument(pdfform, field_values)
if (result_pdf_doc != null)
{
	plugins.file.writeFile('c:/temp/1040a-flatten.pdf', result_pdf_doc)
}

@param {byte} pdf_form the PDF Form to convert
@param {Object} field_values the values to use. If partialFlattening is true, only these fields will be flattened.
@param {Boolean} partialFlattening if true, only flatten the fields set as values, the rest remain unchanged
@return {byte} the flattened PDF document as a byte array, or null in case of an error.

Tom

1 Like