Click here to Skip to main content
12,818,688 members (28,948 online)
Click here to Skip to main content
Add your own
alternative version


86 bookmarked
Posted 3 Jun 2005

EMF Printer Spool File Viewer

, 23 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
A viewer application for EMF format spool files.

What is an EMF spool file?

When an application sends pages to a printer they are held in an intermediary file which the application can write to and the printer driver can read from simultaneously. This speeds up the print process as control can return to the application before the printer has finished printing the document.

Usually this spool file is held in the raw printer page definition language (which could be PCL, PostScript or one of many other options) but in Windows NT, 2000, XP and 2003, it is possible to make the spooler use a different, more device independent format known as an EMF spool file.

The file layout of an EMF spool file is not officially documented by Microsoft, but the newly released documentation ( reveals that it is a series of enhanced metafile records (one for each page) and a number of other record types which are specific to the business of printing these pages.

The EMF spool file record types

The spool file is composed of the following record types:

Private Enum SpoolerRecordTypes
    SRT_EOF = &H0            ' // int32 zero
    SRT_RESERVED_1 = &H1     '*  1                               */
    SRT_FONTDATA = &H2       '  2 Font Data                      */
    SRT_DEVMODE = &H3        '  3 DevMode                        */
    SRT_FONT2 = &H4          '4 Font Data                        */
    SRT_RESERVED_5 = &H5     ' 5                                 */
    SRT_FONT_MM = &H6        ' 6 Font Data (Multiple Master)     */
    SRT_FONT_SUB1 = &H7      '   7 Font Data (SubsetFont 1)      */
    SRT_FONT_SUB2 = &H8      '   8 Font Data (SubsetFont 2)
    SRT_RESERVED_9 = &H9
    SRT_UNKNOWN = &H10       ' // int unknown...
    SRT_PAGE = &HC           ' 12  Enhanced Meta File (EMF)       */
    SRT_EOPAGE1 = &HD        ' 13  EndOfPage                      */
    SRT_EOPAGE2 = &HE        ' 14  EndOfPage                      */
    SRT_EXT_FONT = &HF       ' 15  Ext Font Data                  */
    SRT_EXT_FONT2 = &H10     ' 16  Ext Font Data                  */
    SRT_EXT_FONT_MM = &H11   ' 17  Ext Font Data (Multiple Master)
    SRT_EXT_FONT_SUB1 = &H12 ' 18  Ext Font Data (SubsetFont 1)   */
    SRT_EXT_FONT_SUB2 = &H13 '* 19  Ext Font Data (SubsetFont 2)  */
    SRT_EXT_PAGE = &H14      ' 20  Enhanced Meta File?
End Enum

Of these the most important record types are:


This record contains a Windows standard enhanced metafile, consisting of an EMF header and one or more EMF graphics record structures. The EMF header record gives you the dimensions of the boundary rectangle (the area inside the print margins), the number of graphics records that make up the page, and the file size of this single EMF page.


This record contains the device settings that apply to the rest of the pages in the document (or until another DEVMODE record is encountered that overrides it). The DEVMODE structure holds details such as the number of copies, the page orientation (landscape versus portrait), the paper size and paper source, and so on.


This signifies the end of the spool file records.

Using the EMF spoolfile viewer

To view an EMF spool file, select the menu File -> Open. A dialog box will appear to allow you to browse to the spool file (extension .spl). These are typically held in your $winnt$\System32\spool\ directory. (I have included some samples with this application code as well.)

The viewer allows you to go to a particular page, zoom in and out, and even print the spool file using the following menu options:

  • File
    • Open - Brings up a dialog box to find and open EMF spool files.
    • Print - Allows you to reprint the currently open EMF spool file.
    • Properties - Brings up a dialog box listing the print file properties.
    • Exit - Quits the application.
  • Pages
    • First Page - Goes to the beginning of the document.
    • Previous Page - Goes back one page.
    • Next Page - Goes to the next page.
    • Last Page - Goes to the end of the document.
    • Goto - Goes directly to the selected page.
    • Properties = Brings up a dialog with the properties of this page.
  • View
    • Zoom in enlarges the preview.
    • Zoom out reduces the size of the preview.

Uses for EMF spoolfiles

Since pretty much every application has a print function, the EMF spool file can serve as a quick and dirty portable document format (though much less featured than a PDF). Thus if you have an application and you want to send a file to someone who doesn't have that application to view, you simply use the application's print function and send them the spool file.

In addition, knowing the structure of the spool file means that it is possible to parse the file to extract information from it. You might want to extract just the text from a printed document for archival purposes, and you can do this by parsing the file and extracting the EMR_EXTTEXTOUTA and EMR_EXTTEXTOUTW records.


The source code in this application draws heavily on the work of Feng Yuan and Christophe Lindemann as well as numerous others on the various forums and news groups.

Portions of this article based on These portions are subject to the GNU Free Documentation License and are copyright © 2003-2005 Free Software Foundation, Inc.


  • 21 Aug 2006

    Code updated to .NET 2.0 and page navigation improved.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Duncan Edwards Jones
Software Developer (Senior)
Ireland Ireland
C# / SQL Server developer
Microsoft MVP (Azure) 2017
Microsoft MVP (Visual Basic) 2006, 2007

You may also be interested in...

Comments and Discussions

AnswerRe: Crash on load Pin
Duncan Edwards Jones25-Jun-12 4:53
memberDuncan Edwards Jones25-Jun-12 4:53 
QuestionCannot take the text of the Record Pin
sgkin8-Feb-12 8:34
membersgkin8-Feb-12 8:34 
AnswerRe: Cannot take the text of the Record Pin
internet7827-Feb-12 1:26
memberinternet7827-Feb-12 1:26 
GeneralMy vote of 5 Pin
LeviButler10-Jan-12 4:00
memberLeviButler10-Jan-12 4:00 
GeneralThere is definitely a difference between executable and source Pin
Member 58133013-Jun-11 3:37
memberMember 58133013-Jun-11 3:37 
GeneralRe: There is definitely a difference between executable and source Pin
Member 800497814-Jun-11 1:58
memberMember 800497814-Jun-11 1:58 
GeneralRe: There is definitely a difference between executable and source Pin
CalcMan5512-Jul-11 9:01
memberCalcMan5512-Jul-11 9:01 
GeneralRe: There is definitely a difference between executable and source Pin
Duncan Edwards Jones22-Jan-12 11:41
memberDuncan Edwards Jones22-Jan-12 11:41 
GeneralRe: There is definitely a difference between executable and source Pin
Duncan Edwards Jones23-Apr-14 1:19
professionalDuncan Edwards Jones23-Apr-14 1:19 
GeneralCode difference? Pin
Skif7-Jun-11 14:14
memberSkif7-Jun-11 14:14 
GeneralLoading emf file .... nothing happens... Pin
tinvaltino15-Sep-10 13:28
membertinvaltino15-Sep-10 13:28 
GeneralRe: Loading emf file .... nothing happens... Pin
Duncan Edwards Jones9-Dec-10 8:33
memberDuncan Edwards Jones9-Dec-10 8:33 
GeneralRe: Loading emf file .... nothing happens... Pin
Loris Rinaldo10-Nov-11 5:31
memberLoris Rinaldo10-Nov-11 5:31 
GeneralRe: Loading emf file .... nothing happens... Pin
Loris Rinaldo18-Nov-11 11:21
memberLoris Rinaldo18-Nov-11 11:21 
GeneralRe: Loading emf file .... nothing happens... Pin
Loris Rinaldo18-Nov-11 11:23
memberLoris Rinaldo18-Nov-11 11:23 
QuestionExtract text from .spl file to .txt file Pin
BuzardHawk24-Jul-10 10:06
memberBuzardHawk24-Jul-10 10:06 
GeneralAdobe PDF Files Display Incorrectly [modified] Pin
tokfrans22-Mar-10 3:44
membertokfrans22-Mar-10 3:44 
I really appreciate the hard work that has been put into this article and the source code especially.
I have found that viewing PDF files doesn't work correctly for some documents.
When loading the spooler file, the text looks scrambled and the underlying text is different to what's showing in the display.
To illustrate this I'm showing what I'm seeing.

In the original document when printed on paper you can find this text:
Hardware Requirements

The EMFViewer Application displays:

When debugging the code, I find that this is the text in the EMF record:

To me this seems like the EMF display has been shifted one byte up. H=I, a=b, r=s and so forth. And the same goes for the EMF record text, but the shift is 28 bytes, H=, a=E, r=V, d=H. You get the picture.

Some PDF files works without any problems and looks great, and others display problems like or similar to this.
Can anyone please try to explain why this is, and if there's anything I can do to handle this.


GeneralRe: Adobe PDF Files Display Incorrectly Pin
Duncan Edwards Jones22-Mar-10 10:38
memberDuncan Edwards Jones22-Mar-10 10:38 
GeneralDidn't get The Text From Spool Job using EmfTextRecord Pin
m.junaid8614-Jan-10 2:25
memberm.junaid8614-Jan-10 2:25 
GeneralRe: Didn't get The Text From Spool Job using EmfTextRecord Pin
Duncan Edwards Jones14-Jan-10 21:52
memberDuncan Edwards Jones14-Jan-10 21:52 
GeneralRe: Didn't get The Text From Spool Job using EmfTextRecord Pin
mujahidcodeproject21-Jun-12 1:08
membermujahidcodeproject21-Jun-12 1:08 
GeneralRead Text Printer output Pin
bardill19-Dec-08 5:17
memberbardill19-Dec-08 5:17 
GeneralPrint all pages Pin
Count.Zilch12-Dec-08 0:15
memberCount.Zilch12-Dec-08 0:15 
GeneralRe: Print all pages Pin
Duncan Edwards Jones12-Dec-08 23:18
memberDuncan Edwards Jones12-Dec-08 23:18 
GeneralRe: Print all pages Pin
Count.Zilch13-Dec-08 1:05
memberCount.Zilch13-Dec-08 1:05 
GeneralRe: Print all pages Pin
Duncan Edwards Jones23-Apr-14 4:24
professionalDuncan Edwards Jones23-Apr-14 4:24 
GeneralIt's great, thanks. Where can I find the code of SpoolfileReaderBase.dll??? [modified] Pin
amanofsky10-Oct-08 7:40
memberamanofsky10-Oct-08 7:40 
GeneralRe: It's great, thanks. Where can I find the code of SpoolfileReaderBase.dll??? Pin
Dhanushkatr9-Jun-09 19:00
memberDhanushkatr9-Jun-09 19:00 
QuestionProblem with GDI+ Pin
hsirc21-Sep-08 8:30
memberhsirc21-Sep-08 8:30 
AnswerRe: Problem with GDI+ Pin
Duncan Edwards Jones22-Sep-08 2:37
memberDuncan Edwards Jones22-Sep-08 2:37 
GeneralRe: Problem with GDI+ Pin
hsirc23-Sep-08 21:09
memberhsirc23-Sep-08 21:09 
GeneralRe: Problem with GDI+ Pin
goyal mohit3-Jun-14 22:27
membergoyal mohit3-Jun-14 22:27 
GeneralRe: Problem with GDI+ Pin
Duncan Edwards Jones3-Jun-14 22:52
professionalDuncan Edwards Jones3-Jun-14 22:52 
GeneralRe: Problem with GDI+ Pin
goyal mohit3-Jun-14 23:41
membergoyal mohit3-Jun-14 23:41 
GeneralRe: Problem with GDI+ Pin
goyal mohit6-Jun-14 1:04
membergoyal mohit6-Jun-14 1:04 
GeneralGET SPL Pin
Efrain Dominguez Goycochea9-Sep-08 10:10
memberEfrain Dominguez Goycochea9-Sep-08 10:10 
GeneralRe: GET SPL Pin
hsirc21-Sep-08 8:01
memberhsirc21-Sep-08 8:01 
QuestionDevMode Pin
JC_Denton10-Jul-08 4:59
memberJC_Denton10-Jul-08 4:59 
AnswerRe: DevMode Pin
Duncan Edwards Jones10-Jul-08 9:36
memberDuncan Edwards Jones10-Jul-08 9:36 
GeneralRe: DevMode Pin
JC_Denton11-Jul-08 6:57
memberJC_Denton11-Jul-08 6:57 
GeneralRe: DevMode Pin
Duncan Edwards Jones11-Jul-08 10:03
memberDuncan Edwards Jones11-Jul-08 10:03 
AnswerRe: DevMode Pin
JC_Denton11-Jul-08 10:23
memberJC_Denton11-Jul-08 10:23 
GeneralRe: DevMode Pin
UmeshDrift8-Oct-08 4:46
memberUmeshDrift8-Oct-08 4:46 
GeneralRe: DevMode Pin
Duncan Edwards Jones6-Jan-09 9:58
memberDuncan Edwards Jones6-Jan-09 9:58 
GeneralRe: DevMode Pin
royzhou198516-Jan-09 5:16
memberroyzhou198516-Jan-09 5:16 
GeneralProblem with HP Laserjet Pin
ademian4421-May-08 12:29
memberademian4421-May-08 12:29 
GeneralRe: Problem with HP Laserjet Pin
Duncan Edwards Jones21-May-08 12:50
memberDuncan Edwards Jones21-May-08 12:50 
GeneralEMF Spoolfile documentation update Pin
Duncan Edwards Jones9-May-08 0:46
memberDuncan Edwards Jones9-May-08 0:46 
GeneralPrint EMF spool File Pin
Efrain Dominguez Goycochea5-May-08 14:58
memberEfrain Dominguez Goycochea5-May-08 14:58 
GeneralRe: Print EMF spool File Pin
Duncan Edwards Jones9-May-08 2:35
memberDuncan Edwards Jones9-May-08 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 23 Apr 2014
Article Copyright 2005 by Duncan Edwards Jones
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid