Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C++
#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);

	// Open one file for reading
	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);

	// Open another file for writing
	fptr2 = fopen(filename, "w");
	if (fptr2 == NULL)
	{
		printf("Cannot open file %s \n", filename);
		exit(0);
	}
	fwrite(&cGraphicsBegin, sizeof(cGraphicsBegin), 1, fptr2); /* Creating PCl file header */
	{
	// Read contents from file
	c = fgetc(fptr1);
	while (c != EOF)
	{
		fputc(c, fptr2);
		c = fgetc(fptr1);
	}
	int u32ColCounter = 0;
	for (int rowCounter = 0; rowCounter <= (detail.coloumn - 1); rowCounter++)
	{
		/* Adding the data for single row */
		for (int Coloumncounter = 0; Coloumncounter <= detail.count_lines; Coloumncounter++)
		{
			fwrite(&cGraphicEnd, sizeof(cGraphicEnd), 1, fptr2);
		}
	}
	fwrite(&cRowHeader, sizeof(cRowHeader), 1, fptr2);/* adding a header per row */
	fwrite(&cPCLLineData, detail.coloumn, 1, fptr2); /* adding a header per row */
	}
	fwrite(&cGraphicEnd, sizeof(cGraphicEnd), 1, fptr2);/* Creating PCl file footer */
	
	printf("\nContents copied to %s", filename);

	fclose(fptr1);
	fclose(fptr2);
	return 0;
}
Posted
Updated 29-Mar-18 5:56am
v2
Comments
Richard MacCutchan 29-Mar-18 7:32am    
You are using fields in the structure named detail but you never initialise it with any values.
Patrice T 29-Mar-18 18:17pm    
Looks like the code and question are not related?
explain problem of code.

1 solution

Read in the website Printer Command Language functional reference about the commands and send them to the printer. (found with Google in a minute)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900