tests/testthat/test_fill_pdf_internals.R

# this file is written in UTF-8 encoding


if (requireNamespace("testthat", quietly = TRUE)) {
if (requireNamespace("pdftools", quietly = TRUE)) {
context('fill pdf internals')


test_that('fdf manipulation',{

  pdfFile <- system.file('simpleForm.pdf',package = 'staplr')

  pdfFileRich <- system.file('simpleFormRichText.pdf',package = 'staplr')

  tempFDF = tempfile()
  tempPDF = tempfile(fileext = '.pdf')
  fdfLines = get_fdf_lines(pdfFileRich, tempFDF)


  fill_from_fdf(input_filepath = pdfFile,fdf_filepath =  tempFDF,output_filepath = tempPDF,overwrite = TRUE)

  # pdftools interact wierdly with emoji, it also inconsistently sees the spaces between different
  # # characters.
  pdfTextNewRich = pdftools::pdf_text(tempPDF)
  expect_true(grepl('½¾ ‘’”“•', pdfTextNewRich))





})

  }
}

Try the staplr package in your browser

Any scripts or data that you put into this service are public.

staplr documentation built on Sept. 18, 2023, 5:16 p.m.