How to find out end of file in raster format

solomon slmnraj.raj25 at gmail.com
Mon Dec 7 08:51:28 PST 2009


> On Dec 5, 2009, at 11:32 PM, solomon wrote:
> >=20
> > Hi,
> >=20
> > I am developing a filter for my custom printer, i am developing based =
> on rastertoepson filter. i want to know one thing how to find out when =
> do we reach end of file of the printable file.
>
> When cupsRasterReadHeader/cupsRasterReadHeader2 returns 0, you have =
> reached the end-of-file (or detected a bad raster header/corrupt file).  =
> There will never be any additional data at the end of a properly formed =
> CUPS raster stream.
>
> > suppose in main before entering in to print data we are checking for =
> end of file using while statement as shown below:
> > while (cupsRasterReadHeader2(ras, &header))
> >=20
> > this loop will execute up to end of file. but if my page is longer =
> than end of file(printable file) i want to quit the printing may be as =
> shown below
>
> You need to call cupsRasterReadPixels for each line in the page.  Thus =
> the normal print loop looks something like this:
>
>     /* Read all pages in the raster stream */
>     while (cupsRasterReadHeader(ras, &header))
>     {
>       /* Allocate memory for reading pixels */
>       unsigned char *buffer =3D malloc(header.cupsBytesPerLine);
>
>       /* Read all of the lines on the current page */
>       for (y =3D 0; y < header.cupsHeight; y ++)
>         if (cupsRasterReadPixels(ras, buffer, header.cupsBytesPerLine))
>         {
>           /* Output the line to the printer */
>           ...
>         }
>         else
>           break;
>     }
>
>
> ___________________________________________________
> Michael Sweet, Senior Printing System Engineer
>
>    /* Read all pages in the raster stream */
>     while (cupsRasterReadHeader(ras, &header))
>     {
>       /* Allocate memory for reading pixels */
>       unsigned char *buffer =3D malloc(header.cupsBytesPerLine);
>
>       /* Read all of the lines on the current page */
>       for (y =3D 0; y < header.cupsHeight; y ++)
>         if (cupsRasterReadPixels(ras, buffer, header.cupsBytesPerLine))
>         {
>           /* Output the line to the printer */
>           ...
>         }
>         else
>           break;
>     }
>

thanks for quick reply.

   I tried with the above code but it's not breaking when the end of file is reached, it's printing white space as much as cups.Height which i mentioned in ppd file.

    Is there any option to give dynamic page size depends on printable area, my printer should print receipts, which are variable in size in length if i mentioned some height in ppd file. page height will be ppd page height so i couldn't able to quit the print until page height is finished.


what should i do?


>





More information about the cups mailing list