您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇文章给大家分享的是有关c#中怎么利用Aspose打印文件,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
使用Aspose.Word 11.9,需要配合licence文件破解
//去水印 string licenseFile = "Aspose.Words.lic"; if (File.Exists(licenseFile)) { Aspose.Words.License license = new Aspose.Words.License(); license.SetLicense(licenseFile); } //转换 Aspose.Words.Document doc = new Aspose.Words.Document(FileFullName); doc.Save(SaveFileName, Aspose.Words.SaveFormat.Pdf);
使用Aspose.Cell 8.3(破解版本)
//转换Workbook excel = new Workbook(FileFullName); excel.Save(SaveFileName, Aspose.Cells.SaveFormat.Pdf);
使用Aspose.Slides 16.9(需要配合代码破解)
//去水印string[] stModule = new string[8] {"\u0002\u2006\u2006\u2003","\u0003\u2006\u2006\u2003","\u0005\u2005\u2000\u2003","\u0003\u2000","\u000F","\u0002\u2000","\u0003","\u0002"}; Assembly assembly = Assembly.GetAssembly(typeof(Aspose.Slides.License)); Type typeLic = null, typeIsTrial = null, typeHelper = null;foreach (Type type in assembly.GetTypes()) {if ((typeLic == null) && (type.Name == stModule[0])) { typeLic = type; }else if ((typeIsTrial == null) && (type.Name == stModule[1])) { typeIsTrial = type; }else if ((typeHelper == null) && (type.Name == stModule[2])) { typeHelper = type; } }if (typeLic == null || typeIsTrial == null || typeHelper == null) {throw new Exception(); }object lic = Activator.CreateInstance(typeLic);int findCount = 0;foreach (FieldInfo field in typeLic.GetFields(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) {if (field.FieldType == typeLic && field.Name == stModule[3]) { field.SetValue(null, lic);++findCount; }else if (field.FieldType == typeof(DateTime) && field.Name == stModule[4]) { field.SetValue(lic, DateTime.MaxValue);++findCount; }else if (field.FieldType == typeIsTrial && field.Name == stModule[5]) { field.SetValue(lic, 1);++findCount; } }foreach (FieldInfo field in typeHelper.GetFields(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) {if (field.FieldType == typeof(bool) && field.Name == stModule[6]) { field.SetValue(null, false);++findCount; }if (field.FieldType == typeof(int) && field.Name == stModule[7]) { field.SetValue(null, 128);++findCount; } }if (findCount < 5) {throw new NotSupportedException("无效的版本"); }//转换Presentation ppt = new Presentation(FileFullName); ppt.Save(SaveFileName, Aspose.Slides.Export.SaveFormat.Pdf);
使用Aspose.Pdf 9.4(需要配合代码破解)
//去水印private const string Key = "PExpY2Vuc2U+DQogIDxEYXRhPg0KICAgIDxMaWNlbnNlZFRvPlNoYW5naGFpIEh2ZHVuIEluZm9ybWF0aW9uIFRlY2hub2xvZ3kgQ28uLCBMdGQ8L0xpY2Vuc2VkVG8+DQogICAgPEVtYWlsVG8+MzE3NzAxODA5QHFxLmNvbTwvRW1haWxUbz4NCiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+DQogICAgPExpY2Vuc2VOb3RlPkxpbWl0ZWQgdG8gMSBkZXZlbG9wZXIsIHVubGltaXRlZCBwaHlzaWNhbCBsb2NhdGlvbnM8L0xpY2Vuc2VOb3RlPg0KICAgIDxPcmRlcklEPjE2MDkwMjAwNDQwMDwvT3JkZXJJRD4NCiAgICA8VXNlcklEPjI2NjE2NjwvVXNlcklEPg0KICAgIDxPRU0+VGhpcyBpcyBhIHJlZGlzdHJpYnV0YWJsZSBsaWNlbnNlPC9PRU0+DQogICAgPFByb2R1Y3RzPg0KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0Pg0KICAgIDwvUHJvZHVjdHM+DQogICAgPEVkaXRpb25UeXBlPkVudGVycHJpc2U8L0VkaXRpb25UeXBlPg0KICAgIDxTZXJpYWxOdW1iZXI+NzM4MDNhYmUtYzZkMi00MTY3LTg2MTgtN2I0NDViNDRmOGY0PC9TZXJpYWxOdW1iZXI+DQogICAgPFN1YnNjcmlwdGlvbkV4cGlyeT4yMDE3MDkwNzwvU3Vic2NyaXB0aW9uRXhwaXJ5Pg0KICAgIDxMaWNlbnNlVmVyc2lvbj4zLjA8L0xpY2Vuc2VWZXJzaW9uPg0KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHA6Ly93d3cuYXNwb3NlLmNvbS9jb3Jwb3JhdGUvcHVyY2hhc2UvbGljZW5zZS1pbnN0cnVjdGlvbnMuYXNweDwvTGljZW5zZUluc3RydWN0aW9ucz4NCiAgPC9EYXRhPg0KICA8U2lnbmF0dXJlPm5LNVVUR3dZMWVJSEtIV0d2NW5sQUxXUy81bDEzWkFuamlvdnlBcGNqQis0ZjNGbm5yOWhjeUlzazlvVzQySWp0ZFYra2JHZlNSMUV4OUozSGlkaThCeE43aHFiR1BERXNaWGo2RlYxaGl1N2MxWmUyNEp3VGc2UnpsNUNJRHY1YVhxbDQyczBkSGw4eXpreDRBM2RTTU5KTzRiQ094a2V2OFBiOWxSaUc3ST08L1NpZ25hdHVyZT4NCjwvTGljZW5zZT4=";private static Stream LStream = (Stream)new MemoryStream(Convert.FromBase64String(Key));var l = new Aspose.Pdf.License(); l.SetLicense(LStream);//转换Document doc = new Document(); Page page = doc.Pages.Add(); Aspose.Pdf.Image image = new Aspose.Pdf.Image(); image.File = FileFullName; page.Paragraphs.Add(image); PrintFileName = OfficeUtil.CombinePDFPath(ConvertPDFName); doc.Save(PrintFileName);
使用Aspose.Pdf打印文件可以直接设置打印机名称,分数,方向d等
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings(); ps.PrinterName = PrinterName; ps.Copies = Copies; ps.Duplex = Direction; PdfViewer viewer = new PdfViewer(); viewer.BindPdf(PrintFileName); viewer.PrintDocumentWithSettings(ps); viewer.Close();
注:对于excel转换pdf后是没有表格线的,ppt转换pdf后打印会被截断,需要自己调整方向与纸张大小设置
以上就是c#中怎么利用Aspose打印文件,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。