0

i used the below code to get the number of copies from spl file. For windows 2008 server generated spl file, there is no SpoolerRecordTypes.SRT_DEVMODE.

Private Sub SkipAHeader(ByVal Header As EMFMetaRecordHeader, ByRef SpoolBinaryReader As BinaryReader)

    With Header
        If .nSize <= 0 Then
            .nSize = 8
        End If
        If .iType = SpoolerRecordTypes.SRT_JOB_INFO Then
            Dim JobInfo() As Byte
            JobInfo = SpoolBinaryReader.ReadBytes(.nSize)
            SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize, SeekOrigin.Begin)
        ElseIf .iType = SpoolerRecordTypes.SRT_EOF Then
            '\\ End of file reached..do nothing
        ElseIf .iType = SpoolerRecordTypes.SRT_DEVMODE Then
            '\\ Spool job DEVMODE
            Dim _dmThis As New DevMode(SpoolBinaryReader)
            _Copies = _dmThis.Copies
            SpoolBinaryReader.BaseStream.Seek(.Seek + 8 + .nSize, SeekOrigin.Begin)
        ElseIf .iType = SpoolerRecordTypes.SRT_PAGE Or .iType = SpoolerRecordTypes.SRT_EXT_PAGE Then
            '\\ 
            Call ProcessEMFRecords(Header, SpoolBinaryReader)
        ElseIf .iType = SpoolerRecordTypes.SRT_EOPAGE1 Or .iType = SpoolerRecordTypes.SRT_EOPAGE2 Then
            '\\ int plus long
            Dim EOPAGE() As Byte
            EOPAGE = SpoolBinaryReader.ReadBytes(.nSize)
            If .nSize = &H8 Then
                SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize + 8, SeekOrigin.Begin)
            End If
        ElseIf .iType = SpoolerRecordTypes.SRT_UNKNOWN Then
            SpoolBinaryReader.BaseStream.Seek(.Seek + 4, SeekOrigin.Begin)
        Else
            SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize, SeekOrigin.Begin)
        End If
    End With

End Sub
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • I very much doubt that record is missing. I have production code that reads spool files and has been working for many years, including with Win2008 Server. – Carey Gregory Jan 21 '15 at 16:03
  • can you tell me what record is missing... still i have not got the number of copies. – saravanan Jan 22 '15 at 12:09
  • I doubt any records are missing. Are you aware that in a multi-page document there isn't a `DEVMODE` for every page unless something about that page changes? (eg, orientation) Once you encounter a `DEVMODE` that `DEVMODE` remains in effect for all subsequent pages until you encounter a new one. If your code *does* handle that correctly, then I would guess you have a bug in your file parsing logic. But you didn't include that code so I can only guess. – Carey Gregory Jan 22 '15 at 20:09

0 Answers0