 |

|
The length to read the DEVMODE structure is incorrect. DmDeviceName value is 32 bytes (no 64).
Here is the code so that it can be corrected.
Duncan Thanks for your great help, and I hope to contribute with this comment.
Public Sub New(ByVal FileReader As System.IO.BinaryReader)
dmDeviceName = FileReader.ReadChars(32)
dmSpecVersion = FileReader.ReadInt16
.....
End Sub
|
|
|
|

|
Hi,
I tried renaming the SPL file to EMF, but it is not a valid EMF file.
How can the SPL be converted to a valid EMF file?
Thanks,
Adi
|
|
|
|

|
It can't be converted - it either is EMF or it is RAW (a different printer control language such as PostScript, PCL-5, PCL-6 etc.)
|
|
|
|

|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.__Error.EndOfFile()
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt32()
at EMFSpoolfileReader.EMFSpoolfileReader.GetTruePageCount(String SpoolFilename)
at EMFSpoolViewer.SpoolFileForm.MenuItem_File_Open_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
EMFSpoolViewer
Assembly Version: 1.0.1980.19643
Win32 Version: 1.0.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/Administrator/Desktop/EMFSpoolViewer/EMFSpoolViewer.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
EMFSpoolfileReader
Assembly Version: 1.1.1980.19643
Win32 Version: 1.1.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/Administrator/Desktop/EMFSpoolViewer/EMFSpoolfileReader.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|

|
Are you sure the file you are opening is an EMF spool file? Spool files can either be "RAW" (meaning they are in the printer control language of the printer itself such as PCL-5 or PostScript) or "EMF".
|
|
|
|

|
Trying to find a way to view a spooler file but it's not working.
I can select the file, it loads for a bit, then it crashes:
Unhandled exception has occurred in a component in your application.
Unable to read beyond the end of the stream.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.__Error.EndOfFile()
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt32()
at EMFSpoolfileReader.EMFSpoolfileReader.GetTruePageCount(String SpoolFilename)
at EMFSpoolViewer.SpoolFileForm.MenuItem_File_Open_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3625 (GDR.050727-3600)
CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
EMFSpoolViewer
Assembly Version: 1.0.1980.19643
Win32 Version: 1.0.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/tkmaxa6/Desktop/EMFSpoolViewer/EMFSpoolViewer.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3623 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3620 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
EMFSpoolfileReader
Assembly Version: 1.1.1980.19643
Win32 Version: 1.1.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/tkmaxa6/Desktop/EMFSpoolViewer/EMFSpoolfileReader.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|

|
Are you sure the file you are opening is an EMF spool file? Spool files can either be "RAW" (meaning they are in the printer control language of the printer itself such as PCL-5 or PostScript) or "EMF".
|
|
|
|

|
Very nice article, but i have a problem.
How I use the EMFTextRecord to take the text?
If I call it inside the ProcessEMFRecords , it doesn't return any text
|
|
|
|

|
I also have this problem. Does someone already solved this problem ? I tried to read EMFTextRecord from the start but i don't get any string ....
|
|
|
|

|
Fantastic!
Also works perfect in C#
|
|
|
|

|
The part that really interests me is the part where you reprint the spool file using new printersettings. But the print option in the File menu exists in the executable, but not in the source code.
Would you like to reveal this part of the code or is it not a coincedence that this code is not there?
Thanks in advance
|
|
|
|

|
No the code is not deliberately withheld - I just lost the original when I moved my code to new VCS. I'll see if any of the backups include this app code - otherwise you can use Reflector to decompile it?
|
|
|
|

|
Any news on this front? I was hoping to use a working code block to play with some stuff, like monitoring spl and dumping new docs into pdf or post processing.
|
|
|
|

|
Sorry - it is gone
|
|
|
|

|
It looks like there is a code difference in the posted code and the code behind the binaries. When I run the same file (1000+ pages) on EMFSpoolViewer.exe it works fine, when I run the same file on the code from VB.NET projects the SpoolfileReadertest pretty much takes all RAM it can get (10+Gb) and I have to kill the process to get my machine mack.
Do you have any idea why the sample app and source code behave so differently? Thanks!
|
|
|
|

|
I downloaded the 3 application files - the 2 dlls and the 1 exe
I have win xp pro..
Extracted them to folder
Ran the exe.. prog opens.. i load SPL file in it.. and all it says in the title bar is "Loading emf file..." filepath
And .. nothing else..
Then if i click on menu zoom in or soom out = crash
Unhandled exception has occured in a component in your application. If you click continue, the application will ignore this error and attempt to continue
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter nameL index
Details:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at EMFSpoolViewer.SpoolFileForm.MenuItem_View_Zoomout_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3615 (GDR.050727-3600)
CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
EMFSpoolViewer
Assembly Version: 1.0.1980.19643
Win32 Version: 1.0.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/tino/Desktop/EMFSpoolViewer/EMFSpoolViewer.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3614 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
EMFSpoolfileReader
Assembly Version: 1.1.1980.19643
Win32 Version: 1.1.1980.19643
CodeBase: file:///C:/Documents%20and%20Settings/tino/Desktop/EMFSpoolViewer/EMFSpoolfileReader.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|

|
Is it definitely an EMF format spool file?
|
|
|
|

|
I have the same problem.
The file I want to view was sent to me as with an EMF file extention (its a binary file, not text, of about 6MB) .
I've renamed it to .spl but When I open it with your application I see nothing.
If I use an image viewer as IrfanView or similar I can only view the first page.
Please give me any advice so to be able to view it.
thanks.
Loris
|
|
|
|

|
I'll give myself the answer:
I found this other piece of software that does the job perfectly
http://www.lvbprint.de/html/splviewer1.html
bye
|
|
|
|

|
Use this free software to do the job:
http://www.lvbprint.de/html/splviewer1.html
Bye,
Loris
|
|
|
|

|
Hi Duncan,
I'm used to program VBA code behind Excel.
Manipulating text files.
I stumbled accros EMFSpoolViewer.
I'd like to use this to extract tekst from a .spl to .txt.
Something like this
File open(1, c:\archieve\printarchive.txt, openmode.output
'open spl file'(2)
Do while not EOF(2)
'Read spl file'
'spl tekst' = printdata
Writeline(1, printdata)
loop
How do i implement this in the source code?
With kind regards,
Leon
|
|
|
|

|
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:
Ibsexbsf!Sfrvjsfnfout
When debugging the code, I find that this is the text in the EMF record:
,EVH[EVI6IUYMVIQIRXW
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.
Thanks.
Timmy
|
|
|
|

|
I can kind-of explain it but I'm afraid I do not know what to do to resolve it.
Basically when you print to a PDF it doesn't know if the target machine is going to have the font you are printing in or not so in certain circumstances the font is embedded in the spool file. However it only embeds the letters that are used which means that the glyph at a given position in the font table may be different from the character you would expect to be there - hence the offset effect.
I have not found any way of either (a) knowing that this has occured or (b) un-offsetting the font array but if you do please post it here and I will bake it into the above code.
|
|
|
|

|
I found EMFSpoolfileReader.EMFTextRecord.
how can i read Text from Spool Job
Can you please help me its Urgent. I am very Thank full to you
Regards
Muhammad Junaid Khan
|
|
|
|

|
From the start of the EMFTextRecord read the structure thus:
With SpoolBinaryReader
_Top = .ReadInt32
_Left = .ReadInt32
_Bottom = .ReadInt32
_Right = .ReadInt32
_GraphicsMode = .ReadInt32
_scaleX = .ReadSingle
_scaleY = .ReadSingle
_PTx = .ReadInt32
_PTy = .ReadInt32
_nChars = .ReadInt32
_offString = .ReadInt32
_Options = .ReadInt32
_TxtTop = .ReadInt32
_TxtLeft = .ReadInt32
_TxtBottom = .ReadInt32
_TxtRight = .ReadInt32
_offDX = .ReadInt32
If _offString >= 76 Then
.BaseStream.Seek(_offString - 76, SeekOrigin.Current)
Dim chars() As Byte
chars = .ReadBytes(_nChars * 2)
_Text = System.Text.Encoding.Unicode.GetString(chars) End If
End With
|
|
|
|

|
Hi Junaid,
I have the same requirement of reading the text, can u plz share the code if you were able to view the text.
Thanks & Regards
Mujahid
|
|
|
|

|
Hi
i am searching for a code that convert every printoutput in a textfile for
a content filtering.
i think with your code i can do this but i not understand how i can read the text from the spool file?
i see you have a EMFTextRecord , but i don't now how i ca rraed it???
have you a example in vb.net
i am not a very good programmer and my english is not the best sorry.
|
|
|
|

|
Is there anyway to send all pages of an EMF file to the printer with the listed exe? Unless I'm missing something, I'm having to print each page one-by-one, (to PDFCreator print driver) and then I'll have to use Acrobat or something to join all the pages back together
|
|
|
|

|
Indeed - although I think if you drag the EMF spool file onto the PDF printer icon (control panel -> printer) it might print it?
|
|
|
|

|
Thanks for the tip, but no, unfortunately I already tried this (PDFCreator under XP using .SPL files). It first prompts you to change this to be the default printer, then fails with a message "This file cannot be printed. Please try opening the file with the correct application and printing from there".
Also tried sharing the virtual printer and issuing "copy file.spl \\computer\pdfcreator" and that gives a PDF with a blank landscape page. Copying the same file to a physical laser printer works fine.
Any other ideas appreciated! The view works perfectly, except I have to do everything one page at a time...
|
|
|
|

|
Can you please upload it?
Besides, I tried to compile the codes you uploaded successfully after removing the reference SpoolfileReaderBase.dll, but the output appears quite different from the binary you uploaded.
For example, the [FILE] menu, there is no [properties] sub menu items.
Can you please upload the latest codes that can compile the binary you uploaded? thanks
modified on Friday, October 10, 2008 12:55 PM
|
|
|
|

|
Please upload the complete code. I need to get the properties of the spool file. In this cording it only allow to open the spooled file but can not see the properties..
Thank you
|
|
|
|

|
error while open a SPL file.
A generic error occurred in GDI+.
Dim emfPage As New System.Drawing.Imaging.Metafile(FileReader.BaseStream)
the error is in FileReader.BaseStream
some solution?
salu2.
|
|
|
|

|
Can you check that the spool file is actually an EMF spool file?
(It could be RAW e.g. postscript or PCL or similar)
|
|
|
|

|
wend open a file with notepad, and find a EMF word inside,
look this is a file, http://www.paginasprodigy.com/cristianescalante/00009.zip
was printed with Firefox 3
Great Work Duncan!
|
|
|
|

|
How can i get the SPL files?
how can i get the relationship between de jobID and the document name?
thanks.
|
|
|
|

|
you need set you printer with PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS, and the new documents print, are equal a filename to Jobid, XXXX.spl XXXX=JobId.
bad English
Saludos
|
|
|
|

|
How can I access the Devmode struct for each page in this source code?
Thanks a lot.
|
|
|
|

|
You have to get the SRT_DEVMODE record and then read the DEVMODE from that - it is exactly the same as the DEVMODE structure in the windows api.
The SRT_DEVMODE devmode applies to all the pages that come after it until the next SRT_DEVMODE record comes along...so there isn't one devmode per page.
|
|
|
|

|
So in your code, where:
While recNext.iType <> SpoolerRecordTypes.SRT_EOF
If recNext.iType = SpoolerRecordTypes.SRT_PAGE Then
_Pages += 1
End If
'SpoolfileReaderPerformaceCounter.Increment()
Call SkipAHeader(recNext, SpoolBinaryReader)
recNext = NextHeader(SpoolBinaryReader)
End While
I tried that:
While recNext.iType <> SpoolerRecordTypes.SRT_EOF
If recNext.iType = SpoolerRecordTypes.SRT_DEVMODE Then
Dim newdevmode As New DevMode
newdevmode = recNext.iType
_Pages += newdevmode.Copies()
End If
If recNext.iType = SpoolerRecordTypes.SRT_PAGE Then
_Pages += 1
End If
Call SkipAHeader(recNext, SpoolBinaryReader)
recNext = NextHeader(SpoolBinaryReader)
End While
Obviously it didn't worked...
So how can I read the devmode when I find a SRT_DEVMODE???
Thanks a lot for your help.
|
|
|
|

|
Something like:-
Public Class DevMode
#Region "Private properties"
Private dmDeviceName(64) As Char
Private dmSpecVersion As Short
Private dmDriverVersion As Short
Private dmSize As Short
Private dmDriverExtra As Short
Private dmFields As Integer
Private dmOrientation As Short
Private dmPaperSize As Short
Private dmPaperLength As Short
Private dmPaperWidth As Short
Private dmScale As Short
Private dmCopies As Short
Private dmDefaultSource As Short
Private dmPrintQuality As Short
Private dmColor As Short
Private dmDuplex As Short
Private dmYResolution As Short
Private dmTTOption As Short
Private dmCollate As Short
Private dmFormName(32) As Char
Private dmUnusedPadding As Short
Private dmBitsPerPel As Integer
Private dmPelsWidth As Integer
Private dmPelsHeight As Integer
Private dmDisplayFlags As Integer
Private dmDisplayFrequency As Integer
Private dmICMMethod As Integer
Private dmICMIntent As Integer
Private dmMediaType As Integer
Private dmDitherType As Integer
Private dmReserved1 As Integer
Private dmReserved2 As Integer
Private dmPanningWidth As Integer
Private dmPanningHeight As Integer
#End Region
#Region "Public properties"
#Region "Copies"
Public ReadOnly Property Copies() As Short
Get
If dmCopies < 1 Then
dmCopies = 1
End If
Return dmCopies
End Get
End Property
#End Region
#Region "Collate"
Public ReadOnly Property Collate() As Boolean
Get
Return (dmCollate > 0)
End Get
End Property
#End Region
#End Region
#Region "Public constructors"
Public Sub New(ByVal FileReader As System.IO.BinaryReader)
dmDeviceName = FileReader.ReadChars(64)
dmSpecVersion = FileReader.ReadInt16
dmDriverVersion = FileReader.ReadInt16
dmSize = FileReader.ReadInt16
dmDriverExtra = FileReader.ReadInt16
dmFields = FileReader.ReadInt32
dmOrientation = FileReader.ReadInt16
dmPaperSize = FileReader.ReadInt16
dmPaperLength = FileReader.ReadInt16
dmPaperWidth = FileReader.ReadInt16
dmScale = FileReader.ReadInt16
dmCopies = FileReader.ReadInt16
dmDefaultSource = FileReader.ReadInt16
dmPrintQuality = FileReader.ReadInt16
dmColor = FileReader.ReadInt16
dmDuplex = FileReader.ReadInt16
dmYResolution = FileReader.ReadInt16
dmTTOption = FileReader.ReadInt16
dmCollate = FileReader.ReadInt16
dmFormName = FileReader.ReadChars(32) dmUnusedPadding = FileReader.ReadInt16
dmBitsPerPel = FileReader.ReadInt32
dmPelsWidth = FileReader.ReadInt32
dmPelsHeight = FileReader.ReadInt32
dmDisplayFlags = FileReader.ReadInt32
dmDisplayFrequency = FileReader.ReadInt32
dmICMMethod = FileReader.ReadInt32
dmICMIntent = FileReader.ReadInt32
dmMediaType = FileReader.ReadInt32
dmDitherType = FileReader.ReadInt32
dmReserved1 = FileReader.ReadInt32
dmReserved2 = FileReader.ReadInt32
dmPanningWidth = FileReader.ReadInt32
dmPanningHeight = FileReader.ReadInt32
End Sub
#End Region
End Class
wich you would populate thusly:-
ElseIf .iType = SpoolerRecordTypes.SRT_DEVMODE Then
Dim _dmThis As New DevMode(SpoolBinaryReader)
_Copies = _dmThis.Copies
SpoolBinaryReader.BaseStream.Seek(.Seek + 8 + .nSize, SeekOrigin.Begin)
|
|
|
|

|
Thanks a lot Duncan!
|
|
|
|

|
Hi Duncan,
I notice that in the attached code you say that the numbr of copies are in the shadow file.
Dim ShadowFilename As String
If Not Path.GetExtension(SpoolFilename).ToUpper = ".SHD" Then
ShadowFilename = Path.ChangeExtension(SpoolFilename, ".SHD")
Else
ShadowFilename = SpoolFilename
End If
But in the above code you are refering to the spool file.. isnt it.
ElseIf recNext.iType = SpoolerRecordTypes.SRT_DEVMODE Then
Dim _dmThis As New DevMode(SpoolBinaryReader)
_Copies = _dmThis.Copies
SpoolBinaryReader.BaseStream.Seek(recNext.Seek + 8 + recNext.nSize, SeekOrigin.Begin)
So I am confused, cause when i try to look for SpoolerRecordTypes.SRT_DEVMODE in the spool file, it doesnt come.
Please advise.
|
|
|
|

|
What is held in the spool header file is the # of copies as reported to the spool manager (i.e. what is shown in the printer job queue) but it is possible for different pages within a job to have different numbers of copies. In this case a DEVMODE record would exist for each page for which this different number of copies applies...
|
|
|
|

|
DevMode _dmThis = new DevMode(SpoolBinaryReader);
_Copies = _dmThis.Copies;
when i try the above code , I get _Copies a 0
I am confused!
Is it system problem!
I was running the program on Windows XP
and with the spl file create by the virtual printer!
Somebody could help me?
|
|
|
|

|
Problem with HP Laserjet
As one reads the structure. Spl generated by such printers?
tested the printing process RAW and NT EMF and does not work ...
greetings and thank you very much
|
|
|
|
|
|

|
How Can I print the EMF spool file in VB.NET?
I will appreciate your help.
|
|
|
|

|
Apologies for taking so long to get back to you
Anyhow - you need to convert each SRT_PAGE type emf record to a System.Drawing.Imaging.Metafile() and then use Graphics.DrawImage() in the print page event.
To do this, move the file stream to the start of the record and do:-
Dim emfPage As New System.Drawing.Imaging.Metafile(FileReader.BaseStream)
Hope this helps,
Duncan
|
|
|
|
 |