3

I want to convert my .ps file (which was created from an encrypted .pdf file) back to a .pdf format.

Using ps2pdf in ghostscript gives me the following message on my command prompt:

This PostScript file was created from an encrypted PDF file.
Redistilling encrypted PDF is not permitted. 
Error: /undefined in
--eexec-- Operand stack:    --nostringval--   --dict:89/200(L)--   quit Execution stack:    %interp_exit   .runexec2   --nostringval--  
--nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1977   1   3   %oparray_pop   1976   1   3  
%oparray_pop   1960   1   3   %oparray_pop   1852   1   3  
%oparray_pop   --nostringval--   %errorexec_pop   .runexec2  
--nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1843   2   3   %oparray_pop  
--nostringval--   --nostringval--   --nostringval-- Dictionary stack:    --dict:1198/1684(ro)(G)--   --dict:1/20(G)--   --dict:89/200(L)--   --dict:1198/1684(ro)(G)-- 
Current allocation mode is local Last OS error: No such file or directory 

GPL Ghostscript 9.18: Unrecoverable
error, exit code 1

Is there anyway to convert my .ps file back to .pdf if I know the password of the original encrypted .pdf file from which the .ps file was created?

vidarlo
  • 23,571
Kewal Shah
  • 1,044
  • Have you tried passing the password on the ps2pdf commandline using the -sOwnerPassword=xxxxx option? – steeldriver Dec 31 '17 at 12:45
  • @steeldriver I tried using it, gives the same message as mentioned in the question. – Kewal Shah Dec 31 '17 at 18:00
  • Do you still have the original (encrypted) PDF document? I would restart with that and decrypt it in the process of conversion to PS. Then you shouldn't need to deal with encryption during the reconversion to PDF. – David Foerster Dec 31 '17 at 19:19
  • @DavidFoerster Yes I have the original PDF document but the problem is, I do not know how to do that! – Kewal Shah Jan 01 '18 at 04:02
  • @KewalShah: A quick search revealed something like this: https://gist.github.com/davidfoerster/9c11bc43f896b7cbd6f9f3fc6f7d79a3. – David Foerster Jan 01 '18 at 11:23
  • @DavidFoerster thanks for the link, but could you please mention explicitly what should I write on my command line, I didn't understand from the script, the order and syntax in which I should write as I'm relatively new to Ubuntu. – Kewal Shah Jan 01 '18 at 11:42
  • 1
    For manual use replace the shell variables $INPUT, $OUTPUT, and $PASSWORD in the gs invocation in the last 5 lines with the respective strings. Examples are in the first 3 lines. Alternatively, save the file, edit the first 3 lines to your liking and execute the script. – David Foerster Jan 01 '18 at 12:06

3 Answers3

5

You can open the .ps file in a text editor of your choice, find the line Removing the following eleven lines is illegal, subject to the Digital Copyright Act of 1998. and remove the following eleven lines, starting with mark currentfile eexec and ending with cleartomark, save and run ps2pdf.

1

Why don't you use imagemagick? Try this:

convert myfile.ps myfile.pdf

Hope it helps you

Tim
  • 11
0

I was trying to get around content protection on a PDF protected by the FileOpen Acrobat add-in, and Radovan Garabík's suggestion was the only thing that worked. The only problem is that exporting to PostScript & converting back to PDF loses all the PDF bookmarks. If anyone has a way of re-generating the bookmarks from the document headings, that would be useful.

FileOpen sucks. I downloaded some PDFs, and they worked, then the next day, they suddenly stopped working, saying they couldn't locate the download info, and it won't allow you to print to PDF until it's cracked using Radovan's method:

Install the OpenFile Adobe Acrobat plugin & Open Adobe Acrobat. Select Edit/Preferences, then General, then at the bottom, untick 'Use only certified plug-ins' & close Acrobat. You should then be able to open the OpenFile-protected PDFs, but access is not permanent or device-independent. To gain permanent access, select File/Export to/PostScript, then save the file. Open the PostScript file with Notepad & search for Digital Copyright Act. Remove the following eleven lines, starting with mark currentfile eexec and ending with cleartomark Save & close the PostScript file. Open the PostScript file with Adobe Acrobat, convert to PDF & save. You can now edit or print to PDF.