Convert "print to file" PRN file to PS - pdf

I spend almost day trying to understand how to convert "print to file" PRN file to PS or PDF file. The PRN file is in PCL format and while looking on google I found that GhostPCL should do conversion job using command line
gpcl6win64.exe -dNOPAUSE -sDEVICE=ps2write -sOutputFile="c:\output.ps" "c:\input.prn"
Unfortunately that I get is binary data from PRN file is moved to ps/pdf file without rendering anything useful only garbage symbols.
Any idea how to convert PRN PCL files to PS or PDF?
I am using the newest version of GhostPCL 9.23 for Win64.
I also attaching test files.
input.prn - the print to file PCL.
output.ps - the PostScript file created using command line above with ps2write. Bad result.
output.pdf - the PDF file created using command line above with pdfwrite. Bad result.
output-correct.pdf - The PDF file created using one of online converters. Produce correct output but looking at PDF metadata it seems it is using GPL Ghostscript 9.19.

The command line you specify will create a PostScript program from the PCL input. I don't understand what you mean by:
binary data from PRN file is moved to ps/pdf file without rendering
anything
The process won't render anything it will produce a PostScript file. Note you can create a PDF file instead by using the pdfwrite device.
Perhaps if you shared an example of the input and output files it might be possible to say more. It would also be helpful to see the entire transcript of the back channel output. If nothing else it would contain the version of GhostPCL being used, which would be helpful to know.
[Edit after files supplied]
I've no idea what led you to believe your file was a PCL file, but it isn't.
The 'PRN' file turns out not to be a PCL file at all. Its an XPS file.
Unsurprisingly, when you run this through the PCL interpreter it doesn't know what to make of it. PCL interpreters treat anything they don't understand as 'text' and try to print it as such. Which is why the content of your PDF begins with 'PK'. XPS files are zip archives, and PK is the signature for a zip archive.
If you use GhostXPS instead it will read the file properly. Or, since this is presumably on Windows 10, you could just save it direct to a PDF file if that's what you want.

Add a Microsoft PS Class Driver printer on a local port FILE:. Make sure that its Print Processor is set to winprint/RAW.

Related

executing a Linux command from PDF file in a PDF viewer

Is it possible to execute a Linux command from a PDF file shown in a PDF viewer?
More specific: I generate PDF files from LaTeX using pdflatex. What I would like to do is to include some symbol or text in the PDF file which starts a Linux command when the user clicks on it. Typically I'm using evince to show PDF files.
I'm not sure whether it is at all possible to execute commands from PDF files in a viewer, and if it is possible, which packages and LaTeX commands would be required to include the symbol or text and the associated command in the PDF file?
(Alternatively, is there at least a way to obtain the number of the current page shown in the PDF viewer? That would help to some extent.)
Thanks a lot!
Unfortunately and rather fortunately you cant do that.The pdf standard doesnt allow to run shell scripts. That would be a HUGE security oversight.

inkscape: multiple page pdf to multiple png

when I convert pdf to image in linux command line, it seems inkscape gets the best result (better quality than gs with same dpi). Unfortunately, it only converts the first page to png. How to convert every pdf page to different png file? Do I have to extract one PDF page and store to a new pdf file , then do inkscape concert, and so on?
This isn't solely using Inkscape, but you could use e.g. pdftk to split up the pdf-file into separate pages and convert every page into a png with Inkscape. For example, like this:
pdftk file.pdf burst;
l=$(ls pg_*.pdf)
for i in $l; do inkscape "$i" -z --export-dpi=300 --export-area-page --export-png="$i.png"; done
Note that pdftk burst creates pdf-files called pg_0001.pdf, etc., so if you have any files named like that, they'll be overwritten. You can remove them afterwards easily using
rm pg_*.pdf
Lu Kas' answer threw warnings for me without doing the conversion. Probably because I'm running Inkscape 1.1
However, i got it running by replacing some deprecated commands:
inkscape pdfFile.pdf --export-dpi=300 --export-area-page --export-filename=imageFile.png;
For batch processing rather than slowly looping through file by file inkscape has a shell mode for command file scripting. See https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#Shell_mode
However like all other #file.txt scripts you need to write a custom text file. and for Windows users run against higher ranking inkscape.com not .exe
Since version 1.0 (currently 1.2) a multipage pdf of contents can be addressed for multiple outputs. for some other examples see https://inkscape.org/doc/inkscape-man.html#EXAMPLES
Commands get replaced over time so currently to export png use --export-type="xxx" to batch export a list of input files to type xxx. Thus in this case --export-type="png"
Also for pdf related inputs and support see https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#New_options
For windows users there is a handy batchfile converter here https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11

I found a file in raw lyx output, how do I create a readable pdf or txt file from this mess?

I found a file in raw lyx output, how do I create a readable pdf or txt file from this mess?
https://raw.githubusercontent.com/jarcane/bedroom-wall-press/master/hulks-and-horrors/HnHCompanionI.lyx
I have installed LyX and tried pasting, I have tried pasting in OpenOffice and then exporting as plain text, then importing plain text into LyX, it always includes the format coding when I try to export the file as pdf or text.
I just want the human readable portion of the document.
Any help would be appreciated, thank you.
The LyX file you link to is indeed a valid .lyx file. To use it, do the following:
Download the file. The easiest way to do this is to just run
wget "https://raw.githubusercontent.com/jarcane/bedroom-wall-press/master/hulks-and-horrors/HnHCompanionI.lyx"
Open the file in LyX.
Compile to PDF by clicking on the "eyes" icon, or by going to File > Export > PDF (pdflatex) in which case a .pdf file will be created in the same directory as the .lyx file.
Note that you the .lyx file depends on other files. For example, there is an image included in the .lyx file with a path "C:/Users/BearBear/Google Drive/Hulks and Horrors B&W Logo for Print.png".
It is possible that you won't be able to compile the document because of the missing .png or because you do not have a complete TeX installation. In this case, you can simply read the document in LyX. It is not as pretty as in the PDF but it is certainly readable in my opinion.

Why do I obtain countless 'programming' pages of characters/numbers when printing pdf/png files using lpr?

I've got a silly problem which is literally driving me mad:
When I try to print a file using lpr file.pdf depending on the file I obtain one of the following issues:
the printer does not recognise the A4 format
the file is printed but together with a countless number of pages of programming code ( the 'real' face of a PDF file I guess), characters and numbers.
The same happens also for PNG files.
I'm using MAC OS X El capitan and a Xerox colorQube printer.
Clearly if I open the file with Acrobat or Preview and just make the printing manually I have no problem at all.
I hope you can give me some clues because I couldn't find anything useful on the web.
PS: If I use the option -l the printer prints a sheet saying that the printer is not configured to print pdf files directly.
lpr sends file directly to printer, it may not understand pdf as-is, but since pdf is a successor to postscript - it can contain familiar commands so something gets printed, but the rest, probably the embedded preview and so on - gets printed as raw text
Try using ghostscript to convert to postscript before sending to printer:
gs -dSAFER -dNOPAUSE -sDEVICE=(your printer name) -sOutputFile=\|lpr file.pdf

Using Texmaker, I want to lock the PDF file created so others cannot copy text or print the file

I'm creating PDFs using Texmaker. I would like to create some of the PDF files so that when I give the PDF to others, they are not able to print the file or to copy the text. I know I can do this with some PDF creator applications, but can I do that from some command like program I have with Latex, MikTex and TexMaker?
It wouldn't be effective anyway. There are bits in the pdf format that purport to forbid the user from doing this, but they are really just suggestions that the reader application may or may not act on. There is nothing to stop a user from removing the code that inspects the bits from a free/libre PDF reader, or just to run a tool over the file to remove the restrictions.