⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 barcode.txt

📁 VC++开源条形码代码。自动生成条形码和打印功能
💻 TXT
📖 第 1 页 / 共 5 页
字号:
	/* Now that we have the CheckDigitValue, find the corresponding ASCII character
	from the table */
	if (CheckDigitValue<95 && CheckDigitValue>0) 
	{
		C128CheckDigit=CheckDigitValue+32;
	}
	if(CheckDigitValue>94)
	{
		C128CheckDigit=CheckDigitValue+100;
	}
	if (CheckDigitValue==0) 
	{
		C128CheckDigit = (char)194;
	}

	/* Get PrintableString */
	sprintf(PrintableString,"%c%s%c%c",C128Start,DataToPrint,C128CheckDigit,C128Stop);

	iSize = (long)strlen(PrintableString); 
	strncpy(output, PrintableString, strlen(PrintableString)); 
	return 0;
} 


/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts               */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc.                */
/* All rights reserved.                                          */
/* Redistribution and use of this code in source and/or binary   */
/* forms, with or without modification, are permitted provided   */
/* that: (1) all copies of the source code retain the above      */
/* unmodified copyright notice and this entire unmodified        */
/* section of text, (2) You or Your organization owns a valid    */
/* Developer License to this product from IDAutomation.com       */
/* and, (3) when any portion of this code is bundled in any      */
/* form with an application, a valid notice must be provided     */
/* within the user documentation, start-up screen or in the      */
/* help-about section of the application that specifies          */
/* IDAutomation.com as the provider of the Software bundled      */
/* with the application.                                         */
/*****************************************************************/


long  IDAutomation_Codabar(char *DataToEncode, char *output, long iSize)
{
	if(DataToEncode == NULL)
		return 1;
	if(strlen(DataToEncode) == 0)
		return 1;

	char OnlyCorrectData[512];
	//OnlyCorrectData = new char[512];

	char PrintableString[512];
	//PrintableString = new char[512];
	
	int I;
	int PrintBuffer = 0;
	/* Check to make sure data is numeric, $, +, -, /, or :, and remove all others. */
	for(I = 1;I <= (int)strlen(DataToEncode);I++)
	{
		if((int) asc(mid(DataToEncode, I, 1)) > 0 && isdigit(asc(mid(DataToEncode,I,1))))
			PrintBuffer += sprintf(OnlyCorrectData + PrintBuffer, "%s", mid(DataToEncode, I, 1));
		else if(DataToEncode[I - 1] == '$' || DataToEncode[I - 1] == '+' || DataToEncode[I - 1] == '-' || 
			DataToEncode[I - 1] == '/' || DataToEncode[I - 1] == '.' || DataToEncode[I - 1] == ':')
			PrintBuffer += sprintf(OnlyCorrectData + PrintBuffer, "%s", mid(DataToEncode,I,1));
	}

	/* Get Printable String */
	sprintf(PrintableString,"A%sB", OnlyCorrectData);


	iSize = (long)strlen(PrintableString); 
	strncpy(output, PrintableString, strlen(PrintableString)); 

	return 0;
}



long  IDAutomation_Interleaved2of5(char *DataToEncode, char *output, long iSize)
{
	if(DataToEncode == NULL)
		return 1;
	if(strlen(DataToEncode) == 0)
		return 1;
	
	char PrintableString[512];
	//PrintableString = new char[512];

	char DataToPrint[512];
	//DataToPrint = new char[512];

	char OnlyCorrectData[512];
	//OnlyCorrectData = new char[512];

	char TempString[512];
	//TempString = new char[512];

	int I;
	int CurrentNumberPair = 0;
	char StartCode;
	char StopCode;
	int BufferCounter = 0;
	
	/* Check to make sure data is numeric and remove dashes, etc. */
	for(I=1;I <= (int)strlen(DataToEncode);I++)
	{
		/* Add all numbers to OnlyCorrectData string */
		if(isdigit(asc(mid(DataToEncode,I,1))))
		{
			BufferCounter += sprintf(OnlyCorrectData + BufferCounter,"%c", asc(mid(DataToEncode,I,1)));
		}
	}	

	BufferCounter = 0;
	
	/* Check for an even number of digits, add 0 if not even */
	if((int)(strlen(OnlyCorrectData) % 2) == 1)
	{
		sprintf(TempString,"%d%s",0, OnlyCorrectData);
	}
	else
		sprintf(TempString,"%s",OnlyCorrectData);

	/* Assign start and stop codes */
	StartCode = (char)203;
	StopCode = (char)204;
	for(I=1;I <= (int)strlen(TempString);I = I + 2)
	{
		/* Get the value of each number pair */
		CurrentNumberPair = atoi(mid(TempString, I, 2));
		/* == Get the ASCII value of CurrentChar according to chart by adding to the value == */
		if(CurrentNumberPair < 94) 
		{
			BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", (char)(CurrentNumberPair + 33));
		}
		if(CurrentNumberPair > 93)
		{
			BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", (char)(CurrentNumberPair + 103));
		}
	}

	/* Get Printable String */
	sprintf(PrintableString,"%c%s%c", StartCode, DataToPrint, StopCode);


	iSize = (long)strlen(PrintableString); 
	strncpy(output, PrintableString, strlen(PrintableString)); 
	return 0;
} 


/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts               */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc.                */
/* All rights reserved.                                          */
/* Redistribution and use of this code in source and/or binary   */
/* forms, with or without modification, are permitted provided   */
/* that: (1) all copies of the source code retain the above      */
/* unmodified copyright notice and this entire unmodified        */
/* section of text, (2) You or Your organization owns a valid    */
/* Developer License to this product from IDAutomation.com       */
/* and, (3) when any portion of this code is bundled in any      */
/* form with an application, a valid notice must be provided     */
/* within the user documentation, start-up screen or in the      */
/* help-about section of the application that specifies          */
/* IDAutomation.com as the provider of the Software bundled      */
/* with the application.                                         */
/*****************************************************************/


long  IDAutomation_Interleaved2of5Mod10 (char *DataToEncode, char *output, long iSize)
{
	if(DataToEncode == NULL)
		return 1;
	if(strlen(DataToEncode) == 0)
		return 1;
	
	char DataToEncode2[512];
	//DataToEncode2 = new char[512];
	
	char PrintableString[512];
	//PrintableString = new char[512];

	char OnlyCorrectData[512];
	//OnlyCorrectData = new char[512];

	int BufferCounter = 0;
	char StartCode;
	char StopCode;
	int I = 0;
	int CurrentNumberPair = 0;
	
	/* Check to make sure data is numeric and remove dashes, etc. */
	for(I=1;I <= (int)strlen(DataToEncode);I++)
	{
		/* Add all numbers to OnlyCorrectData string */
		if(isdigit(asc(mid(DataToEncode,I,1))))
		{
			BufferCounter += sprintf(OnlyCorrectData + BufferCounter, "%s", mid(DataToEncode, I, 1));
		}
	}


	BufferCounter += sprintf(OnlyCorrectData + BufferCounter, "%c", FindMod10Digit(OnlyCorrectData));

	/* Check for an even number of digits, add 0 if not even */
	if((int)(strlen(OnlyCorrectData) % 2) == 1)
		sprintf(DataToEncode2, "0%s", OnlyCorrectData);
	else	
		sprintf(DataToEncode2, "%s", OnlyCorrectData);
 

	/* Assign start and stop codes */
	StartCode = (char)203;
	StopCode = (char)204;
	BufferCounter = 0;
	BufferCounter += sprintf(PrintableString + BufferCounter, "%c", StartCode);
	for(I = 1;I <= (int)strlen(DataToEncode2);I = I + 2)
	{
		CurrentNumberPair = atoi(mid(DataToEncode2, I, 2));
		if(CurrentNumberPair < 94)
			BufferCounter += sprintf(PrintableString + BufferCounter, "%c", (char)(CurrentNumberPair + 33));
		else
			BufferCounter += sprintf(PrintableString + BufferCounter, "%c", (char)(CurrentNumberPair + 103));
	}

	BufferCounter += sprintf(PrintableString + BufferCounter, "%c", StopCode);


	iSize = (long)strlen(PrintableString); 
	strncpy(output, PrintableString, strlen(PrintableString)); 
	
	return 0;
} 


/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts               */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc.                */
/* All rights reserved.                                          */
/* Redistribution and use of this code in source and/or binary   */
/* forms, with or without modification, are permitted provided   */
/* that: (1) all copies of the source code retain the above      */
/* unmodified copyright notice and this entire unmodified        */
/* section of text, (2) You or Your organization owns a valid    */
/* Developer License to this product from IDAutomation.com       */
/* and, (3) when any portion of this code is bundled in any      */
/* form with an application, a valid notice must be provided     */
/* within the user documentation, start-up screen or in the      */
/* help-about section of the application that specifies          */
/* IDAutomation.com as the provider of the Software bundled      */
/* with the application.                                         */
/*****************************************************************/


long  IDAutomation_Code39 (char *DataToEncode, char *output, long iSize)
{

	if(DataToEncode == NULL)
		return 1;
	if(strlen(DataToEncode) == 0)
		return 1;

	char DataToPrint[512];
	//DataToPrint = new char[512];
	
	char PrintableString[512];
	//PrintableString = new char[512];

	int I;
	int CurrentChar;
	int BufferCounter = 0;
	/* Check for spaces in code */
	for(I=1;I <= (int)strlen(DataToEncode);I++)
	{
		/* Get each character one at a time */
		CurrentChar = asc((mid(DataToEncode,I,1)));
		/* To print the barcode symbol representing a space you will need*/
		/* to type or print "=" (the equal character) instead of a space character.*/
		if(CurrentChar == 32)
		{
			CurrentChar = 61;
		}
		//BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", CurrentChar);
		sprintf(DataToPrint,"%s%c", DataToPrint,CurrentChar);
	}
	
	/* Get Printable String */
	sprintf(PrintableString,"*%s*",strupr(DataToPrint));
	
	iSize = (long)strlen(PrintableString); 
	strncpy(output, PrintableString, strlen(PrintableString)); 

	return 0;
}


/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts               */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc.                */
/* All rights reserved.                                          */
/* Redistribution and use of this code in source and/or binary   */
/* forms, with or without modification, are permitted provided   */
/* that: (1) all copies of the source code retain the above      */
/* unmodified copyright notice and this entire unmodified        */
/* section of text, (2) You or Your organization owns a valid    */
/* Developer License to this product from IDAutomation.com       */
/* and, (3) when any portion of this code is bundled in any      */
/* form with an application, a valid notice must be provided     */
/* within the user documentation, start-up screen or in the      */
/* help-about section of the application that specifies          */
/* IDAutomation.com as the provider of the Software bundled      */
/* with the application.                                         */
/*****************************************************************/


long  IDAutomation_Code39Mod43 (char *DataToEncode, char *output, long iSize)
{

	if(DataToEncode == NULL)
		return 1;
	if(strlen(DataToEncode) == 0)
		return 1;
	
	//char DataToEncode2[512];
	//DataToEncode2 = new char[512];

	char DataToPrint[512];
	//DataToPrint = new char[512];

	char PrintableString[512];
	//PrintableString = new char[512];

	int I;
	int weightedTotal;
	int	CurrentChar;		
	char CurrentValue;
	char CheckDigit;
	char CheckDigitValue;
	int bufferCounter = 0;

	/* Get data from user, this is the DataToEncode */
//	sprintf(DataToEncode2,"%s",DataToEncode);
	weightedTotal = 0;
	/* only pass correct data */
	for(I = 1;I <= (int)strlen(DataToEncode);I++)
	{
		// Get each character one at a time 
		CurrentChar = asc(strupr(mid(DataToEncode,I,1)));
		// Get the value of CurrentChar according to MOD43 
		// 0-9 
		if(CurrentChar < 58 && CurrentChar > 47) 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = CurrentChar - 48;
		}
		else if(CurrentChar < 91 && CurrentChar > 64)   
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = CurrentChar - 55;
		}
		else if(CurrentChar == 32) 		// Space 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", "=");
			CurrentValue = 38;
		}
		else if(CurrentChar == 45) // - 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 36;
		}
		else if(CurrentChar == 46) // . 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 37;
		}
		else if(CurrentChar == 36) // $ 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 39;
		}
		else if(CurrentChar == 47) // / 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 40;
		}
		else if(CurrentChar == 43) // + 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 41;
		}
		else if(CurrentChar == 37) // % 
		{
			bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
			CurrentValue = 42;
		}
		else
		{
			CurrentValue = 0;
		}
		// add the values together 
		weightedTotal = weightedTotal + CurrentValue;
	}
	// divide the WeightedTotal by 43 and get the remainder, this is the CheckDigit	
	CheckDigitValue = (int)((weightedTotal % 43));

	// Assign values to characters 
	if(CheckDigitValue < 10) // 0-9 
	{
		CheckDigit = CheckDigitValue + 48;
	}	
	else if((CheckDigitValue < 36) && (CheckDigitValue > 9)) // A-Z 
	{
		CheckDigit = CheckDigitValue + 55;
	}
	else if(CheckDigitValue == 38) // Space 
	{
		CheckDigit = 61;
	}	
	else if(CheckDigitValue == 36) // - 
	{
		CheckDigit = 45;
	}		
	else if(CheckDigitValue == 37)    // . 
	{
		CheckDigit = 46;
	}	
	else if(CheckDigitValue == 39)	// $ 
	{
		CheckDigit = 36;
	}
	else if(CheckDigitValue == 40)	// / 
	{
		CheckDigit = 47;
	}	
	else if(CheckDigitValue == 41)	// + 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -