public ActionResult PrintReceipt(int id) { Order order = repository.GetOrderByOrderId(id); PDFFactory fact = new PDFFactory(order, Server); fact.BuildFile(Response); return(File(fact.BuildFile(Response), "application/pdf", "filename.pdf")); }
public static void pdfToPdf(string path, string outpath) { if (string.IsNullOrEmpty(path)) { MessageBox.Show("请选择文件"); } int pageSize = 1; PDFFactory pf = new PDFFactory(); url = path; pdfToPdfPath = pf.Splite(path, pageSize);//---------------------------------------------------------------------------split pdf if (pdfToPdfPath != null) { //拆分文件成功之后接着对pdf转化成图片 for (int i = 0; i < pdfToPdfPath.Count; i++) { string fileName = pdfToPdfPath[i].Substring(0, pdfToPdfPath[i].Length - 4); string imagPath = ConvertPDF2Image(pdfToPdfPath[i], outpath + "/", fileName, 1, 26, System.Drawing.Imaging.ImageFormat.Png, (double)3); //----------------------------pdf to img imagePath.Add(imagPath); } } else { MessageBox.Show("拆分文件失败"); } if (imagePath != null) { Cut(imagePath); //-------------------------------------------------------------cut } if (imagePath != null) { //TurnTheImageToPdf(ref smallImagePath);//---------------------------------------------------------imgtopdf } for (int i = 0; i < pdfToPdfPath.Count; i++) { System.IO.File.Delete(pdfToPdfPath[i]); } for (int i = 0; i < imagePath.Count; i++) { System.IO.File.Delete(imagePath[i]); } for (int i = 0; i < smallImagePath.Count; i++) { System.IO.File.Delete(smallImagePath[i]); } bigPdfToSmallPd pdf = new bigPdfToSmallPd(smallPdfPath); pdf.Show(); }