Эх сурвалжийг харах

供应商条码打印CS程序修改

Hcsy 7 жил өмнө
parent
commit
24a8ad9f0d

+ 2 - 2
UAS_Web/Browser.cs

@@ -17,8 +17,8 @@ namespace UAS_Web
         public Browser()
         {
             InitializeComponent();
-            Text = "思拓微-供应商条码打印";
-            string path = "http://192.168.253.80:8090/ERP/jsps/vendbarcode/login.jsp";
+            Text = "供应商条码打印";
+            string path = "http://stwecig.vicp.io:8099/ERP/jsps/vendbarcode/login.jsp";
             webBrowser = new ChromiumWebBrowser(path)
             {
                 Dock = DockStyle.Fill

+ 7 - 1
UAS_Web/UAS_Web.csproj

@@ -86,6 +86,10 @@
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
+    <Reference Include="Zen.Barcode.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b5ae55aa76d2d9de, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>tool\Zen.Barcode.Core.dll</HintPath>
+    </Reference>
     <Reference Include="zxing, Version=0.16.2.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>tool\zxing.dll</HintPath>
@@ -130,7 +134,9 @@
       <DesignTime>True</DesignTime>
     </Compile>
     <None Include="app.config" />
-    <None Include="packages.config" />
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>

+ 1 - 0
UAS_Web/packages.config

@@ -5,4 +5,5 @@
   <package id="CefSharp.Common" version="49.0.1" targetFramework="net40" />
   <package id="CefSharp.WinForms" version="49.0.1" targetFramework="net40" />
   <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net40" />
+  <package id="Zen.Barcode.Rendering.Framework" version="3.1.10729.1" targetFramework="net40" />
 </packages>

+ 14 - 14
UAS_Web/tool/PrintHelper.cs

@@ -7,6 +7,7 @@ using System.IO;
 using System.Linq;
 using System.Runtime.InteropServices;
 using System.Text;
+using Zen.Barcode;
 using ZXing;
 using ZXing.QrCode;
 
@@ -145,20 +146,19 @@ namespace UAS_Web.tool
         public static void DrawBarcode(string str, ref Bitmap bitmap, double x, double y, double width, double height)
         {
 
-            QrCodeEncodingOptions options = new QrCodeEncodingOptions();
-            options.Margin = 1;
-            options.Width = (int)width * 4;
-            options.Height = (int)height * 4;
-            options.PureBarcode = true;
-            BarcodeWriter writer = new BarcodeWriter();
-            writer.Format = BarcodeFormat.CODE_128;
-            writer.Options = options;
-            Bitmap imgTemp = writer.Write(str);
-            //BarCode _Code = new BarCode();
-            //_Code.ValueFont = new Font(new FontFamily("黑体"), (float)(6 * 25.4 /18), FontStyle.Regular);
-            //_Code.Height = 6*4;
-            //Bitmap imgTemp = _Code.GetCodeImage("0012490202261807040001",
-            //BarCode.Encode.Code128A);
+            //QrCodeEncodingOptions options = new QrCodeEncodingOptions();
+            //options.Margin = 1;
+            //options.Height = (int)height * 4;
+            //options.PureBarcode = true;
+            //BarcodeWriter writer = new BarcodeWriter();
+            //writer.Format = BarcodeFormat.CODE_128;
+            //writer.Options = options;
+            //Bitmap imgTemp = writer.Write(str);
+
+            Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum;
+
+            Image imgTemp = barcode128.Draw(str, (int)height * 4);
+
             bitmap = (Bitmap)CombinImage(bitmap, imgTemp, (float)x, (float)y);
         }
 

+ 3 - 9
UAS_Web/tool/RequestHandler.cs

@@ -128,7 +128,7 @@ namespace UAS_Web.tool
 
                     foreach (var item in barcode)
                     {
-                        Bitmap bit = new Bitmap(la_width * 6, la_height * 4);
+                        Bitmap bit = new Bitmap(la_width * 10, la_height * 4);
 
 
                         using (Graphics g = Graphics.FromImage(bit))
@@ -167,8 +167,7 @@ namespace UAS_Web.tool
                                         }
                                         if (itemstr.Contains("\\\""))
                                         {
-                                            itemstr = itemstr.Replace("\\\"", "\"");
-                                            Console.WriteLine(itemstr);
+                                            itemstr = itemstr.Replace("\\\"", "\"");                                 
                                         }
                                     }
                                     PrintHelper.Printstring(itemc.Value != null ? itemstr : " ", int.Parse(Sidc["LP_SIZE"].ToString()), g, int.Parse(Sidc["LP_LEFTRATE"].ToString()), int.Parse(Sidc["LP_TOPRATE"].ToString()));
@@ -196,12 +195,7 @@ namespace UAS_Web.tool
         {
             Image i = bitmaps[index];
             Graphics g = e.Graphics;
-            g.CompositingQuality = CompositingQuality.HighQuality;
-            g.SmoothingMode = SmoothingMode.HighQuality;
-            g.InterpolationMode = InterpolationMode.NearestNeighbor;
-            g.PixelOffsetMode = PixelOffsetMode.Half;
-            g.ScaleTransform(0.7F, 1F);
-            g.DrawImage(i, 0, -5, i.Width, i.Height);
+            g.DrawImage(i, 5, 10, i.Width, i.Height);
             if (index < imagecount - 1)
             {
                 e.HasMorePages = true;

BIN
UAS_Web/tool/Zen.Barcode.Core.dll