C# 将Word,Execl,PPT,Project, 文件转成PDF, 不依赖Office!!
git 地址
https://gitee.com/bandung/Execl_WordTOPDF.git
包括了各种破解的dll
Word转PDF
挨个引用
Word转PDF
public void WordToPDF(String from,String to)
{
try
{
Document doc = new Document(from);
//保存为PDF文件,此处的SaveFormat支持很多种格式,如图片,epub,rtf 等等 //权限这块的设置成不可复制
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, "password", PdfEncryptionAlgorithm.RC4_128);
// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;
// Extend permissions to allow editing or modifying annotations.
encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;
saveOptions.EncryptionDetails = encryptionDetails;
// Render the document to PDF format with the specified permissions.
doc.Save(to , saveOptions); //doc.Save(to, SaveFormat.Pdf);
Console.WriteLine("成功!");
}
catch (Exception e)
{
Console.WriteLine(e);
Console.WriteLine("强行报错!");
} }
Execl转 PDF
public void ExeclToPDF(String from, String to)
{
try
{ Aspose.Cells.Workbook xls = new Aspose.Cells.Workbook(from);
Aspose.Cells.PdfSaveOptions xlsSaveOption = new Aspose.Cells.PdfSaveOptions();
xlsSaveOption.SecurityOptions = new Aspose.Cells.Rendering.PdfSecurity.PdfSecurityOptions();
#region pdf 加密
//Set the user password
//PDF加密功能
//xlsSaveOption.SecurityOptions.UserPassword = "pdfKey";
//Set the owner password
//xlsSaveOption.SecurityOptions.OwnerPassword = "sxbztxmgzxt";
#endregion
//Disable extracting content permission
xlsSaveOption.SecurityOptions.ExtractContentPermission = false;
//Disable print permission
xlsSaveOption.SecurityOptions.PrintPermission = false;
xlsSaveOption.AllColumnsInOnePagePerSheet = true; //权限这块的设置成不可复制
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, "password", PdfEncryptionAlgorithm.RC4_128);
// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;
// Extend permissions to allow editing or modifying annotations.
encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;
saveOptions.EncryptionDetails = encryptionDetails;
// Render the document to PDF format with the specified permissions.
//doc.Save(to, saveOptions); xls.Save(to, xlsSaveOption); Console.WriteLine("转换成功!");
}
catch (Exception e)
{
Console.WriteLine(e);
Console.WriteLine("强行报错!");
} }
PPT转PDF
public void pptToPdf(string from, string to)
{
Presentation ppt = new Presentation(from);
ppt.Save(to, Aspose.Slides.Export.SaveFormat.Pdf);
Console.WriteLine("成功!");
}
Project 文件转PDF
public void project()
{
var project = new Aspose.Tasks.Project("1.mpp");
// save in different formats
project.Save("file\\output.pdf", Aspose.Tasks.Saving.SaveFileFormat.PDF);
project.Save("file\\output.html", Aspose.Tasks.Saving.SaveFileFormat.HTML);
project.Save("file\\output.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
project.Save("file\\output.png", Aspose.Tasks.Saving.SaveFileFormat.PNG); Console.WriteLine("成功!"); }
把文件压缩成压缩包
using (var archive = new Archive())
{
archive.CreateEntry("1.pptx", @"1.pptx");
archive.Save(@"result.zip");
}
如果想在其他语言调用使用Thrift吧,其实java 来转的话也很快
C# 将Word,Execl,PPT,Project, 文件转成PDF, 不依赖Office!!的更多相关文章
- Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件
Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入.导出数据非常方便.其中Aspose.Cells就是用来操作Excel的,功能有很多.我所用的是最基本的 ...
- html文件转换成pdf和word
1.html文件转成pdf 采用jar包有itext-asian.jar.itextpdf-5.5.5.jar.itext-pdfa-5.5.5.jar.itext-xtra-5.5.5.jar,为了 ...
- doc或docx(word)或image类型文件批量转PDF脚本
doc或docx(word)或image类型文件批量转PDF脚本 1.实际生产环境中遇到文件展示只能适配PDF版本的文件,奈何一万个文件有七千个都是word或者image类型的,由此搞个脚本批量转换下 ...
- java 文件转成pdf文件 预览
一.前端代码 //预览功能 preview: function () { //判断选中状态 var ids =""; var num = 0; $(".checkbox& ...
- java调用com组件将office文件转换成pdf
在非常多企业级应用中都涉及到将office图片转换成pdf进行保存或者公布的场景,由于pdf格式的文档方便进行加密和权限控制(类似于百度文库).总结起来眼下将office文件转换 成pdf的方法主要有 ...
- dvi文件和将dvi文件转换成pdf格式
dvi文件和将dvi文件转换成pdf格式 Latex只能把tex文件编译成dvi文件, 在cmd 中: 使用xdvi查看dvi格式的文件 若用texstudio编辑tex文件,则可直接将已编译成功的. ...
- asp.net将ppt文档转换成pdf
一.添加引用 using Microsoft.Office.Core;using Microsoft.Office.Interop.PowerPoint; 二.转换方法 C# 代码 复制 // ...
- C# Tips: 将 VS2012 / VS2013 的.sln文件、project文件转换成 VS2010格式
原来有一些VS2013的工程文件(.sln..csproj),使用.Net 4.0.现需要将它们转换成VS2010格式. 经实验,办法如下: (1) 在Solution文件(.sln)中: 把文件头部 ...
- C# 将PowerPoint文件转换成PDF文件
PowerPoint的优势在于对演示文档的操作上,而用PPT查看资料,反而会很麻烦.这时候,把PPT转换成PDF格式保存,再浏览,不失为一个好办法.在日常编程中和开发软件时,我们也有这样的需要.本文旨 ...
随机推荐
- vue.js 源代码学习笔记 ----- codegenEvents.js
/* @flow */ const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/ const simplePathRE = / ...
- ios系统降级
1.使用PP助手/iTunes备份好文件资料,以防重要信息丢失: 2.设备连接iTunes,按住Shift键之后点击“恢复iPhone”,选择已下载好的iOS8.4.1固件,等待更新完成即可. 注意要 ...
- Windows环境下 PyQt5 如何安装MySql驱动 (PyQt5连接MYSQL时显示Driver not loaded解决方案)
参考文章: https://blog.csdn.net/qq_38198744/article/details/80261695 前文说过如何在Ubuntu环境下 为PyQt5 安装MySql驱动, ...
- Buildroot 打包文件系统流程跟踪
/********************************************************************************* * Buildroot 打包文件系 ...
- python爬虫错误
错误描述 TypeError: list indices must be integers or slices, not str 错误缘由 取标签属性的时候, find_all()函数与find()函 ...
- [linux]df 磁盘100%Used告警,du显示目录状态良好的故障排查
1.回顾: 某在线主机深夜连续接到告警系统的disk Used 超限告警. 登陆主机查看却遇到了困惑:在检查磁盘使用量 df –h 出来的磁盘使用量确实和告警信息一样,已经被100%占用,但是查看目录 ...
- Python面试题(十六)
1.取出两个升序数组中的最小的一半的元素组成一个新的升序数组. map(lambda x, y: x if x < y else y, a, b) 答案 2.用至少2种不同的方式删除一个list ...
- Hibernate环境搭建+struts整合
说明:本文档,是和struts2+hibernate的整合示例. lib下还有struts2的jar包,本示例没有显示.struts2的搭建参考struts2的环境搭建 一下载hibernate的ja ...
- python random模块(随机数)详解
使用前要先导入random模块 import random random.randomrandom.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0 random ...
- 推荐一个React 入门的教程
推荐一个React 入门的教程 react 入门实例教程 Github地址:https://github.com/ruanyf/react-demos