VFP 愛用者社區 首頁 VFP 愛用者社區
本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
 
 常見問題常見問題   搜尋搜尋   會員列表會員列表   會員群組會員群組   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入

發票機列印紙本發票c#程式, 有高手能轉成vfp程式嗎?

 
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區
上一篇主題 :: 下一篇主題  
發表人 內容
jimmy987



註冊時間: 2003-06-26
文章: 33


第 1 樓

發表發表於: 星期二 八月 11, 2015 5:50 pm    文章主題: 發票機列印紙本發票c#程式, 有高手能轉成vfp程式嗎? 引言回覆

以下是c#程式碼, 用comport 送至發票機, 程式中一堆byte 不知如何轉換?

// Print's PortName
private string sPortName = "";
private string sPortSet = "";
private byte[] QrCodeData;
private byte[] QrCodeData1;

public byte[] RdData;

private byte[] SendBuff;

// BSC10 Print Command
private const string PrtReset = "\x1b\x40"; // Reset Printer
private const string PaperCutT = "\x1d\x56\x42\x00"; // feed to cut poistion and Paper cut
private const string PaperCutN = "\x1d\x56\x30\x00"; // Paper cut at Now poistion
private const string PosAlign_Left = "\x1b\x61\x30";
private const string PosAlign_Center = "\x1b\x61\x31";
private const string PosAlign_Right = "\x1b\x61\x32";
private const string McWidth80 = "\x1b\x1e\x41\x00"; // 指定 機構寬度為 80 mm
private const string McWidth50 = "\x1b\x1e\x41\x03"; // 指定 機構寬度為 58.7 mm

private void button1_Click(object sender, EventArgs e)
{
string SampleRec;
string QRprintCmd = "\x1d\x28\x6b\x03\x00\x31\x51\x30";

//1.Clear Send Buffer
SendBuff = new byte[0];

//印表機重置 // 1.Reset Print
printToBuffer(PrtReset);

//設置機構寬度
Byte[] McSize = { 0x1b, 0x1e, 0x41, 0x03 }; // 2.指定 機構寬度為 58 mm,可印寬度 50.8mm

ByteToBuffer(McSize);

//設定左邊界位置起印位置為 22mm
Byte[] LeftStar ={
0x1d, 0x50, 0xcb, 0xcb, // 3.指定 X,Y 的Basic pitch(1/203,1/203 DPI)
0x1d, 0x4c, 0x00, 0x00 // 4.左邊界位置起印位置為 0mm

};
ByteToBuffer(LeftStar);

//5.Print Logo (長度:11mm)
string PrtLogo = "\x1d\x38\x4c\x06\x00\x00\x00\x30\x45\x30\x31\x01\x01"; // Printing Logo on Current Poistion
printToBuffer(PrtLogo);

//6. Page Mode Setting
UInt16 PageBaiscLength = 630; //設定 Page Mode 長度 632 Dots / 203DPI = 79 mm
// 無統編,有明細
PageBaiscLength -= 16; //設定 Page Mode 長度 616 Dots / 203DPI = 77 mm

byte[] PageMDLength = BitConverter.GetBytes(PageBaiscLength);

Byte[] PageCmd ={
// 0x1b,0x40,0x1b,0x1d,0x03,0x03,0x00,0x00, // 1.Reset Print
// 0x1b,0x1e,0x41,0x03, // 2.指定 機構寬度為 58.7 mm,可印寬度50.8mm
// 0x1b,0x1e,0x41,0x00, // 2.指定 機構寬度為 82 mm,可印寬度 72mm
// 0x1d,0x50,0xcb,0xcb, // 3.指定 X,Y 的Basic pitch(1/203,1/203 DPI)

0x1b,0x4c, // 4.Page Mode Selected
0x1b,0x54,0x00, // 5.Select character print direction in page mode
0x1b,0x57,0x00,0x00,0x00,0x00,0x90,0x02 // 6-1.Select print region in page mode :編輯寬度為 0x290 (656 dots約為82mm)
};
ByteToBuffer(PageCmd);

ByteToBuffer(PageMDLength); // 6-2.Select print region in page mode : 長度 638 dots)

//3. E-INVOICE Data 第一行
SetABSPos(1, 8, 1); // 指定 (X,Y) 位置於 203 DPI


//非補印發票
SampleRec = ""
+ "\x1c\x53\x03\x03" // 指定中文字距為 30 dots
+ "\x1b\x20\x00" // 指定英數字距為 12 Dots
+ "\x1b\x21\x31\x1c\x21\x0c" // 指定使用 2倍高,2倍寬 的 FONT B字
+ "電子發票證明聯";

printToBuffer(SampleRec);

//4. E-INVOICE Data 第二行
SetABSPos(2, 18, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "\x1c\x53\x00\x05" // 指定中文字距為 29 dots
+ "\x1b\x20\x05" // 指定英數字距為 17 Dots
+ "\x1b\x21\x38\x1c\x21\x0c" // 指定使用 2倍高,2倍寬 的 FONT A字
+ "102年11-12月";
printToBuffer(SampleRec);

//5. E-INVOICE Data 第三行
SetABSPos(2, 28, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "\x1c\x53\x00\x06" // 指定中文字距為 30 dots
+ "\x1b\x20\x06" // 指定英數字距為 18 Dots
+ "\x1c\x21\x0c" // 指定使用 2倍高,2倍寬 的 FONT A字
+ "AB-12345678";
printToBuffer(SampleRec);

//5. E-INVOICE Data 第四行
SetABSPos(2, 34, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "\x1b\x21\x00\x1c\x21\x00" // Select Font A
+ "\x1c\x53\x00\x00\x1b\x20\x00" // Set Kanji Pitch : 24 dots, Ascii 12 Dots
+ "2013-12-12 13:40:56";
printToBuffer(SampleRec);

//6. E-INVOICE Data 第伍行
SetABSPos(2, 39, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "隨機碼 0912 總計 1000";
printToBuffer(SampleRec);

// 有統一編號
//7. E-INVOICE Data 第六行
//SetABSPos(32, 44, 1); // 指定 (X,Y) 位置於 203 DPI
SetABSPos(2, 44, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "賣方 12345678  買方 87654321";
printToBuffer(SampleRec);



//8. E-INVOICE Data 第七行 39條碼
SetABSPos(5, 57, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "\x1d\x48\x00" // Barcode : HRI character print position : 1D 48 n ( 0: none , 1: above , 2:Below , 3: both)
+ "\x1d\x66\x00" // Barcode : HRI character font : 1D 66 n ( 0:12x24 1: 9x17)
+ "\x1d\x68\x30" // Barcode : Set bar code height : 1D 68 n (n dots)
+ "\x1d\x77\x01" // BarCode : Set bar code horizontal size : 1D 77 n (1 ? n ? 6)
+ "\x1d\x6b\x04" // Barcode : 1D 6B m d1...dk NULL : BarCode Data
+ "10212AB123456780921"
+ "\x00";
printToBuffer(SampleRec);

//9. E-INVOICE Data 第八行 QR-Code
//Get QR Code Command
MakeQRData();

//SetABSPos(34, 61, 1); // 指定 (X,Y) 位置於 203 DPI
SetABSPos(4, 60, 1); // 指定 (X,Y) 位置於 203 DPI

ByteToBuffer(QrCodeData); // 列印 QRCode 1
printToBuffer(QRprintCmd);

//SetABSPos(71, 61, 1); // 指定 (X,Y) 位置於 203 DPI
SetABSPos(41, 60, 1); // 指定 (X,Y) 位置於 203 DPI

ByteToBuffer(QrCodeData1); // 列印 QRCode 2
printToBuffer(QRprintCmd);

//10. E-INVOICE Data 第九行 店別
SetABSPos(2, 94, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "店別 1500 機台9999 序號99999";
printToBuffer(SampleRec);

//11. E-INVOICE Data 第十行 退貨說明
SetABSPos(2, 99, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "*退換貨時請出示發票及銷或明細表*";
printToBuffer(SampleRec);

// 有統一編號
//12. E-INVOICE Data 第十一行 發票 90mm 指示線
SetABSPos(2, 103, 1); // 指定 (X,Y) 位置於 203 DPI

SampleRec = ""
+ "\x1b\x4a\x04" //列印位置微調向下 feed 4 Dots
+ "--------------------------------";
printToBuffer(SampleRec);

//13. E-INVOICE Data 起印
SampleRec = ""
+ "\x0c" // Page Mode 起印,
+ "\x1b\x53"; // 回到 Line Mode
printToBuffer(SampleRec);
//------ 以上發票長度固定為 90 mm -------


// 有品項明細
//------ 以下為明細 不限長度 ------
//15.設定左邊界位置在 23mm
ByteToBuffer(LeftStar); //因 從PageMode回到 LineMode時,左邊界會歸零,因此需要再重設一次.

//5.Print Logo (長度:11mm)
printToBuffer(PrtLogo);

//16.加此兩行印出後,剛好 發票90mm 指示線在裁刀位置 (微調 90mm 指示線到裁刀位置 720-640 = 80)
//SampleRec = ""
//+ " 乾電池 1 x 100 100TX"
//+ "\x1b\x4a\x28" // Line feed 40 Dots
//+ " 口罩 1 x 200 200TX"
//+ "\x1b\x4a\x28"; // Line feed 40 Dots
//printToBuffer(SampleRec);

// if (this.Rb01.Checked == true)
// { // 有品項明細,無統一編號時,要切紙

//***** 注意B. 有品項: 無統編時, 裁刀切紙目前位置動作執行 ****
//** 17. E-INVOICE Data 無統一編號時,需要切紙,執行此行切紙指令
// SampleRec = ""
// + "\x1d\x56\x30\x00"; // 裁刀切紙到目前位置指令
// printToBuffer(SampleRec);
//***** 注意B. 有品項: 無統編時, 裁刀切紙目前位置動作執行 ****
// }

//------ 明細繼續列印 ------------
// 18.其他明細資料
SampleRec = ""
+ "\x1b\x4a\x08" // Line feed 8 Dots
+ "\x1b\x21\x21\x1c\x21\x04\x1b\x61\x31" // 指定使用 1倍高,2倍寬 的 FONT B字,置中
+ "購買明細"
+ "\x1b\x4a\x2c" // Line feed 22/4 mm= 44 Dots
+ "\x1b\x21\x00\x1c\x21\x00\x1b\x61\x30" // 指定使用 1倍高,1倍寬 的 FONT A字,靠左
+ "\x1c\x53\x00\x00\x1b\x20\x00" // Set Kanji Pitch : 24 dots, Ascii 12 Dots
+ " 乾電池 1 x 100 100TX"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 口罩 1 x 200 200TX"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 牛奶 1 x 25 25TX"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 3項"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 銷售額(應稅) 300"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 銷售額(免稅) 25"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 稅額 15"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ " 總計 340"
+ "\x1b\x4a\x28" // Line feed 40 Dots
+ "\x1d\x56\x42\x00" // feed to cut poistion and Paper cut
+ "\x10\x14\x01\x00\x02"; // Open Cash Drawer
//Send the sample receipt for printing, goto the function printToBuffer for examples on how the print job is sent.
printToBuffer(SampleRec);

///4.Send All data to Printer
ByteToPrinter(SendBuff);

}
/// 指定在 Page Mode 時,列印的絕對座標位置,單位為 0.87mm 或 0.84mm
private void SetABSPos(int xPoint, int yPoint, int DPIbase)
{
int BaseCnt = 6; // 6/180 Dots == 0.84 mm
if (DPIbase == 0)
BaseCnt++; // 7/203 Dots == 0.87 mm

if ((xPoint * BaseCnt) > 576)
xPoint = 576 / BaseCnt ; // Max 72mm Width

if ( (yPoint * BaseCnt) > 2400)
yPoint = 2400 / BaseCnt; // Max 300mm Length

byte[] xLen = BitConverter.GetBytes(Convert.ToUInt16(xPoint * BaseCnt));
byte[] yLen = BitConverter.GetBytes(Convert.ToUInt16(yPoint * BaseCnt));
byte[] xHead = { 0x1b, 0x24 };
byte[] yHead = { 0x1d, 0x24 };

byte[] ABSPoint = new byte[xHead.Length + xLen.Length + yHead.Length + yLen.Length];

xHead.CopyTo(ABSPoint, 0);
xLen.CopyTo(ABSPoint, xHead.Length);
yHead.CopyTo(ABSPoint, xHead.Length + xLen.Length);
yLen.CopyTo(ABSPoint, xHead.Length + xLen.Length + yHead.Length);

ByteToBuffer(ABSPoint);

}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// PrintToPrinter ( String )
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
/// <summary>
/// This function can be used in your C# application to print to a Star Micronics Thermal Line Mode Printer.
/// If you use this function for your application, please note this is for C# or .NET projects only.
/// The function takes a string with the print data. The print data contains hex commands and the actual text.
///
/// Its important to know that text is basicly hex under the hood. These characters are stored as a string, which is an array of chars.
/// A char is basicly a byte (0x1B) attached to a code page to change it from a byte to a readable char.
///
/// So if you wanted to print "Hello World!" in bold, you would send a string to this function containing:
/// \x1b\x45Hello World\x1b\x46
/// {Bold On Cmd}Hello World{Bold Off Cmd}
///
/// We use a Try, Catch to open the port because it may throw a PortException if the Star Printer is offline or unreachable.
/// If the port was opened successfully, online status can be accessed by using StarIO's built in method GetOnlineStatus() which returns a boolean.
/// The boolean value for status is tested for false (OFFLINE) and if so, it will NOT printing the data, close the port and exit this function.
/// When the printer is online, it will land in the "else" statement which will convert the string to a byte array then print with the StarIO WritePort method.
/// The log is updated with the data sent to the printer and the port is closed.
/// </summary>
/// <param name="prnData">This is the string that holds the print data, the string holds hex values/text data.</param>
private void printToPrinter(string prnData)
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Encoding your string to a byte array and how code pages effect string/char encoding.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// You can use the following command to convert your string to a byte array but notice how we can specify a code page.
// Here is way to set CODE PAGE 852 to match with the printer CODE PAGE 852
//
// Encoding ec = Encoding.GetEncoding(852);
// byte[] command = ec.GetBytes(prnData);
//
// If your software will be using a different code page, this is how you can encode the string correctly to get the desired text to byte encoding.
//
// In this example we will be using UTF8 to encode our string to a byte array but you can use ASCII for legacy systems like this.
//
// byte[] command = ASCIIEncoding.ASCII.GetBytes(print);
//
// Using System.Text.Encoding, we can call Encoding.UTF8.GetBytes(string); to convert our string hex data to a byte array. (Recommended)
byte[] dataByteArray = Encoding.Default.GetBytes(prnData);


// Print Data with Binary type
ByteToPrinter(dataByteArray);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// PrintToPrinter ( Byte )
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
private void ByteToPrinter(byte[] prnData)
{
//Set the status to offline because this is a new attempt to print
onlineStatus = false;

//TRY -> Use the textboxes to check if the port info given will connect to the printer.
try
{
//Very important to only try opening the port in a Try, Catch incase the port is not working
this.sPort = Factory.I.GetPort(this.sPortName, this.sPortSet, 10000);

//GetOnlineStatus() will return a boolean to let us know if the printer was reachable.
this.onlineStatus = sPort.GetOnlineStatus();
}

//CATCH -> If the port information is bad, catch the failure.
catch (PortException)
{
this.RTxtMsg.Text = "印表機:\n" + sPortName + "\n 連結失敗!";
return; //exit this entire function
}
//If it is offline, dont setup receipt or try to write to the port.
if (onlineStatus == false)
{
this.RTxtMsg.Text = "印表機狀態:已離線";
}
//Else statement means it is ONLINE, lets start the printjob
else
{
//Write bytes to printer
uint amountWritten = 0;
uint amountWrittenKeep;
while (prnData.Length > amountWritten)
{
//This while loop is very important because in here is where the bytes are being sent out through StarIO to the printer
amountWrittenKeep = amountWritten;
try
{
amountWritten += sPort.WritePort(prnData, amountWritten, (uint)prnData.Length - amountWritten);
}
catch (PortException)
{
// error happen while sending data
this.RTxtMsg.Text = "印表機:\n" + sPortName + "\n 連結失敗!";
Factory.I.ReleasePort(sPort);
return;
}

if (amountWrittenKeep == amountWritten) // no data is sent
{
Factory.I.ReleasePort(sPort);
this.RTxtMsg.Text = "印表機:\n" + sPortName + "\n 無法傳送資料!";
return; //exit this entire function
}

}

//Release the port
//THIS IS VERY IMPORTANT, IF YOU OPEN THE PORT AND DO NOT CLOSE IT, YOU WILL HAVE PROBLEMS
Factory.I.ReleasePort(sPort);
this.RTxtMsg.Text = "印表機:\n" + sPortName + "\n 資料傳送完成!";

this.PanelReset.Interval = 5000; // after 5 second clean Panel Message
this.PanelReset.Enabled = true;
//////////////////////////
}
}

/// <summary>
/// Save all Print data to buffer First
/// </summary>
/// <param name="prnData"></param>
private void printToBuffer(string prnData)
{
byte[] dataByteArray = Encoding.Default.GetBytes(prnData);

// Print Data with Binary type
ByteToBuffer(dataByteArray);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Byte save to Buffer( Byte )
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
private void ByteToBuffer(byte[] prnData)
{
byte[] SendBuffTmp;
SendBuffTmp = new byte[SendBuff.Length + prnData.Length];
SendBuff.CopyTo(SendBuffTmp, 0);
prnData.CopyTo(SendBuffTmp, SendBuff.Length);


SendBuff = new byte[SendBuffTmp.Length];
SendBuffTmp.CopyTo(SendBuff, 0);
}

private void MakeQRData()
{ ////// 依設定產生 QR Code Cimmand ///////


string QRinform = "\x1d\x28\x6b\x03\x00\x31\x52\x30";

/// 1.How to set QR Code Model 1 or 2
/// GS ( k pL pH cn fn n1 n2
/// (pL + pH × 256) = 4 (pL = 4, pH = 0)
/// cn = 49
/// fn = 65
/// n1 = 49, 50
/// n2 = 0
string model = Char.ConvertFromUtf32(this.CmBQRMode.SelectedIndex + 49);
//Set the Model of QR code to model 2,
string QRmodel = "\x1d\x28\x6b\x04\x00\x31\x41" + model + "\x00";

/// 2.Set QR Cell Size
/// GS ( k pL pH cn fn n
/// (pL + pH × 256) = 3 (pL = 3, pH = 0)
/// cn = 49
/// fn = 67
/// 1 ? n ? 16
string cellSize = Char.ConvertFromUtf32(this.CmBQRSize.SelectedIndex + 1);
//Set the cell size - QR Code Size
string QRcellSize = "\x1d\x28\x6b\x03\x00\x31\x43" + cellSize;

string cellSize1 = Char.ConvertFromUtf32(this.CmBQRSize.SelectedIndex + 1);
//Set the cell size - QR Code Size
string QRcellSize1 = "\x1d\x28\x6b\x03\x00\x31\x43" + cellSize1;


///3. How to set QR Code Correction Level
/// GS ( k pL pH cn fn n
/// (pL + pH × 256) = 3 (pL = 3, pH = 0)
/// cn = 49
/// fn = 69
/// 48 ? n ? 51
string correctionLvl = Char.ConvertFromUtf32(this.CmBQRLevel.SelectedIndex + 4Cool;
//Set the correction level
string QRcorrectionLvl = "\x1d\x28\x6b\x03\x00\x31\x45" + correctionLvl;


///4. Prints the QR Code
/// GS ( k pL pH cn fn m
/// (pL + pH × 256) = 3 (pL = 3, pH = 0)
/// cn = 49
/// fn = 81
/// m = 48
string QRprintCmd = "\x1d\x28\x6b\x03\x00\x31\x51\x30";


///5. Sets the QR code data
/// GS ( k pL pH cn fn m d1…dk
/// 4 ? (pL + pH × 256) ? 7092 (0 ? pL ? 255, 0 ? pH ? 27)
/// cn = 49
/// fn = 80
/// m = 48
/// 0 ? d ? 255
/// k = (pL + pH × 256) – 3
//we must build in how long the data is into the data set command

byte[] dataByteArray; //Left Side QR-Code Data
byte[] dataByteArray1; //Right Side Qr-Code Data

if (this.RadBBig5.Checked == true)
{ // Encoding = BIG5

//Default(Big5) for Chinese Code
dataByteArray = Encoding.Default.GetBytes(this.TxtQRData.Text);
dataByteArray1 = Encoding.Default.GetBytes(this.TxtQRData1.Text);
}
else
{ // Encoding = UTF-8

//UTF-8 for Chinese Code
dataByteArray = Encoding.UTF8.GetBytes(this.TxtQRData.Text);
dataByteArray1 = Encoding.UTF8.GetBytes(this.TxtQRData1.Text);
}

byte byteLenL = Convert.ToByte((dataByteArray.Length + 3) % 256);
byte byteLenH = Convert.ToByte((dataByteArray.Length + 3) / 256);
byte[] byteQRdata ={ 0x1d, 0x28, 0x6b, byteLenL, byteLenH, 0x31, 0x50, 0x30 };

byte byteLenL1 = Convert.ToByte((dataByteArray1.Length + 3) % 256);
byte byteLenH1 = Convert.ToByte((dataByteArray1.Length + 3) / 256);
byte[] byteQRdata1 ={ 0x1d, 0x28, 0x6b, byteLenL1, byteLenH1, 0x31, 0x50, 0x30 };

///產生 QRCode1 列印指令

string Tempstr = QRmodel + QRcorrectionLvl + QRcellSize;
byte[] QRHead = Encoding.Default.GetBytes(Tempstr);
//string Tempprt = QRinform;
//byte[] QRPrt = Encoding.Default.GetBytes(Tempprt);
QrCodeData = new byte[QRHead.Length + byteQRdata.Length + dataByteArray.Length];
QRHead.CopyTo(QrCodeData, 0);
byteQRdata.CopyTo(QrCodeData, QRHead.Length);
dataByteArray.CopyTo(QrCodeData, (QRHead.Length + byteQRdata.Length));
//QRPrt.CopyTo(QrCodeData, (QRHead.Length + byteQRdata.Length + dataByteArray.Length));

///產生 QRCode2 列印指令
Tempstr = QRmodel + QRcorrectionLvl + QRcellSize1;
QRHead = Encoding.Default.GetBytes(Tempstr);
//Tempprt = QRinform;
//QRPrt = Encoding.Default.GetBytes(Tempprt);
QrCodeData1 = new byte[QRHead.Length + byteQRdata1.Length + dataByteArray1.Length ];
QRHead.CopyTo(QrCodeData1, 0);
byteQRdata1.CopyTo(QrCodeData1, QRHead.Length);
dataByteArray1.CopyTo(QrCodeData1, (QRHead.Length + byteQRdata1.Length));
//QRPrt.CopyTo(QrCodeData1, (QRHead.Length + byteQRdata1.Length + dataByteArray1.Length));

}
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
kalok



註冊時間: 2010-08-26
文章: 284


第 2 樓

發表發表於: 星期六 九月 12, 2015 9:25 am    文章主題: 引言回覆

用在甚麼發票機?
回頂端
檢視會員個人資料 發送私人訊息
ezpos



註冊時間: 2011-04-20
文章: 323


第 3 樓

發表發表於: 星期五 六月 05, 2020 12:50 pm    文章主題: 引言回覆

private const string PrtReset = "\x1b\x40"; // Reset Printer

\x1b\x40 代表16進位

利用這網站轉換 成10進位
https://www.convertworld.com/zh-hant/numerals/hexadecimal.html

相當於chr(27) chr(64)

_________________
ezPos收銀機 簡單好用低成本 http://www.ezpos.info
全新美觀的POS收銀機.POS軟硬體耗材.
軟體客制化.網站規劃....能賺錢的都可以找我

http://www.twelife.com 台灣生活網
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
garfield
Site Admin


註冊時間: 2003-01-30
文章: 2157


第 4 樓

發表發表於: 星期一 六月 08, 2020 3:22 pm    文章主題: 引言回覆

在vfp 就可以轉換16進位,
"\x1b\x40" , vfp 用 chr( 0x1b )+chr( 0x40 )

_________________
利用>>搜尋<<的功能會比問的還要快得到答案.
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
CPS0204



註冊時間: 2014-08-24
文章: 441


第 5 樓

發表發表於: 星期一 六月 08, 2020 3:59 pm    文章主題: 引言回覆

想印QRCODE, 可參考此篇
http://vfp.sunyear.com.tw/viewtopic.php?t=7045

自動下載至C:\TEMP 的GIF檔
然後引用到LABEL FORM或REPORT FORM中
印出至雷射印表機貨,條碼機都可以,視為一普通的圖型檔

不需要繞到C++去呼叫
回頂端
檢視會員個人資料 發送私人訊息
ezpos



註冊時間: 2011-04-20
文章: 323


第 6 樓

發表發表於: 星期六 六月 13, 2020 6:20 pm    文章主題: 引言回覆

可以考慮 改成vfp送指令到 發票機 列印
速度會很快

_________________
ezPos收銀機 簡單好用低成本 http://www.ezpos.info
全新美觀的POS收銀機.POS軟硬體耗材.
軟體客制化.網站規劃....能賺錢的都可以找我

http://www.twelife.com 台灣生活網
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
ezpos



註冊時間: 2011-04-20
文章: 323


第 7 樓

發表發表於: 星期六 六月 13, 2020 6:24 pm    文章主題: 引言回覆

裡面有 印發票的指令格式!!!

http://www.goldencode.com.tw/download_s.html?ds=112

_________________
ezPos收銀機 簡單好用低成本 http://www.ezpos.info
全新美觀的POS收銀機.POS軟硬體耗材.
軟體客制化.網站規劃....能賺錢的都可以找我

http://www.twelife.com 台灣生活網
回頂端
檢視會員個人資料 發送私人訊息 參觀發表人的個人網站
新人類



註冊時間: 2005-11-27
文章: 47


第 8 樓

發表發表於: 星期四 一月 13, 2022 8:15 am    文章主題: 引言回覆

ezpos 寫到:
裡面有 印發票的指令格式!!!

http://www.goldencode.com.tw/download_s.html?ds=112

請問有範例可以參考一下?
回頂端
檢視會員個人資料 發送私人訊息
syntech



註冊時間: 2003-05-16
文章: 4211
來自: Taipei,Taiwan

第 9 樓

發表發表於: 星期四 一月 13, 2022 9:31 am    文章主題: 引言回覆

財政部只有規範大致的標準,
自己印就好了

我用的方式是 html的發票格式,以windows printer 方式印,
精度較差,
但作業簡單.

_________________
如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問

請聯絡我們,也許我們幫得上忙
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 AIM Address
syntech



註冊時間: 2003-05-16
文章: 4211
來自: Taipei,Taiwan

第 10 樓

發表發表於: 星期四 一月 13, 2022 9:46 am    文章主題: 引言回覆

站友 spfrk 好像有開發VFP的電子發票列印套件,
花點小錢解決比較快

http://vfp.sunyear.com.tw/viewtopic.php?t=6703&postdays=0&postorder=asc&start=0

http://vfp.sunyear.com.tw/viewtopic.php?t=6844&highlight=

_________________
如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問

請聯絡我們,也許我們幫得上忙
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件 AIM Address
從之前的文章開始顯示:   
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區 所有的時間均為 台北時間 (GMT + 8 小時)
1頁(共1頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票
無法 在這個版面附加檔案
無法 在這個版面下載檔案


Powered by phpBB © 2001, 2005 phpBB Group
正體中文語系由 phpbb-tw 維護製作