Hi,
I am a student working on a project based on PCL5 .
Trying to develop a program which will be providing text file printing functionality to the printer.
The driver will be implemented on C language.
I have implemented the PCL5 commands in the C program given below.
Now i want to change the font of the text file but it is not getting changed.
Please help and suggest to find out where i committed the mistake and let me know if the commands are correct for text file printing or not ?
Here is the code for text to PCL on which i am working on
What I have tried:
#include <stdio.h>
#include<conio.h>
typedef struct text {
unsigned char data[100],
coloumn,
count_lines;
}TEXT;
struct text detail;
int main()
{
int Esc = 27;
int totalchar;
unsigned char cPCLLineData[128];
char cGraphicsBegin[] = { 27, '&', 'a', '0', 'C', 27, '&', 'a', '0', 'R', 27, '(', '1', '2', 'U' };
char cRowHeader[] = { 27, '*', 's', '3', 'I' };
char cGraphicEnd[] = { 27, '*', 'c', '8', '3', 'E' };
FILE *fptr1, *fptr2;
char filename[100], c;
printf("Enter the filename to open for reading \n");
scanf("%s", filename);
fptr1 = fopen(filename, "r");
if (fptr1 == NULL)
{
printf("Cannot open file %s \n", filename);
exit(0);
}
printf("Enter the filename to open for writing \n");
scanf("%s", filename);
fptr2 = fopen(filename, "w");
if (fptr2 == NULL)
{
printf("Cannot open file %s \n", filename);
exit(0);
}
fwrite(&cGraphicsBegin, sizeof(cGraphicsBegin), 1, fptr2);
{
c = fgetc(fptr1);
while (c != EOF)
{
fputc(c, fptr2);
c = fgetc(fptr1);
}
int u32ColCounter = 0;
for (int rowCounter = 0; rowCounter <= (detail.coloumn - 1); rowCounter++)
{
for (int Coloumncounter = 0; Coloumncounter <= detail.count_lines; Coloumncounter++)
{
fwrite(&cGraphicEnd, sizeof(cGraphicEnd), 1, fptr2);
}
}
fwrite(&cRowHeader, sizeof(cRowHeader), 1, fptr2);
fwrite(&cPCLLineData, detail.coloumn, 1, fptr2);
}
fwrite(&cGraphicEnd, sizeof(cGraphicEnd), 1, fptr2);
printf("\nContents copied to %s", filename);
fclose(fptr1);
fclose(fptr2);
return 0;
}