当前位置: 首页 > news >正文

高端网站建设公司零零包装材料东莞网站建设

高端网站建设公司零零,包装材料东莞网站建设,设计公司网站域名,wordpress调用文章列表图片为背景前面两篇博客讲解了怎么通过程序控制word的生成#xff0c;包括生成文字、添加表格、添加图片等。这篇博客主要说一下怎么把word图片转换成pdf。 using System; using System.Collections.Generic; using System.Linq; using System.Text;using Microsoft.Office.Core;namespa…前面两篇博客讲解了怎么通过程序控制word的生成包括生成文字、添加表格、添加图片等。这篇博客主要说一下怎么把word图片转换成pdf。 using System; using System.Collections.Generic; using System.Linq; using System.Text;using Microsoft.Office.Core;namespace PDFTest {class PDFUtil{/// summary/// 把Word文件转换成为PDF格式文件/// /summary/// param namesourcePath源文件路径/param/// param nametargetPath目标文件路径/param /// returnstrue转换成功/returnspublic static bool WordToPDF(string sourcePath, string targetPath){bool result false;Microsoft.Office.Interop.Word.WdExportFormat exportFormat Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;Microsoft.Office.Interop.Word.ApplicationClass application null;Microsoft.Office.Interop.Word.Document document null;try{application new Microsoft.Office.Interop.Word.ApplicationClass();application.Visible false;document application.Documents.Open(sourcePath);document.SaveAs2();document.ExportAsFixedFormat(targetPath, exportFormat);result true;}catch (Exception e){Console.WriteLine(e.Message);result false;}finally{if (document ! null){document.Close();document null;}if (application ! null){application.Quit();application null;}GC.Collect();GC.WaitForPendingFinalizers();GC.Collect();GC.WaitForPendingFinalizers();}return result;}/// summary/// 把Microsoft.Office.Interop.Excel文件转换成PDF格式文件/// /summary/// param namesourcePath源文件路径/param/// param nametargetPath目标文件路径/param /// returnstrue转换成功/returns//public static bool ExcelToPDF(string sourcePath, string targetPath)//{// bool result false;// Microsoft.Office.Interop.Excel.XlFixedFormatType targetType Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF;// object missing Type.Missing;// Microsoft.Office.Interop.Excel.ApplicationClass application null;// Microsoft.Office.Interop.Excel.Workbook workBook null;// try// {// application new Microsoft.Office.Interop.Excel.ApplicationClass();// application.Visible false;// workBook application.Workbooks.Open(sourcePath);// workBook.SaveAs();// workBook.ExportAsFixedFormat(targetType, targetPath);// result true;// }// catch (Exception e)// {// Console.WriteLine(e.Message);// result false;// }// finally// {// if (workBook ! null)// {// workBook.Close(true, missing, missing);// workBook null;// }// if (application ! null)// {// application.Quit();// application null;// }// GC.Collect();// GC.WaitForPendingFinalizers();// GC.Collect();// GC.WaitForPendingFinalizers();// }// return result;//}/// summary/// 把PowerPoint文件转换成PDF格式文件/// /summary/// param namesourcePath源文件路径/param/// param nametargetPath目标文件路径/param /// returnstrue转换成功/returns//public static bool PowerPointToPDF(string sourcePath, string targetPath)//{// bool result;// Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType targetFileType Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPDF;// object missing Type.Missing;// Microsoft.Office.Interop.PowerPoint.ApplicationClass application null;// Microsoft.Office.Interop.PowerPoint.Presentation persentation null;// try// {// application new Microsoft.Office.Interop.PowerPoint.ApplicationClass();// //application.Visible MsoTriState.msoFalse;// persentation application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);// persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);// result true;// }// catch (Exception e)// {// Console.WriteLine(e.Message);// result false;// }// finally// {// if (persentation ! null)// {// persentation.Close();// persentation null;// }// if (application ! null)// {// application.Quit();// application null;// }// GC.Collect();// GC.WaitForPendingFinalizers();// GC.Collect();// GC.WaitForPendingFinalizers();// }// return result;//}/// summary/// 把Visio文件转换成PDF格式文件/// /summary/// param namesourcePath源文件路径/param/// param nametargetPath目标文件路径/param /// returnstrue转换成功/returns//public static bool VisioToPDF(string sourcePath, string targetPath)//{// bool result;// Microsoft.Office.Interop.Visio.VisFixedFormatTypes targetType Microsoft.Office.Interop.Visio.VisFixedFormatTypes.visFixedFormatPDF;// object missing Type.Missing;// Microsoft.Office.Interop.Visio.ApplicationClass application null;// Microsoft.Office.Interop.Visio.Document document null;// try// {// application new Microsoft.Office.Interop.Visio.ApplicationClass();// application.Visible false;// document application.Documents.Open(sourcePath);// document.Save();// document.ExportAsFixedFormat(targetType, targetPath, Microsoft.Office.Interop.Visio.VisDocExIntent.visDocExIntentScreen, Microsoft.Office.Interop.Visio.VisPrintOutRange.visPrintAll);// result true;// }// catch (Exception e)// {// Console.WriteLine(e.Message);// result false;// }// finally// {// if (application ! null)// {// application.Quit();// application null;// }// GC.Collect();// GC.WaitForPendingFinalizers();// GC.Collect();// GC.WaitForPendingFinalizers();// }// return result;//}} }程序中包含了各种office格式转换pdf的代码在使用之前一定要加载对应的COM库进来然后才可以使用。转载于:https://www.cnblogs.com/stemon/p/4617561.html
http://www.zqtcl.cn/news/336312/

相关文章:

  • 百度搜不到自己的网站python云服务器网站开发实例
  • 给企业做网站的业务员优书网没了
  • 江门网站建设方案外包洛阳网站设计哪家专业
  • 电暖怎么做网站办公室平面设计图
  • 全屏网站 功能丽水市企业网站建设 微信营销 影视拍摄
  • 天天爱天天做视频网站网站推送
  • 制作企业网站与app有什么不同化工企业网站建设
  • 东莞企业推广网站专门做黄漫的网站
  • 温州网站关键词排名优化win10 电脑做网站服务器
  • 网站设计规划信息技术教案营销模式和营销策略
  • 太仓住房城乡建设网站微信怎么注册
  • 德骏网站建设重庆企业网站如何推广
  • 路由器做内部网站服务器石家庄新闻综合频道在线直播回放
  • 怎么给网站备案亚马逊网站建设与维护方法分析
  • 金华网站建设团队产品网络推广方案范文
  • 拼多多刷单网站开发虚拟机可以做两个网站
  • wordpress安装路径和站点地址的设置信通网站开发中心
  • 柳州公司网站建设网站服务商
  • 智能建站实验报告成功营销网站
  • 基于jsp的网站开发开题报告青海公路工程建设市场信用信息服务网站
  • 做网站页面的软件wordpress如何开启page页面评论
  • 做网站最简单的长春财经学院
  • 导购网站 icp备案要求网站设置ico
  • ftp做网站营销策划方案步骤
  • 网站建设若干意见wordpress查看数据库密码
  • 什么网站可以做宣传西安网站建设聚星互联
  • 产品展示网站源码2015年做哪些网站致富
  • 潍坊网站制作推广怎样做彩票网站
  • 做视频网站被判刑自己怎么做企业网站建设
  • 安庆网站建设兼职哪个公司的卡网络最好