Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Low level API not able to transform PDF to PDF in multi-threading environment #63

Open
Akash1684 opened this issue Sep 30, 2018 · 4 comments

Comments

@Akash1684
Copy link

Akash1684 commented Sep 30, 2018

I am using Ghost4j 1.0.1 with Ghostscript version Ghostscript 9.05 and converting PDF to PDF using the following parameters:

final String[] gsArgs = new String[10];
        gsArgs[0] = "-pdf2pdf";
        gsArgs[1] = "-dNOPAUSE";
        gsArgs[2] = "-dBATCH";
        gsArgs[3] = "-dSAFER";
        gsArgs[4] = "-sDEVICE=pdfwrite";
        gsArgs[5] = "-sOutputFile=" + outputFileName;
        gsArgs[6] = "-c";
        gsArgs[7] = ".setpdfwrite";
        gsArgs[8] = "-f";
        gsArgs[9] = inputFileName;

However, I am getting following exception on calling gs.initialize(gsArgs):

org.ghost4j.Ghostscript: Page 3
org.ghost4j.Ghostscript: Error: /nocurrentpoint in --run--
org.ghost4j.Ghostscript: Operand stack:
org.ghost4j.Ghostscript: --dict:14/14(L)-- --dict:0/0(ro)(G)--
org.ghost4j.Ghostscript: Execution stack:
org.ghost4j.Ghostscript: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop --nostringval-- --nostringval-- 4 1 10 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval--
org.ghost4j.Ghostscript: Dictionary stack:
org.ghost4j.Ghostscript: --dict:1157/1684(ro)(G)-- --dict:1/20(G)-- --dict:83/200(L)-- --dict:83/200(L)-- --dict:109/127(ro)(G)-- --dict:291/300(ro)(G)-- --dict:24/31(L)-- --dict:6/8(L)-- --dict:28/40(L)--
org.ghost4j.Ghostscript: Current allocation mode is local
org.ghost4j.Ghostscript: Last OS error: 2
org.ghost4j.Ghostscript: GPL Ghostscript 9.05: Unrecoverable error, exit code 1

I am using thread safe approach, defined in http://www.ghost4j.org/threadsafetyandmultithreading.html and synchronizing on GS instance.

@4F2E4A2E
Copy link
Collaborator

4F2E4A2E commented Oct 9, 2018

Please upload a pdf document example in order to be able to reproduce the problem.
It could be very well related to your content, thanks.

@Akash1684 Akash1684 changed the title java.io.IOException: Content found after EOF Low level API generates Corrupted file in multi threaded environment Oct 12, 2018
@Akash1684 Akash1684 changed the title Low level API generates Corrupted file in multi threaded environment Low level API not able to transform PDF to PDF in multi-threading environment Oct 20, 2018
@Akash1684
Copy link
Author

Akash1684 commented Oct 20, 2018

@4F2E4A2E - I am not able to share the exact file. However, I have added the log trace for more information. I agree that issue is related to the content of the file since the same approach worked for multiple PDF files in past.

The pattern I am seeing is that PDF files generated through Acrobat Distiller 18.0 (Windows) are causing this issue.

Note: I've found a similar issue for PS to PDF https://stackoverflow.com/questions/9905507/what-does-this-ghostscript-error-message-mean

@4F2E4A2E
Copy link
Collaborator

Did you ask the Acrobat Distiller 18.0 (Windows) about this?

@Akash1684
Copy link
Author

Error: /nocurrentpoint in --run--
Operand stack:
   --dict:14/14(L)--   --dict:0/0(ro)(G)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1894   1   3   %oparray_pop   1893   1   3   %oparray_pop   1877   1   3   %oparray_pop   --nostringval--   --nostringval--   6   1   10   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1155/1684(ro)(G)--   --dict:1/20(G)--   --dict:83/200(L)--   --dict:83/200(L)--   --dict:109/127(ro)(G)--   --dict:291/300(ro)(G)--   --dict:24/31(L)--   --dict:6/8(L)--   --dict:28/40(L)--
Current allocation mode is local
Last OS error: 2

GPL Ghostscript 9.05: Unrecoverable error, exit code 1

GPL Ghostscript 9.05: ERROR: A pdfmark destination page 5 points beyond the last page 4.

The issue is that Ghostscript is reading pdfmark and then failing on incorrect pdfmark. PDF is now generated using Adobe Acrobat Standard DC 18.11.20063 rather than Acrobat Distiller 18.0 (Windows) so the generation software was not an issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants