0

I have a .pdf that contains alot of forms that i dont want the user to be able to edit.

Have tried CAM::PDF but i cant manage to load my pdf file into this. I only get a page with checkboxes but no text

This is how the pdf is supposed to look like:

-

This is how the file looks like from CAM::PDF

-

Does anyone know what i'm doing wrong? If i remove the setPrefs line i get the rigth pdf put without the settings i want.

Sample of code:

my $file = CAM::PDF->new($pdf_file_path);
$file->sefPrefs('', '', 1, 0, 1, 0);
$file->output('C:\temp\campdf.pdf');
$file->save();

EDIT: used pdftk, this had an option to flatten the pdf and made my pdf not editable.

Onionhill
  • 1
  • 1

2 Answers2

1

For anyone else with this problem, I was able to use CAM::PDF to make a PDF read-only:

$file->sefPrefs(undef, undef, 1, 0, 0, 0);

I believe if the 'copy' pref is set to true, the user can still edit the fields because they still have the option to "save a copy" but not to overwrite the original.

In my case I also had to do the following to get the form fields to properly fill out:

$file->getFormFieldList;   # I think this forces the fields to be cached but it wouldn't work without
...
$file->clean;
kbosak
  • 2,132
  • 1
  • 13
  • 16
-1

If you want read only try this.

chmod 0555, "example.pdf";
iCanHasFay
  • 662
  • 5
  • 12
  • I have tried this. I can still make a change in pdf and print it with wrong info =/ This only helps me make the user nor overwrite – Onionhill May 25 '12 at 13:21
  • When you say "i dont want the user to be able to edit" do you mean you don't want them to be able to input anything in the forms or are they able to edit the form labels? – iCanHasFay May 25 '12 at 14:44
  • What i mean is that my perl script is filling in the form with info. This info should not be editable. – Onionhill May 29 '12 at 07:35