【问题标题】:merge pdf files with extra blank page at the end of odd-paged documents - qpdf在奇数页文档的末尾合并带有额外空白页的 pdf 文件 - qpdf
【发布时间】:2020-06-04 16:03:26
【问题描述】:

我希望为此使用 qpdf。

我要打印很多小文件,需要双面打印,所以我合并了 20 个文档,最后得到了一个 200 页的 pdf。然后我可以让打印机打印,偶数页颠倒,然后翻转堆栈并将其放回打印机并打印奇数页,所以我们正在使用纸张的两面。

我的问题是如何检测单个空白页并将其添加到任何具有奇数页数的文档的末尾;这样,当我进行双面打印时,每个文档都与其他文档完全分开,而不仅仅是在完成文档的背面打印。

【问题讨论】:

    标签: qpdf


    【解决方案1】:

    我将继续寻找进一步简化此流程的方法,因为我希望工作流程更简单,但我会使用此方法来确保不会有两篇文章共用一张纸。

    pacman::p_load(tidyverse, pdftools, qpdf)
    
    # some prep
    directory <- "Some/FileFolder/Path"
    filelist <- (paste(directory, "/",
                       list.files(directory,
                                  pattern = "*.pdf"), sep = ""))
    
    # bust apart all pdf to inspect
    my_pages <- as.list(lapply(filelist, pdf_split))
    page_summ <- cbind.data.frame(filelist,
                                  lengths(my_pages)) %>%
      rename(filename = 1,
             pages = 2) %>%
      mutate(is_odd = pages %%2==1)
    
    
    # separate into odd and even sets
    odd_docs <- page_summ %>%
      filter(is_odd == TRUE)
    
    even_docs <- page_summ %>%
      filter(is_odd == FALSE)
    
    # I could not find an R process for adding a page to PDFs.
    # For now, I will add a buffer page to docs via a PDF program.
    # Once you are satisfied with your even_docs subset, pdf_combine
    
    tocombine <- as.data.frame(even_docs$filename)
    
    lapply(tocombine, pdf_combine)
    

    这会自动将组合文件生成到先前定义的目录中。新文件名不能使用 lapply() 中的“output =”设置。查找新文件名 = "firstnameintocombine_combined.pdf"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      • 1970-01-01
      相关资源
      最近更新 更多