PRN File Documentation
Summary
A PRN (printer output file) holds the exact data stream a printer would receive, saved to disk instead of sent to hardware, usually when you pick “Print to file” in a print dialog. The bytes inside are written in the printer’s own page-description language, most often PostScript or HP PCL, so a .prn is device code, not a readable document. Its MIME type is application/octet-stream. You send it raw to a matching printer to reproduce the page.
Technical details
| Feature | Value |
|---|---|
| Full name | Printer output file (print-to-file) |
| File extension | .prn |
| MIME type | application/octet-stream |
| Format type | Spooled printer data — a page-description or control stream, not a document format |
| Category | Page layout / printer data |
| Developer | None (generic; produced by printer drivers and the print spooler) |
| Introduced | Print-to-file dates to early PC printing (1980s) |
| Common contents | PostScript, HP PCL, PCL 6 (PCL-XL), Epson ESC/P, or raw raster |
| Open standard | Partial — PostScript and PCL are documented; a raw driver dump is device-specific |
| Byte order | Depends on the language inside (PostScript is text; PCL mixes text and binary) |
| Magic number | None fixed. PostScript starts %!PS (25 21 50 53); PCL often 1B 45 (ESC E); PJL jobs start 1B 25 2D 31 32 33 34 35 58 (ESC %-12345X) |
| Editable | No — layout and fonts are frozen into printer code |
| Related extensions | .ps, .pcl, .eps, .spl, .pdf |
| Also used by | Microsoft Excel “Formatted Text (Space delimited)” export — a plain-text table, unrelated to printing |
| Specification | Adobe PostScript Language Reference; HP PCL / PCL XL reference |
What is a PRN file?
A PRN file is a captured print job: the exact byte stream a printer would have received, written to disk instead of sent down the cable. It is created when you tick “Print to file” in a print dialog, or when a driver is configured to spool to a file. Print-to-file has existed since the earliest days of PC printing in the 1980s, and the .prn name is a Windows convention rather than a defined format. There is no PRN specification, because a .prn is not one thing: its contents are whatever page-description language the driver that made it speaks.
That is the key idea. A .prn is device data, not a document. When you print normally, the application hands your page to a printer driver, the driver renders it into the printer’s command language, and the spooler streams those bytes to the hardware. Print-to-file simply intercepts that final stream and saves it. The result is meant to be re-sent to a compatible printer to reproduce the page byte-for-byte, with fonts, margins and layout already resolved. You generally cannot edit it and, for most variants, cannot view it on screen.
Which printer language is inside
Because the driver decides the encoding, the first job with any .prn is to work out what language it holds. Four possibilities cover almost every file.
| Language | First bytes | What it is |
|---|---|---|
| PostScript | 25 21 50 53 (%!PS) | Adobe’s page-description language; a full program describing the page |
| HP PCL | 1B 45 (ESC E) | Printer Command Language; escape sequences plus raster and font data |
| PJL wrapper | 1B 25 2D 31 32 33 34 35 58 (ESC %-12345X) | Printer Job Language prologue that selects paper/duplex/language, then hands off to PostScript or PCL |
| Raw / ESC/P / raster | device-specific | Epson ESC/P control codes or a pre-rendered bitmap for the exact model |
Open the file in a text editor to read those first bytes. A PostScript job is human-readable text: it begins %!PS-Adobe-3.0, then a block of %% DSC (Document Structuring Convention) comments such as %%BoundingBox, %%Pages and %%Title, followed by the PostScript operators that draw the page. A PCL or raw job is mostly unreadable binary: you will see the ESC byte (0x1B) scattered through short command sequences, and long runs of compressed raster data with no readable structure.
PostScript print jobs
The PostScript variant is the friendliest, because PostScript is a complete, stack-based programming language rather than a static file. A PostScript .prn is a program that, when executed by a PostScript interpreter, paints the page. The header carries the DSC comments that let spoolers reorder or count pages without running the code; the body is a sequence of operators (moveto, lineto, show, fill) with fonts either referenced or embedded inline.
%!PS-Adobe-3.0
%%Title: invoice.pdf
%%Creator: PScript5.dll Version 5.2.2
%%BoundingBox: 0 0 612 792
%%Pages: 1
%%EndComments
...
72 720 moveto
/Helvetica findfont 12 scalefont setfont
(Total due: 149.00) show
showpage
%%EOF
Because it is a real program, a PostScript .prn can be interpreted off the printer. Ghostscript reads the PostScript and can rasterise the page to an image (gs -sDEVICE=png16m) or produce a PDF with its ps2pdf wrapper. If the job is already PostScript, it effectively is a PostScript file, and renaming .prn to .ps lets PostScript-aware tools recognise it. This is the one case where a .prn can be previewed and converted cleanly.
PCL and raw jobs
HP’s PCL is not a programming language; it is a stream of escape sequences that set state and place data. A PCL job opens with the reset ESC E, then commands such as ESC &l for page layout, ESC ( for font selection and ESC *r to start raster graphics, interleaved with the compressed bitmap rows themselves. Later HP printers speak PCL 6, also called PCL-XL, which is a compact binary protocol rather than escape-based text and is even less readable.
A PCL .prn cannot be interpreted by Ghostscript alone, which only understands PostScript and PDF. It needs a PCL interpreter: GhostPCL (ghostpdl) renders PCL and PCL-XL to an image or PDF. A truly raw job — ESC/P codes for an old Epson dot-matrix, or a raster bitmap targeted at one specific model — is the hardest case: it is tied so tightly to the device that the only reliable way to realise it is to send it to that same printer.
Sending a .prn to a printer
The reliable way to “open” a print job is to give it back to a printer that speaks the same language, ideally the same driver that created it. The bytes must reach the printer raw, with no further driver processing, or they get double-encoded and print as garbage. On Windows, copy the file in binary mode straight to a shared queue: copy /b invoice.prn \\PC\PrinterShare. On Linux and macOS, send it raw through CUPS with lpr -o raw invoice.prn. If the target printer does not understand the embedded language (a PostScript job sent to a PCL-only printer, say), it will print pages of code instead of the document.
The unrelated Excel .prn
One other file also carries this extension and confuses searches. Microsoft Excel’s “Formatted Text (Space delimited)” export writes a .prn that is plain ASCII text: a fixed-width table where columns are padded with spaces to align. That file has nothing to do with printing. It opens in any text editor or back in Excel, and you can tell it apart instantly because it is readable columns of your own data, not %!PS or a wall of escape codes. If your .prn came out of Excel, treat it as a text table, not a print job.
Frequently asked questions
Why is my PRN file full of unreadable characters?
Because it is a print job written in the printer’s own language, not a document. PCL and raw jobs are mostly binary control codes and compressed raster data, which look like garbage in a text editor. A PostScript job is the exception: it is readable text beginning %!PS.
Can I edit a PRN file?
Not in any practical sense. The layout, fonts and page geometry are already resolved into device code, so there is no editable document structure left. To change the content you go back to the original application and re-print, or re-export to a real document format.
How do I know if my PRN is PostScript or PCL?
Read the first bytes. %!PS means PostScript, which Ghostscript can preview and convert. ESC E (1B 45) or a PJL prologue means PCL, which needs GhostPCL. That single check decides which tool can handle the file.
References
- Ghostscript — PostScript/PDF interpreter (ps2pdf, rasterising)
- GhostPDL / GhostPCL — PCL and PCL-XL interpreter
- Microsoft — Sending files to a printer from the command line
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.