public static void Base64StringToFile(string strbase64)
{
string tempPath = Path.Combine(Application.StartupPath, "Temp");
byte[] blob = Convert.FromBase64String(strbase64.ToString());
if (!Directory.Exists(tempPath))
Directory.CreateDirectory(tempPath);
string fN = Guid.NewGuid().ToString() + ".pdf";
string fileName = Path.Combine(tempPath, fN);
FileStream stream = new FileStream(fileName, FileMode.CreateNew);
stream.Write(blob, 0, blob.Length);
stream.Close();
// 加载PDF文档
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(fileName);
PdfDocument doc2 = new PdfDocument();
foreach (PdfPageBase page in doc.Pages)
{
PdfPageBase newPage = doc2.Pages.Add(PdfPageSize.A2, new Spire.Pdf.Graphics.PdfMargins(200, 100));
page.CreateTemplate().Draw(newPage, new System.Drawing.PointF(0, 0));
}
doc.PrintSettings.PrintController = new StandardPrintController();
doc.Print();
doc.Close();
}
打印的时候报错是因为智障的问题,自定义一个