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

Error converting PS file containing PJL commands to PDF #60

Open
omasseau opened this issue Aug 31, 2017 · 0 comments
Open

Error converting PS file containing PJL commands to PDF #60

omasseau opened this issue Aug 31, 2017 · 0 comments

Comments

@omasseau
Copy link

omasseau commented Aug 31, 2017

I have a ps file that contains PJL commands.
If I convert it to pdf with the command line (Ghostcript 9.20 on Windows10 64 bits) it works correctly:

gswin64c -dNOPAUSE -dBATCH -dSAFER -dProcessColorModel=/DeviceRGB -dPDFSETTINGS=/default -dCompatibilityLevel=1.4 -dPDFX=false -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -sDEVICE=pdfwrite -sOutputFile=pjl.pdf -q -f pjl.ps

But it does not work with ghost4j. I get an Invalid memory access exception:

Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:383)
at com.sun.jna.Function.invoke(Function.java:315)
at com.sun.jna.Library$Handler.invoke(Library.java:212)
at com.sun.proxy.$Proxy0.gsapi_exit(Unknown Source)
at org.ghost4j.Ghostscript.exit(Ghostscript.java:555)
at org.ghost4j.Ghostscript.initialize(Ghostscript.java:359)
at org.ghost4j.converter.PDFConverter.run(PDFConverter.java:238)
at org.ghost4j.converter.AbstractRemoteConverter.convert(AbstractRemoteConverter.java:85)

Test code:


	public static void main(String[] args) throws Exception {
		
		try {
			String input = "C:\\postscript\\pjl.ps";
			
			PSDocument document = new PSDocument();
			document.load(new ByteArrayInputStream(Files.readAllBytes(Paths.get(input))));
			
			PDFConverter converter = new PDFConverter();

			converter.convert(document, new ByteArrayOutputStream()); 

		} catch (Exception e) {
			throw new Exception("Could not convert postscript to pdf", e);
		}
	}

Without the PJL commands it works fine.

I attached the problematic file: pjl.txt (rename extension to .ps as github does not support .ps attachments).
I also attached the file that works: no-pjl.txt

no-pjl.txt
pjl.txt

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

1 participant