简体   繁体   中英

is there any way to add outlines(bookmarks) to existed pdf in ruby

I have few pdf files and could combine into single pdf called combined.pdf with the following code.

pdf = CombinePDF.new
pdf << CombinePDF.load("1.pdf")
 # one way to combine, very fast.
pdf << CombinePDF.load("2.pdf")
pdf << CombinePDF.load("3.pdf")
pdf << CombinePDF.load("4.pdf")
pdf.save "combined.pdf"

Now I want to add outlines to this combined.pdf. Trying with the prawn, but no luck. Here is the code that i have tried

Prawn::Document.generate("full_template.pdf", :template => filename) do
  text "THis content is written on the first page of the template", :align => :center

  outline.define do
   section("Slaves", :destination => 1) do
     page :title => "Page 2", :destination => 2
     page :title => "Page 3", :destination => 3
   end
  end
end

https://github.com/yutayamamoto/pdfoutline我制作了一个库,可以帮助您将大纲添加到 PDF 文件中,尽管它不是用 ruby​​ 编写的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM