c#中怎么利用Aspose打印文件

本篇文章給大家分享的是有關(guān)c#中怎么利用Aspose打印文件,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

創(chuàng)新互聯(lián)長期為上千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為虹口企業(yè)提供專業(yè)的網(wǎng)站制作、成都做網(wǎng)站虹口網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。

WrodToPDF

使用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);
            }

            //轉(zhuǎn)換
            Aspose.Words.Document doc = new Aspose.Words.Document(FileFullName);
            doc.Save(SaveFileName, Aspose.Words.SaveFormat.Pdf);

ExcelToPDF

使用Aspose.Cell 8.3(破解版本)

//轉(zhuǎn)換Workbook excel = new Workbook(FileFullName);
                excel.Save(SaveFileName, Aspose.Cells.SaveFormat.Pdf);

PPTToPDF

使用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("無效的版本");
            }//轉(zhuǎn)換Presentation ppt = new Presentation(FileFullName);
            ppt.Save(SaveFileName, Aspose.Slides.Export.SaveFormat.Pdf);

圖片ToPDF

使用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);//轉(zhuǎn)換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);

PDF文件打印c#中怎么利用Aspose打印文件

使用Aspose.Pdf打印文件可以直接設(shè)置打印機(jī)名稱,分?jǐn)?shù),方向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轉(zhuǎn)換pdf后是沒有表格線的,ppt轉(zhuǎn)換pdf后打印會(huì)被截?cái)?,需要自己調(diào)整方向與紙張大小設(shè)置

以上就是c#中怎么利用Aspose打印文件,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁標(biāo)題:c#中怎么利用Aspose打印文件
分享URL:http://muchs.cn/article8/gdipip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、自適應(yīng)網(wǎng)站、微信小程序、虛擬主機(jī)、營銷型網(wǎng)站建設(shè)、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司