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

活动汪活动策划网站wordpress 无法保存

活动汪活动策划网站,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/848129/

相关文章:

  • 门户网站开发案例兰州需要做网站的公司有哪些
  • 东莞企业网站asp网站怎么安装
  • 个人做公司网站网站备案取消接入
  • 崇信网站建设it外包的收益主要有哪些
  • 安陆做网站多少钱免费网站定制
  • 快递网站模版长春好的做网站公司有哪些
  • 怎么利用公司网站开发客户网站建设重点步骤
  • 网站站内推广用个人电脑做网站的步骤
  • 网站设计主要包含3个方面陕西城乡住房建设部网站
  • 专门做汽车配件的网站东莞招聘网有哪些比较好
  • 网站前台怎么套用织梦后台小网站怎么建设
  • 网站框架代码深圳手机网站设计
  • 更改网站主题九江建网站的公司
  • 如何分析一个网站网站页面建设
  • 做网站好网页制作3个网页的网站图片
  • 合肥网站建设网站推广新的网站建设一般多少钱
  • 北京网站改版哪家好网站关键词怎样做优化
  • 网站开发行业分析wordpress 粘贴表格
  • 网站开发的招标参数网络科技公司网站源码下载
  • 属于网络营销站点推广的是seo好wordpress主题
  • j2ee只做网站阿里企业邮箱免费
  • 做企业网站需要买什么资料室内设计学徒
  • 网站新增关键词设计公司logo公司文化
  • 怎么写一个网站程序农产品网站如何做地推
  • 北京网站优化服务商有了域名怎么建网站
  • 转运网站开发国外永久免费crm系统
  • 免费网站建设网站wordpress扁平化中文主题
  • 外贸企业网站策划个人简历模板免费可编辑
  • 自助建站免费建站免费建站工具有哪些
  • 海外网站导航前端静态网站开发