# Can't print PRN file

## sidkdbl07

I have a bunch of PRN files from a windows machine that I want to print on my linux machine.

I tried the following command but the light on my printer (a Canon s520) only blinks, and nothing prints.

 *Quote:*   

> ->lpr -Ps520 myfile.prn

 

I have turboprint drivers installed.

I also tried doing the following but it gave me errors.

 *Quote:*   

> ->ps2pdf myfile.prn myfile.pdf
> 
> Fontconfig error: "~/.fonts.conf", line 1: not well-formed (invalid token)
> 
> Error: /syntaxerror in -file-
> ...

 

What gives? Can anyone help?

----------

## moocha

Catting it directly to your printer device node (/dev/lpr or whichever it is) doesn't work?

----------

## sidkdbl07

I tried to the following and it gives the same result as my lpr command

 *Quote:*   

> cat myfile.prn | lpr -Ps520

 

Is that what you mean?

----------

## moocha

No, something like 

```
cat myfile.prn > /dev/lp0
```

 Note that if /dev/lp0 doesn't exist this will copy myfile.lpr to /dev with the name lp0; if it didn't work please check afterwards and make sure to delete it. Look at the file size - the device node should be zero bytes long, the file will be, well, whatever amount of bytes it is  :Very Happy: .

----------

## sidkdbl07

I even tried this as root but it didn't work.

 *Quote:*   

> cat myfile.prn > /dev/usb/lp0

 

BTW, I can print from openoffice fine.

----------

## rouben

The most likely cause for ps2pdf's failure is because the PRN file is not really a PostScript file. Most inkjet/bubblejet printers don't use PostScript (they use a proprietary, closed-source binary language), and ps2pdf assumes that you feed it standard PostScript files, which are actually just text files containing special commands (human readable... almost  :Wink: ).

If you're not sure what type of file your Windows printer driver generated, use the file command (really handy). For example, I have a Canon i950, and when I try to "file" its PRN files, I get a report that the file contain "data" (i.e. the file command has no idea what the filetype is). If I feed file a PostScript file, it recognizes that immediately. In this example, i950.prn and ps.prn are Canon i950 and PostScript PRN files, respectively:

```
[rouben@einstein rouben]$ file pc/i950.prn 

pc/i950.prn: data

[rouben@einstein rouben]$ file pc/ps.prn

pc/ps.prn: PostScript document text conforming at level 3.1

[rouben@einstein rouben]$
```

You can even crack open both files in your favourite text editor and see that there's a big difference.  :Wink: 

With regards to printing these PRN files, I do believe that since you're using the TurboPrint drivers, you have to feed proper PostScript files to the s520 printer queue, as normally all UNIX drivers expect either plain text or PostScript as input. So what happens is that you feed the TurboPrint driver a binary file that it can't understand, because that binary file is not plain text or PostScript. Here's how UNIX printing systems work:

The command lpr -PmyPrinter filename grabs the input file "filename" and passes it on to the printer driver associated to the "myPrinter" print queue. Normally the "filename" needs to be plain text or PostScript.

The driver (called a filter) associated with "myPrinter" queue takes the plaintext/PostScript data and converts it (if necessary) to a language your printer can understand (in your case, Canon's proprietary binary language).

CUPS/LPRnG or whatever printing system you use then picks up the output of the driver (whatever it is) and feeds it to the printer, which causes the printer to print.

Now here's what happens when you try to print your Windows PRN files:

The command lpr -Ps520 myfile.prn (or cat myfile.prn | lpr -Ps520, both commands do the same thing) grabs the input file "myfile.prn" and passes it on to the printer driver associated to the "s520" print queue (i.e. the TurboPrint driver).

The TurboPrint driver tries to make sense of your myfile.prn, but can't really understand enything, because it can only understand plain text or PostScript. Since the input is neither one of these, the TurboPrint driver panics and either outputs nonsense garbage or something like "do nothing".

CUPS/LPRnG or whatever printing system you use then picks up the output of the TurboPrint driver (even though it's garbage output, the printing system doesn't care) and feeds it to the printer. Upon receiving the nonsense, the printer lights up... and does nothing, thankfully. Otherwise you'd have a pile of wasted paper and ink on your desk.  :Wink: 

What you need to do is to hand the PRN file to the printer directly. You can accomplish that by adding another printer in CUPS without a driver (or using the "raw" driver). Then use that printer to print your PRN files. By doing this you're telling CUPS/LPRnG/whatever to give the contents of "myfile.prn" to the printer directly, which is what you want to do, since your PRN file is in a format your printer can understand. That should theoretically work.

Tell me how it goes... oh and I hope I've made sense here. Tell me if there's something you'd like cleared up.

----------

## sidkdbl07

Rouben buddy...that was a great reponse! 

I set up a printer called "PRN_Printer" within CUPS and used the raw driver. Then I tried a similar command but it does the same thing.

 *Quote:*   

> lpr -PPRN_Printer myfile.prn

 

I have tried it with the s520 printer turned off in CUPS and the same thing... light blinks but nothing happens.

----------

