Using CrystalDecisions.CrystalReports.Engine;
Using System.Configuration;
Using Crystaldecisions.shared;
Using Gma.QrCodeNet.Encoding.Windows.Render;
Using Gma.QrCodeNet.Encoding;
Using System.IO;
Using Gma.QrCodeNet.Encoding.Windows.Forms;
private void Button1_Click (object sender, EventArgs e)
{
Dt. Columns.Add ("A", typeof (Byte[]));
Dt. Columns.Add ("B");
Dt. Columns.Add ("C");
for (int i = 0; i < 2; i++)
{
DataRow dr = dt. NewRow ();
dr["B"] = "1111111111DAFADFASDFADSFSDFASDFASDFASDFJLASDFJASL;DFJASDFL;ASJDFASL; JDFLSADFJSDFAASDFASDF--13123123-ADSFASDFKLJSDF^SADFSDASADFASDFASDFSADF "+ i.tostring ();
dr["C"] = "2222222222" + i.tostring ();
dr["A"] = Genqrcode (dr["B"]. ToString ());
Dt. Rows.Add (DR);
}
Document = new Reportdocument ();
String reportpath = @ "D:\Prj\DEV\Barcode\20160610\PrintReportSvr\PrintReportSvr\OrderReport\ReportTest.rpt";
Document. Load (Reportpath);
Document. Setdatasource (DT);
Document. Exporttodisk (Exportformattype.portabledocformat, Pdfpath + @ "\" + pdfname);
}
Public byte[] Genqrcode (string barcodecontent)
{
byte[] bt = NULL;
Color _lightmodule = Color.white;//color.fromargb (220, 100, 203, 50);
Color _darkmodule = Color.black;//color.fromargb (170, 20, 250, 220);
Qrcodeimgcontrol Qrcontrol = new Qrcodeimgcontrol ();
Qrcontrol.errorcorrectlevel = ERRORCORRECTIONLEVEL.M;
Qrcontrol.quietzonemodule = Gma.QrCodeNet.Encoding.Windows.Render.QuietZoneModules.Two;
Qrcontrol.darkbrush = new SolidBrush (_darkmodule);
Qrcontrol.lightbrush = new SolidBrush (_lightmodule);
Qrcontrol.width = 100;
Qrcontrol.height = 100;
Qrcontrol.text = barcodecontent;
QrControl.Image.Save (@ "C:\1111\1123.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
BT = Getbyteimage (Qrcontrol.image);
Return BT;
}
Public byte[] Getbyteimage (Image img)
{
byte[] bt = NULL;
if (!img. Equals (NULL))
{
using (MemoryStream mostream = new MemoryStream ())
{
Bitmap bmp = New Bitmap (IMG);
Bmp. Save (Mostream, System.Drawing.Imaging.ImageFormat.Jpeg);//Storing the image in the specified format in the cache memory stream
BT = new Byte[mostream. Length];
Mostream. Position = 0;//Set the initial position of the left
Mostream. Read (BT, 0, Convert.ToInt32 (BT). Length));
}
}
Return BT;
}
C # generate a QR code PDF file