Graphical Printing on HP printers

IN PROGRESS
Bids
2
Avg Bid (USD)
$298
Project Budget (USD)
$100 - $400

Project Description:
Given an existing C program that reads a file and sends commands to an HP printer, adapt this program to really make it to work.

This program replaces the printing of a plotter to a laser/deskjet HP printers.

The input file has commands like:
1) Pen Up;
2) Pen Down;
3) Go to some coordinates within the range of an A4 format;
3) Print text;
4) Print bmp and jpg images;
5) Few other commands like rotating text, etc.

The printing should (see attached image for a sample. It is a cut of a plotted A4 page using old pens):

1) Print graphical information in A4 format;
2) No printing across many pages; a given file only prints one sheet;

The status of the C program is that:
1) it reads the file and calls a set of small routines that perform specific functions (pen up, text, etc.).
2) existing few comments are in Portuguese but very easily understood by the corresponding functionality.

## Deliverables

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.


2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).

* * *This broadcast message was sent to all bidders on Monday Feb 6, 2006 2:14:10 PM:



I attached a zipped file with the existing code and and the input file that produces the picture shown.

It might be possible that the code does not rotate texts.

Thanks.
* * *This broadcast message was sent to all bidders on Tuesday Feb 7, 2006 3:40:21 PM:



There is a bit of confusion with the C program and I put some extra comments in English.

To draw a line:

Pen Up
Cursor (x1, y1)
PenDown
Cursor (x2, y2)
Pen Up

Thanks.

Bressan


Here is the program

/*
PROGRAMA : printer.c
OBJETIVO : Converter arquivos plotados para imprimir em deskjet.
AUTOR : Celso Bressan
DATA : 18/jan/2006
*/

#include
#include
#include
#include

#define HP890C 0
#define KODAK 1
#define HP900 2

char buf[4000];
FILE *stdinput;
FILE *stdoutput;
int Tipo;
char EB = '^';
char ET = '_'; // String terminator
int EC = 100;

/* Inicia a impressora. */
// Initializes printer
void Inicia(void)
{

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "\033E"); /* Reseta a impressora. */
fprintf(stdoutput, "\033&l26A"); /* Seleciona o formato A4. */
fprintf(stdoutput, "\033&l1O"); /* Orientação Landscape. */
fprintf(stdoutput, "\033*t75R"); /* 75 dots per inch. */
fprintf(stdoutput, "\033*r0A"); /* Inicia o raster grafico. */
fprintf(stdoutput, "\033(6M");
break;
case KODAK:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
case HP900:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
}
}

// Set printer back to normal at the end of the job.
void Termina(void)
{

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "\033*rC"); /* Final do raster grafico. */
fprintf(stdoutput, "\033E"); /* Reseta a impressora. */
break;
case KODAK:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
case HP900:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
}
}

/* Pega um valor numerico. */
// Gets a numeric value
int PegaValor(void)
{
int i;
int c;

for (i = 0; i < 10; i++)
{
c = fgetc(stdinput);
if ((c >= '0' && c <= '9') || c == '-' || c == '+')
buf[i] = c;
else
{
buf[i] = '\0';
ungetc(c, stdinput);
break;
}
}
return(atoi(buf));
}

/* Peg a um valor hexadecimal. */
// Gets a hexadecimal value
char PegaHexa(void)
{
int c;
char TabHex[] = "0123456789ABCDEF";

c = toupper(fgetc(stdinput));
if (c >= '0' && c <= '9')
return(c - '0');
if (c >= 'A' && c <= 'F')
return(c - 'A' + 10);
return(0);
}

/* Configura codigos. */
// Configuration parameters
void Configura(void)
{
int c;

c = fgetc(stdinput);
if (c == 'B')
EB = PegaHexa() * 16 + PegaHexa();
if (c == 'T')
ET = PegaHexa() * 16 + PegaHexa();
if (c == 'C')
{
c = fgetc(stdinput);
if (c == 'M')
EC = 100;
if (c == 'N')
EC = 025;
if (c == '1')
EC = 001;
if (c == '5')
EC = 005;
}
}

/* Pega um string. */
// Gets a string terminated by ET. Rot is the rotation and Tam is the font size
void PegaString(void)
{
int i;
int c;
int v;
int Rot = 1;
int Tam;
char Rotar[20];
char Tamar[20];

Rot = fgetc(stdinput) - '0';
if (Rot == 1)
strcpy(Rotar, "");
else
strcpy(Rotar, "\033&a90P");
i = fgetc(stdinput) - '0';
if ((c = fgetc(stdinput)) == '+')
Tam = (i - 1) * 2 + 1;
else
Tam = (i - 1) * 2;
for (i = 0; i < sizeof(buf); i++)
{
c = fgetc(stdinput);
if (c == ET)
break;
else
buf[i] = c;
}
buf[i] = '\0';

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "\033(s20H\033(s%dV%s%s\033&a0P", Tam * 10, Rotar, buf);
break;
case KODAK:
fprintf(stdoutput, "String=(%d,%s)\n", v, buf);
break;
case HP900:
fprintf(stdoutput, "String=(%d,%s)\n", v, buf);
break;
}
}

/* Pega um par de ordenadas x e y. */
// Gets a pair of x and y
void PegaCoord(int *x, int*y)
{
*x = PegaValor();
fgetc(stdinput);
*y = PegaValor();
}

// Pen Up
void SobePena(void)
{

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "");
break;
case KODAK:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
case HP900:
fprintf(stdoutput, "Pena=%c\n", 'U');
break;
}
}

// Pen Down
void DescePena(void)
{

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "");
bre ak;
case KODAK:
fprintf(stdoutput, "Pena=%c\n", 'D');
break;
case HP900:
fprintf(stdoutput, "Pena=%c\n", 'D');
break;
}
}

// Selects a pen
void PoePena(void)
{
int v;

v = PegaValor();

switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "");
break;
case KODAK:
fprintf(stdoutput, "PoePena=%d\n", v);
break;
case HP900:
fprintf(stdoutput, "PoePena=%d\n", v);
break;
}
}

// Gets the size of page in units
void PegaLimites(int *X0, int *Y0, int *X1, int *Y1)
{
int c;

c = fgetc(stdinput);
*X0 = PegaValor();
c = fgetc(stdinput);
*Y0 = PegaValor();
c = fgetc(stdinput);
*X1 = PegaValor();
c = fgetc(stdinput);
*Y1 = PegaValor();
}

// Sets the cursor position
void Cursor(int x, int y)
{
switch(Tipo)
{
case HP890C:
fprintf(stdoutput, "\033*p%dX\033*p%dY", x, y);
break;
case KODAK:
fprintf(stdoutput, "Cursor=(%d,%d)\n", x, y);
break;
case HP900:
fprintf(stdoutput, "Cursor=(% d,%d)\n", x, y);
break;
}
}

main(int argc, char **argv)
{
int x;
int y;
int c;
int X0, Y0, X1, Y1;
char entra[512];
char saida[512];
char *p;

/* Determina o tipo da impressora. */
if (argc != 4)
{
fprintf (stderr, "Parametro invalido: nome da impressora.\n");
exit(1);
}
Tipo = HP890C;
if (strcmp(argv[1], "HP890C") == 0)
Tipo = HP890C;
if (strcmp(argv[1], "KODAK") == 0)
Tipo = KODAK;
if (strcmp(argv[1], "HP900") == 0)
Tipo = HP900;

/* Abre a entrada e a saida. */
// p = (char *)getenv("HOME");
// sprintf(entra, "%s/data/", p, argv[2]);
// sprintf(saida, "%s/data/", p, argv[3]);
stdinput = fopen(argv[2],"r");
stdoutput = fopen(argv[3],"w");
Inicia();

/* Processa as linhas da entrada. */
X0 = Y0 = X1 = Y1 = 0;
while ((c = fgetc(stdinput)) != -1)
{
switch(c)
{
case ' ':
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '+':
case '-':
ungetc(c, stdinput); // Coordinates
PegaCoord(&x, &y);
Cursor(x, Y1 - y);
break;
case 'V': // Not used
PegaValor();
break;
case 0x0A: // end of line
case 0x0D:
break;
case 'D':
DescePena(); // Pen Down
break;
case 'E':
Configura(); // Configuration
break;
case 'U':
SobePena(); // Pen Up
break;
case 'P':
PoePena(); // Select Pen
break;
case 'H':
Cursor(0, Y1); // Cursor to home
break;
case 'S':
PegaString(); // Gets a string
break;
case 'L':
PegaValor(); // Gets a value
break;
case 'W':
PegaLimites(&X0, &Y0, &X1, &Y1); // Gets the borders of the page
break;
default:
// fprintf(stdoutput, "\nError=%c\n", c);
break;
}
}

Termina();
}



## Platform

It is platform independent as it can be called from any environment to send files to a printer.

Skills required:
Anything Goes, C Programming, Engineering, Linux, Microsoft, MySQL, PHP, Software Architecture, Software Testing, UNIX, Windows Desktop
Additional Files: lRAC_DOC_NameCryptedToProtectYourPrivacy_X200626102731185590822073238161462202361746763370081086758035286512816.jpg
About the employer:
Verified
Public Clarification Board
Bids are hidden by the project creator. Log in as the employer to view bids or to bid on this project.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.