tests/testthat/test-rotate.R

test_that("rotate file", {
  pdf_file <- 'password.pdf'
  ## rotating by 90 and by -270 should give the same result
  outfile1 <- tempfile(fileext = ".pdf")
  pdf_rotate_pages(pdf_file, pages = 1, angle = 90, output = outfile1, password = "ownerpwd")
  outfile2 <- tempfile(fileext = ".pdf")
  pdf_rotate_pages(pdf_file, pages = 1, angle = -270, output = outfile2, password = "ownerpwd")
  expect_identical(unname(tools::md5sum(outfile1)), unname(tools::md5sum(outfile2)))
  ## but should be different to the input file
  expect_false(unname(tools::md5sum(outfile1)) == unname(tools::md5sum(pdf_file)))
  unlink(outfile1)
  unlink(outfile2)
})

Try the cpp11qpdf package in your browser

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

cpp11qpdf documentation built on April 4, 2025, 4:39 a.m.