[WinPrnDev] Re: Duplicate Print jobs

  • From: Octavian Rinciog <octavian.rinciog@xxxxxxxxx>
  • To: winprndev@xxxxxxxxxxxxx
  • Date: Thu, 3 Oct 2013 09:51:31 +0300

Sorry, but I think I didn't explain very well my situation.

I'm reading until end of file using ReadPrinter and that gave me only
50 KB and the original .spl is shrinking from 838KB to 788KB.
The next calls of ReadPrinter (of course I read until end of file) for
the same id gave me 788KB.

So, using this code:

void ReadFunction(HANDLE hPrinterJob)
{
    do{
        if (!ReadPrinter(hPrinterJob, lpBytes, BUFSIZE, &dwBytesRead))
        {
            return FALSE;
        }

        else
        {
            if (!WritePrinter(hPrinterNew, lpBytes, dwBytesRead,
&dwBytesWritten))
            {
                return FALSE;
            }
        }
    }while(dwBytesRead!=0);
}

When I first call ReadFunction is reading only 50KB( and the original
file is changing) and after, for the same job, is reading 788KB.

So, my question is why the original .spl file is shrinking from 838 to
788 when I first read from it and after remains the same file?


2013/10/3 Alex Egorov <alex@xxxxxxxxxxxxxx>:
> You should read to filestream until end of file, very rare you will get
> print jobs, which you can read using one ReadPrinter call
>
>
> On Thu, Oct 3, 2013 at 8:11 AM, Alex Egorov <alex@xxxxxxxxxxxxxx> wrote:
>>
>> This is normal, some time you can read several bytes per one read
>> operation :)
>>
>>
>> On Thu, Oct 3, 2013 at 1:41 AM, Octavian Rinciog
>> <octavian.rinciog@xxxxxxxxx> wrote:
>>>
>>> Thank you Alex and Christoph for your advices.
>>>
>>> Right now I realised that the jobs are modified when I read from them.
>>>
>>> For example, I have a .spl file that, when is generated, has 838KB. When
>>> I first read from this job using ReadPrinter the .spl file goes to 788KB and
>>> multiple calls of ReadPrinter copy only 50KB (the buffer is 1024B).
>>>
>>> Do you know why is happening this?
>>> And also could you recommend me a proper way to copy the initial job ?
>>>
>>> În data de 01.10.2013 23:35, "Christoph Lindemann"
>>> <christoph@xxxxxxxxxxxx> a scris:
>>>
>>>> The print processor EMF/SPL functions can only be used in the context of
>>>> a print processor.
>>>> You could of course implement a new print processor, and use that with
>>>> the printer instead of winprint. But some drivers depend on features of
>>>> their own custom print processors.
>>>>
>>>> As Alex described, copy the SPL file and then parse it yourself.
>>>> Then replay the EMF page by page on a device context of the second
>>>> printer.
>>>>
>>>> You need to take into account any devmode changes and the EMF bounds to
>>>> setup the DC for the target printer. Orientation could for example change
>>>> during job.
>>>>
>>>> Also make sure to install the embedded fonts and subset fonts. Do not
>>>> print different jobs concurrently from different threads. Or else your 
>>>> fonts
>>>> can get wrong, when different fonts with same name are loaded at the same
>>>> time. The font table is process wide, and the last loaded font with a
>>>> particular name will be used for all threads. So you need to serialize that
>>>> (alternatively rewrite the fonts and font references in EMF with unique
>>>> names. This is a lot of work)
>>>>
>>>> /christoph
>>>>
>>>> On 01/10/2013, at 21.11, Alex Egorov <alex@xxxxxxxxxxxxxx> wrote:
>>>>
>>>> No, in my software I wait using FindFirstPrinterChangeNotification, set
>>>> print job to pause, make copy of the print job to file, resume print job 
>>>> and
>>>> parse file. I don't know more useful method, no know - file system level
>>>> filter driver, but can't write drivers.
>>>>
>>>>
>>>> On Tue, Oct 1, 2013 at 10:02 PM, Octavian Rinciog
>>>> <octavian.rinciog@xxxxxxxxx> wrote:
>>>>>
>>>>> Thanks, but I was asking if there is some API that does this, because
>>>>> as I understand, the info is already there. (Maybe some calls of
>>>>> PrintDocumentOnPrintProcessor).
>>>>>
>>>>> 2013/10/1 Alex Egorov <alex@xxxxxxxxxxxxxx>:
>>>>> > http://www.undocprint.org/formats/winspool/emf
>>>>> >
>>>>> >
>>>>> > On Tue, Oct 1, 2013 at 8:10 PM, Octavian Rinciog
>>>>> > <octavian.rinciog@xxxxxxxxx> wrote:
>>>>> >>
>>>>> >> Thank you Alex for your advice.
>>>>> >> I'm wondering you  know how to extract the EMF records from the SPL
>>>>> >> file and save them in a file.
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> 2013/10/1 Alex Egorov <alex@xxxxxxxxxxxxxx>:
>>>>> >> > With different drivers this is impossible,
>>>>> >> > If source printer have print jobs with NT EMF format than
>>>>> >> > this is possible but with some advanced work with print job
>>>>> >> > content.
>>>>> >> > You should manually extract EMF content and send it to another
>>>>> >> > printer,
>>>>> >> > but EMF content can be readed without any second printer.
>>>>> >> >
>>>>> >> >
>>>>> >> > On Tue, Oct 1, 2013 at 4:27 PM, Octavian Rinciog
>>>>> >> > <octavian.rinciog@xxxxxxxxx> wrote:
>>>>> >> >>
>>>>> >> >> 2013/10/1 Alex Egorov <alex@xxxxxxxxxxxxxx>:
>>>>> >> >> > How do you get print job handle?
>>>>> >> >>
>>>>> >> >> The source print job handle is obtained using the following
>>>>> >> >> calls:
>>>>> >> >>
>>>>> >> >>     _stprintf_s(jobStr, _T("%s,Job %i"), szPrinterName, iIndex);
>>>>> >> >>     if (!OpenPrinter(jobStr, &hPrinterJob, NULL))
>>>>> >> >>     {
>>>>> >> >>         return FALSE;
>>>>> >> >>     }
>>>>> >> >>
>>>>> >> >>
>>>>> >> >> > How big your bufsize? (Can't be more than 64k)
>>>>> >> >> My bufsize is 1024B. The spl file is copied very good (The two
>>>>> >> >> files
>>>>> >> >> has the same dimension and hash).
>>>>> >> >>
>>>>> >> >> Anyway, I'm not sure that copying the spl file is the proper way
>>>>> >> >> to
>>>>> >> >> implement my task, because in the general case the two printers
>>>>> >> >> have a
>>>>> >> >> different driver.
>>>>> >> >>
>>>>> >> >>
>>>>> >> >> --
>>>>> >> >> Octavian Rinciog
>>>>> >> >>
>>>>> >> >> ---
>>>>> >> >> Questions? First check the UndocPrint pages at
>>>>> >> >> http://www.undocprint.org/winspool
>>>>> >> >>
>>>>> >> >> To unsubscribe, visit the List Server page at
>>>>> >> >> //www.freelists.org/list/winprndev
>>>>> >> >
>>>>> >> >
>>>>> >> >
>>>>> >> >
>>>>> >> > --
>>>>> >> > Alex Egorov
>>>>> >> > http://usefulsoft.com
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> --
>>>>> >> Octavian Rinciog
>>>>> >> ---
>>>>> >> Questions? First check the UndocPrint pages at
>>>>> >> http://www.undocprint.org/winspool
>>>>> >>
>>>>> >> To unsubscribe, visit the List Server page at
>>>>> >> //www.freelists.org/list/winprndev
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > Alex Egorov
>>>>> > http://usefulsoft.com
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Octavian Rinciog
>>>>> ---
>>>>> Questions? First check the UndocPrint pages at
>>>>> http://www.undocprint.org/winspool
>>>>>
>>>>> To unsubscribe, visit the List Server page at
>>>>> //www.freelists.org/list/winprndev
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Alex Egorov
>>>> http://usefulsoft.com
>>
>>
>>
>>
>> --
>> Alex Egorov
>> http://usefulsoft.com
>
>
>
>
> --
> Alex Egorov
> http://usefulsoft.com



-- 
Octavian Rinciog
---
Questions? First check the UndocPrint pages at 
http://www.undocprint.org/winspool

To unsubscribe, visit the List Server page at 
//www.freelists.org/list/winprndev

Other related posts: