Forum: Ruby on Rails encrypt the pdf

Posted by kiran cy (kirankumarcy)
on 2012-12-05 11:40
I am encrypting the pdf in rails using pdf-toolkit

here is my code:
PDF::Toolkit.pdftk(infile output outfile user_pw rails)

It is giving error saying that
undefined method user_pw

Any suggestions
Posted by Colin Law (Guest)
on 2012-12-05 11:56
(Received via mailing list)
On 5 December 2012 10:40, kiran cy <lists@ruby-forum.com> wrote:
> I am encrypting the pdf in rails using pdf-toolkit
>
> here is my code:
> PDF::Toolkit.pdftk(infile output outfile user_pw rails)
>
> It is giving error saying that
> undefined method user_pw

Have you provided that method or variable?  If not then what do you
think that user_pw is referring to?

Colin
Posted by kiran cy (kirankumarcy)
on 2012-12-05 12:04
I think that is predefined in pdftk
Posted by Colin Law (Guest)
on 2012-12-05 12:12
(Received via mailing list)
On 5 December 2012 11:04, kiran cy <lists@ruby-forum.com> wrote:

Please quote the previous message and put your reply inline at
appropriate points.  Remember this is a mailing list not a forum
(though you may be accessing it via a forum-like interface.  Thanks.

> I think that is predefined in pdftk

Can you point me to the docs that make you think that in

> PDF::Toolkit.pdftk(infile output outfile user_pw rails)

that user_pw is predefined in pdftk?

Colin
Posted by kiran cy (kirankumarcy)
on 2012-12-05 12:14
Colin Law wrote in post #1087900:
> On 5 December 2012 11:04, kiran cy <lists@ruby-forum.com> wrote:
>
> Please quote the previous message and put your reply inline at
> appropriate points.  Remember this is a mailing list not a forum
> (though you may be accessing it via a forum-like interface.  Thanks.
>
>> I think that is predefined in pdftk
>
> Can you point me to the docs that make you think that in
>
>> PDF::Toolkit.pdftk(infile output outfile user_pw rails)
>
> that user_pw is predefined in pdftk?
>
> Colin

http://www.pdflabs.com/docs/pdftk-cli-examples/
Posted by Colin Law (Guest)
on 2012-12-05 12:34
(Received via mailing list)
On 5 December 2012 11:14, kiran cy <lists@ruby-forum.com> wrote:
>>
>>> PDF::Toolkit.pdftk(infile output outfile user_pw rails)
>>
>> that user_pw is predefined in pdftk?
>>
>> Colin
>
> http://www.pdflabs.com/docs/pdftk-cli-examples/

As you have coded it ruby will look for a variable or method called
user_pw from which to get the value to pass to pdftk.  If you want to
pass the string user_pw then I guess that you must put "user_pw".

Colin
Posted by Frederick Cheung (Guest)
on 2012-12-05 14:03
(Received via mailing list)
On Dec 5, 11:14am, kiran cy <li...@ruby-forum.com> wrote:

>
> http://www.pdflabs.com/docs/pdftk-cli-examples/
>

That is the usage summary for the command line tools, not for the ruby
api. For starters you'll need to separate your arguments with commas,
not spaces

Fred
Posted by kiran cy (kirankumarcy)
on 2012-12-06 08:32
It is working pdf is encrypted

my_pdf = 
PDF::Toolkit.open(directory+@encrypt_pdf.attach.url.split('?')[0].to_s)
        my_pdf.user_password=@encrypt_pdf.user_password
        my_pdf.owner_password=@encrypt_pdf.owner_password

how to allow permissions like printing screen reader
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.