您的位置:首页 > 其它

SPL - Microsoft® Windows Spool File Format

2016-07-22 16:40 661 查看
SPL - Microsoft® Windows Spool File Format

Introduction

The print job's spooled data is contained in a spool file.

For each print job there are two spool files generated by the Windows® NT/2000 spooler. One file with the .SHD extension for job settings, and one with the .SPL extension for the drawing commands.

:!: Microsoft has released official documentation about this format in connection to the Open Protocol Specifications.

[MS-EMFSPOOL]: Enhanced Metafile Spool Format Specification

[MS-EMF]: Enhanced Metafile Format Specification

:!: Warning

While you might use the information you find here to extract EMF and other data from the Windows spoolfiles, you should remember, that this information is undocumented and might change without prior notice!

You can probably locate the information about the EMF structs in

the spool file format. But note that one major caveat with this

approach is that since the spool file format is MS proprietary,

it might change in future releases without notice. So if your

driver is dependent on a particular spool file format, it could

break on future releases. This is the reason for us recommending

that you not rely on the spool file format.

//Ashwin, Microsoft

This document includes documentation for the EMF-SPL file format.

The Windows® SPL files can include RAW data or EMF data.

RAW-SPL

In the case of RAW data, the content of the file is exactly the same as the data send to the printer.

So this data could be PCL, PostScript, ESC-P, CaPSL, Prescribe or similar.

When is RAW used?

A Print Processor must support the RAW data type or it simply won't work. Beyond that, the data types it supports have little effect.

The decision on whether to spool EMF or RAW is made by GDI based on various factors.

More information on the Spool Files page.

EMF-SPL

EMF stands for Enhanced Metafile. You can find information on standard EMF in the Windows Platform SDK.

Basically the SPL files consist of one or more standard EMF files, surrounded by some extra records. The EMF SPL files contain a special version of EMF, not compatible with standard EMF, although most of the records are the same.

SPL_HEADER

SMR_PAGE_EMF/WMF

SMR_OFFS_FONT

SMR_OFFS_FONT

SMR_EO_PAGE

SMR_PAGE_EMF/WMF

SMR_DEVMODE

SMR_OFFS_FONT

SMR_OFFS_FONT

SMR_OFFS_FONT

SMR_EO_PAGE

Records

Header

The SPL files always start with the SPL_HEADER, this record differs in the way, that the specified recordsize includes both header and data of the SPL header.

Base Record Structure

The records following the SPL_HEADER, always start with (include) the SMR base record. The nSize member specifies the size of the following data, including the size of the remaining header members and the data. nSize = (RECORDSIZE - sizeof(SMR)).

So the SMR_EO_PAGE.nSize member would be = 8, as the complete record is 16 bytes (SMR + 8)

Page Record

Every page contained in the file consists of at least one SMR_PAGE_EMF and one SMR_EO_PAGE record. The SMR_PAGE_EMF contains the EMF data for the page.

Between these 2 records, every page can include some additional records like DEVMODE and font data for the page.

Font Records

You can find more information about the various font data formats used in the SPL files, at the Font Formats page.

EOF Record (End of File)

SPL files can also include an SMR_PAGE_EMF record specifying a length of 0. This record indicates the end of file. The following data should not be considered valid.

Definition

/*****************************************************************************

* Terms of Use

* Copyright © Christoph Lindemann. All rights reserved.

*

* Permission is granted to copy, distribute and/or modify this document under

* the terms of the GNU Free Documentation License, Version 1.2 or any later

* version published by the Free Software Foundation; with no Invariant

* Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the

* license is included in the section entitled "GNU Free Documentation

* License".

*----------------------------------------------------------------------------

* History:

* 24-03-2004 Initial Document

* Christoph Lindemann, christoph@lindemann.nu

*

* 24-03-2004 Release to public

* Christoph Lindemann, christoph@lindemann.nu

*

* 10-06-2004 Added SPL_SMR_PADDING

* Thanks to Fabian Franz

*

* 11-06-2004 CORRECTED FAULTY INFORMATIONS

* Christoph Lindemann, christoph@lindemann.nu

*

* 14-06-2004 Added some text explaining the format.

* Christoph Lindemann, christoph@lindemann.nu

*

* 19-05-2005 Corrected typos in SMREXT definition

* Thanks to Peter Wasser

*

* 02-11-2005 Updated End-Of-Page records 0x0D and 0x0E

* Thanks to Krzys

*

* 15-06-2006 Updated EMF Spool Metafile record types

* Christoph Lindemann, christoph@lindemann.nu

*

* 16-06-2006 Added information about PRESTARTPAGE record

* Christoph Lindemann, christoph@lindemann.nu

*

* 08-04-2008 Updated with new info found in MS Official Released Specs.

* Christoph Lindemann, christoph@lindemann.nu

*

*****************************************************************************/

//Spool Metafile constants

#define SPLMETA_SIGNATURE 0x00010000 //Version 1.0

// Spool Metafile record types

// Please note remarks in the corresponding struct definitions

#if(WINVER >= 0x0400)

/* Windows NT Workstation 4.0 SP2 */

#define SRT_METAFILE 0x00000001 /* 1 Enhanced Meta File (EMF) NT4 */

#define SRT_ENGINE_FONT 0x00000002 /* 2 A TrueType font definition */

#define SRT_DEVMODE 0x00000003 /* 3 DevMode */

#define SRT_TYPE1_FONT 0x00000004 /* 4 A PostScript Type 1 font definition */

#define SRT_PRESTARTPAGE 0x00000005 /* 5 The start page for EPS */

#if (WINVER >= 0x0500)

/* Windows 2000 */

#define SRT_DESIGNVECTOR 0x00000006 /* 6 A font design vector (Multiple Master) */

#define SRT_SUBSET_FONT 0x00000007 /* 7 A subset font definition */

#define SRT_DELTA_FONT 0x00000008 /* 8 A delta font definition */

#define SRT_FORM_METAFILE 0x00000009 /* 9 EMF */

#define SRT_BW_METAFILE 0x0000000A /* 10 Monochrome EMF */

#define SRT_BW_FORM_METAFILE 0x0000000B /* 11 Monochrome EMF */

#define SRT_METAFILE_DATA 0x0000000C /* 12 Enhanced Meta File (EMF) Win2k */

#define SRT_EXT_METAFILE 0x0000000D /* 13 An offset to document content */

#define SRT_EXT_BW_METAFILE 0x0000000E /* 14 An offset to monochrome document content */

#define SRT_EXT_ENGINE_FONT 0x0000000F /* 15 An offset to a TrueType font definition */

#define SRT_EXT_TYPE1_FONT 0x00000010 /* 16 An offset to a PS Type 1 font definition */

#define SRT_EXT_DESIGNVECTOR 0x00000011 /* 17 An offset to a font design vector */

#define SRT_EXT_SUBSET_FONT 0x00000012 /* 18 An offset to a subset font definition */

#define SRT_EXT_DELTA_FONT 0x00000013 /* 19 An offset to a delta font definition */

#define SRT_EXT_PS_JOB_DATA 0x00000014 /* 20 Document-level PostScript data */

#if (WINVER >= 0x0501)

/* Windows XP */

#define SRT_EXT_EMBED_FONT 0x00000015 /* 21 an offset to embedded font identifiers */

#endif

#endif

#endif

/*****************************************************************************

* SPL_HEADER

*----------------------------------------------------------------------------

* SPL file header for EMFSPL files

*****************************************************************************/

typedef struct tagSPLHEADER {

DWORD SIGNATURE;

DWORD nSize; // record size INCLUDING header

DWORD offDocumentName; // offset of Job Title from start

DWORD offPort; // offset of portname from start

BYTE HeaderData[];

} SPL_HEADER, *PSPL_HEADER;

/*****************************************************************************

* SMR - Base record

*----------------------------------------------------------------------------

* Base record type for the Spool Metafile.

*****************************************************************************/

typedef struct tagSMR{

DWORD iType; // Spool metafile record type

DWORD nSize; // length of the following data

// NOT INCLUDING this header

} SMR, *PSMR;

/*****************************************************************************

* SMREXT - Extended record

*----------------------------------------------------------------------------

* Contains neg. distance to start of Data

*****************************************************************************/

typedef struct tagSMREXT{

SMR smr;

DWORD DistanceLow;

DWORD DistanceHigh;

} SMREXT, *PSMREXT;

/*****************************************************************************

* SMRPRESTARTPAGE - PRESTARTPAGE

*----------------------------------------------------------------------------

* Written before pagedata is written to spoolfile

* Used as a temporary "end of file" indicating following data is not

* fully spooled yet

*****************************************************************************/

typedef struct tagSMRPRESTARTPAGE{

SMR smr;

DWORD Unknown1;

DWORD Unknown2; //0xFFFFFFFF

} SMRPRESTARTPAGE, *PSMRPRESTARTPAGE;

/*****************************************************************************

* SMR_PAGE - EMF/Page data

*----------------------------------------------------------------------------

* EMF/Page data

*****************************************************************************/

typedef struct tagSMRPAGE{

SMR smr; // if smr.nSize == 0, this indicates EndOfFile

BYTE EMFData[];

} SMR_PAGE, *PSMR_PAGE;

/*****************************************************************************

* SMR_DEVMODE - DEVMODE data

*----------------------------------------------------------------------------

* DEVMODE data

*****************************************************************************/

typedef struct tagSMRDEVMODE{

SMR smr;

BYTE DEVMODEData[];

} SMR_DEVMODE, *PSMR_DEVMODE;

/*****************************************************************************

* SMR_FONT - FONT data

*****************************************************************************/

typedef struct tagSMRFONT{

SMR smr;

BYTE FONTData[];

} SMR_FONT, *PSMR_FONT;

/*****************************************************************************

* SMR_EXTFONT - Extended Font Data

*----------------------------------------------------------------------------

* Contains neg. distance to start of

* Font Data

* Font data is typically embedded as

* GDICOMMENT in the prev EMF data

*****************************************************************************/

typedef struct tagEXTFONT{

SMREXT smrext;

} SMR_EXTFONT, *PSMR_EXTFONT;

/*****************************************************************************

* SMR_EOPAGE - End of Page

*----------------------------------------------------------------------------

* Contains neg. distance to

* start of page record

*****************************************************************************/

typedef struct tagSMREOPAGE{

SMREXT smrext;

} SMR_EOPAGE, *PSMR_EOPAGE;

More information, examples and tools

Books

Windows Graphics Programming: Win32 GDI and DirectDraw by Feng Yuan.

The world's most complete guide to Windows graphics programming!

Win32 GDI and DirectDraw: Accurate, under the hood, and in depth

Beyond the API: Internals, restrictions, performance, and real-life problems

Complete: Pixel, lines, curves, filled area, bitmap, image processing, fonts, text, metafile, printing

And more
http://www.amazon.com/exec/obidos/ASIN/0130869856
Articles, Code and Tools

EMF Printer Spool File Viewer (Article, Code & Tool)

A viewer application for EMF format spool files.
http://www.codeproject.com/dotnet/EMFSpoolViewer.asp
Spool File View (Tool)

An EMF-Spool file viewer. Shows information about SHD and SPL files. For developers.

splview.zip

O&K Printer Viewer (Tool)

Viewing and saving as image the printed documents.
http://www.prnwatch.com/ok-printer-viewer/
Metafile Extraction (Article)

By Vipin Aravind

Part 1:http://www.microsoft.com/india/msdn/articles/130.aspx

Part 2:http://www.angelfire.com/extreme4/vprint/MetafileExtractionPartII.htm

PrintMirror (Driver)

Open Source printer which creates EMF files
http://sourceforge.net/projects/printmirror/
SPL Viewer (Tool)

Viewer for SPL files. Freeware. English/German
http://www.lvbprint.de/html/splviewer.htm
EMF Printer(Driver)

Virtual printer for creation of EMFs and more! http://emfprinter.sourceforge.net
EMFexplorer (Tool)

A program to manipulate Windows Metafile data. This open-source software displays, scales, rotates documents, and, using GDI+, optionally enhances their quality.
http://frazmitic.free.fr/emfexplorer/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: