今天小编给大家分享一下id是html的属性吗的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一
顺晟科技
2022-09-15 20:45:38
220
通过NuGet安装
Pechkin
Pechkin.Synchronized
一下示例是控制台应用程序
static void btnCreate() {
SynchronizedPechkin sc = new SynchronizedPechkin(new GlobalConfig()
.SetMargins(new Margins() { Left = 0, Right = 0, Top = 0, Bottom = 0 }) //设置边距
.SetPaperOrientation(false) //设置纸张方向为纵向
.SetPaperSize(MillimetersToPixelsWidth(100), MillimetersToPixelsWidth(150))); //设置纸张大小50mm * 100mm
ObjectConfig oc = new ObjectConfig();
oc.SetPrintBackground(true)
.SetLoadImages(true);
byte[] buf = sc.Convert(oc, File.ReadAllText(@"C:\Users\Administrator\Documents\WeChat Files\ahjesus\Files\111.html"));
if (buf == null) {
Console.WriteLine("Error converting!");
return;
}
try {
string fn = Path.GetTempFileName() + ".pdf";
FileStream fs = new FileStream(fn, FileMode.Create);
fs.Write(buf, 0, buf.Length);
fs.Close();
Process myProcess = new Process();
myProcess.StartInfo.FileName = fn;
myProcess.Start();
} catch { }
}
static string get_uft8(string unicodeString) {
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] encodedBytes = utf8.GetBytes(unicodeString);
String decodedString = utf8.GetString(encodedBytes);
return decodedString;
}
//length是毫米,1厘米=10毫米
public static int MillimetersToPixelsWidth(float length) {
System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(p.Handle);
IntPtr hdc = g.GetHdc();
int width = GetDeviceCaps(hdc, 4); // HORZRES
int pixels = GetDeviceCaps(hdc, 8); // BITSPIXEL
g.ReleaseHdc(hdc);
return (int)(((float)pixels / (float)width) * length);
}
[DllImport("gdi32.dll")]
private static extern int GetDeviceCaps(IntPtr hdc, int Index);
19
2022-10
19
2022-10
19
2022-10
18
2022-10
16
2022-10
02
2022-10