Learn R Programming

staplr (version 2.9.0)

set_fields: Set fields of a pdf form

Description

If the toolkit Pdftk is available in the system, it will be called to fill a pdf form with given a list of fields. List of fields can be acquired by get_fields function.

See the reference for detailed usage of pdftk.

Usage

set_fields(input_filepath = NULL, output_filepath = NULL, fields,
  overwrite = TRUE)

Arguments

input_filepath

the path of the input PDF file. The default is set to NULL. IF NULL, it prompt the user to select the folder interactively.

output_filepath

the path of the output PDF file. The default is set to NULL. IF NULL, it prompt the user to select the folder interactively.

fields

Fields returned from get_fields function. To make changes in a PDF, edit the values component of an element within this list

overwrite

If a file exists in output_filepath, should it be overwritten.

References

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

See Also

get_fields

Examples

Run this code
# NOT RUN {
pdfFile = system.file('testForm.pdf',package = 'staplr')
fields = get_fields(pdfFile)

fields$TextField1$value = 'this is text'
fields$TextField2$value = 'more text'
fields$RadioGroup$value = 2
fields$checkBox$value = 'Yes'

set_fields(pdfFile,'filledPdf.pdf',fields)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab