set_fields: Set fields of a pdf form

View source: R/fill_pdf.R

set_fieldsR Documentation

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,
  convert_field_names = FALSE,
  flatten = FALSE
)

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.

convert_field_names

If you set convert_field_names when using get_fields you should set this to TRUE as well so the fields can be matched correctly.

flatten

If TRUE, the form fields will be flattened and turned into plain text.

Value

TRUE if the operation was succesfful. FALSE if the operation fails.

Author(s)

Ogan Mancarci

References

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

See Also

get_fields

Examples

pdfFile = system.file('simpleForm.pdf',package = 'staplr')
fields = get_fields(pdfFile)

fields$TextField$value = 'this is text'
fields$TextField2$value = 'more text'
fields$Checkbox$value = 'Yes'

output <- tempfile(fileext = '.pdf')

set_fields(pdfFile,output,fields)


pridiltal/staplr documentation built on Jan. 26, 2024, 9:11 a.m.