LoginSignup
4
5

More than 5 years have passed since last update.

prawn で生成する PDF にパスワードを付ける

Posted at

http://t-taira.hatenablog.com/entry/20100116/1263667269 の記事そのままですが、
自分用のメモとして。

pdf_with_encryption.rb
# coding: utf-8
require 'prawn'
require 'prawn/security'

pdf = Prawn::Document.new

pdf.text "Hello, world"
pdf.encrypt_document :permissions => {
  :print_document => true,
  :modify_contents => false,
  :modify_contents => false,
  :copy_contents   => true,
  :modify_annotations => false,
},
  :user_password => 'xxxxxxxxxx',
  :owner_password => :random

pdf.render_file("ps.pdf")
4
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5