一款有着强大的文档转换功能的工具,无论何时何地都会是现代办公环境极为需要的。在本篇文章中,将继续介绍关于Word文档的转换功能(Word转XPS/SVG/EMF/EPUB/TIFF)希望方法中的代码能为各位开发者们提供一定的参考价值。
使用方法:下载安装该控件后,在VS控制台应用程序中添加引用Spire.Doc.dll文件(dll文件可在该安装文件夹下Bin中获取)
1. Word转XPS
using Spire.Doc; using System; namespace WordtoXPS_Doc { class Program { static void Main(string[] args) { //初始化String类,元素为需要转换的Word文档 String file = "sample.docx"; //创建一个Document类对象,加载sample文件 Document doc = new Document(file); //将Word文件保存为XPS,并运行生成的文档 doc.SaveToFile("Word2XPS.xps", FileFormat.XPS); System.Diagnostics.Process.Start("Word2XPS.xps"); } } }
2. Word转SVG
using Spire.Doc; namespace WordtoSVG_Doc { class Program { static void Main(string[] args) { //实例化Document类,并加载Word sample Document doc = new Document(); doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.docx"); //保存为svg格式 doc.SaveToFile("result.svg", FileFormat.SVG); } } }
3. Word转Emf
using Spire.Doc; using System.Drawing; using System.Drawing.Imaging; namespace WordtoEmf_Doc { class Program { static void Main(string[] args) { //实例化一个Document类,并加载Word sample Document doc = new Document(); doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.docx", FileFormat.Docx); //调用方法 SaveToImages()将Word第一页转为image并保存为Emf格式 System.Drawing.Image image = doc.SaveToImages(0, Spire.Doc.Documents.ImageType.Metafile); image.Save("WordtoEmf.emf", ImageFormat.Emf); } } }
4. Word转Epub
using Spire.Doc; namespace WordtoEPUB { class Epub { static void Main(string[] args) { //实例化Document类,并加载Word sample Document document = new Document(); document.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.docx"); //保存为Epub格式,并运行生成的文档 document.SaveToFile("ToEpub.epub", FileFormat.EPub); System.Diagnostics.Process.Start("ToEpub.epub"); } } }
5. Word转Word XML
using Spire.Doc; namespace WordtoWordXML_Doc { class Program { static void Main(string[] args) { //创建一个Document类对象并加载Word sample Document doc = new Document(); doc.LoadFromFile("sample.docx"); //调用方法SaveToFile()保存Word为Word Xml doc.SaveToFile("WordToWordXML.xml", FileFormat.WordXml); } } }
6. Word转Tiff
using Spire.Doc; using Spire.Doc.Documents; using System; using System.Drawing; using System.Drawing.Imaging; namespace convert_word_to_tiff { class Program { static void Main(string[] args) { //实例化一个Document类,加载Word sample Document document = new Document(@"C:\Users\Administrator\Desktop\sample.docx"); //调用方法JoinTiffImages()将Word保存为tiff格式,并运行生成的文档 JoinTiffImages(SaveAsImage(document), "result.tiff", EncoderValue.CompressionLZW); System.Diagnostics.Process.Start("result.tiff"); } //自定义方法SaveAsImage()将Word文档保存为图像 private static Image[] SaveAsImage(Document document) { Image[] images = document.SaveToImages(ImageType.Bitmap); return images; } private static ImageCodecInfo GetEncoderInfo(string mimeType) { ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders(); for (int j = 0; j < encoders.Length; j++) { if (encoders[j].MimeType == mimeType) return encoders[j]; } throw new Exception(mimeType + " mime type not found in ImageCodecInfo"); } //自定义方法JoinTiffImages()将Word保存为TIFF图片格式(使用指定编码器和图像编码参数) public static void JoinTiffImages(Image[] images, string outFile, EncoderValue compressEncoder) { System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.SaveFlag; EncoderParameters ep = new EncoderParameters(2); ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame); ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)compressEncoder); Image pages = images[0]; int frame = 0; ImageCodecInfo info = GetEncoderInfo("image/tiff"); foreach (Image img in images) { if (frame == 0) { pages = img; pages.Save(outFile, info, ep); } else { ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage); pages.SaveAdd(img, ep); } if (frame == images.Length - 1) { ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush); pages.SaveAdd(ep); } frame++; } } } }
相关推荐
实现SVG格式图片转换Image、png/jpeg/jpg/pdf,包含svg.dll itextsharp.dll动态链接库文件,C#工程直接引用即可;.net C#源码实例
C#后台Svg转换为png/jpeg等图片代码(C#版)
矢量格式转换程序,基于JAVA实现的SVG转EMF的的示例代码,下载后导入到eclipse即可运行。
This is SVG, a language for describing two-dimensional graphics in XML. The Scalable Vector Graphics (SVG) Copyright 2001, 2002, 2011 World Wide Web Consortium (Massachusetts Institute of ...
svg转png, svg文件渲染, 使用plutosvg库
WMF转PNG EMF转PNG 工具类,使用wmf2svg 来实现wmf转svg 用batik jar实现svg转png 这种转换 不存在图片丢失等问题!
Sharp is a Scalable Vector Graphics (SVG) implementation for Android. It facilitates loading vector graphics as SharpDrawables, and can effectively be used wherever a conventional image would be ...
1.1 文档转换:PDF转图片/Word/SVG/XPS/HTML/XPS/TIFF、图片转PDF 1.2 文档操作:文档创建、合并、拆分、压缩、复制;页面背景、页边距、纸张大小及方向、页面旋转、合并、缩放;表单域;页眉页脚;水印;文本列表...
doc for . net是一个专业的Word .... net平台创建、读取、写入、转换和打印Word文档文件,具有...此外,它还支持使用c#将Word Doc/Docx转换为PDF, Word转换为SVG, Word转换为PostScript, Word转换为PCL(打印机命令语言)。
This is the API specification of the FreeHEP VectorGraphics package for converting emf to svg.
OFD文档转换支持 PDF转换: 通过对OFD的文档进行解析,使用 Apache Pdfbox生成并转换OFD中的元素为PDF内的元素实现PDF的转换。 图片转换: 通过对OFD的文档进行解析,采用java.awt绘制图片,支持转换为PNG、JPEG...
使用场景:很多时候下载的图片都是SVG...2. 可以将 一个目录下的所有SVG图片,同时转换为对应的 任意尺寸的 ico 图片。 3. 输入的 ico图标文件 都存储在 存放SVG图片目录中的 icons子目录中,并会组建相同的文件结构。
1.1 文档格式转换:Excel转PDF/图片/HTML/XPS/SVG/XML/CSV/TIFF/ET/ETT/OFD/、XML转Excel等。 1.2 文档操作:创建、合并、拆分、删除文档;设置文档属性、背景、页边距;插入分页符;文档修订、加密、数字签名;...
Spire.Doc for .NET 是一款专门对 Word 文档...能在 Word 97/2003/2007/2010/2013 和 XML、RTF、TXT、XPS、EPUB、EMF、HTML、ODT 等格式文件之间进行双向转换,还能将 Word 文件高质量地转换为 PDF 和 SVG 文件格式。
spire.doc-5.1.9 Spire.Doc for .NET 是一款...能在 Word 97/2003/2007/2010/2013 和 XML、RTF、TXT、XPS、EPUB、EMF、HTML、ODT 等格式文件之间进行双向转换,还能将 Word 文件高质量地转换为 PDF 和 SVG 文件格式。
svg转css,css转svg,svg与css互相转换并压缩
SVG转Image c#开发。
将图片格式转换成SVG格式图片
基于J2ME/Mobile SVG的移动地理信息服务客户端技术研究,范财友,冯立建,本文在分析当前移动地理信息服务应用与技术的基础上,详细讨论了基于J2ME/Mobile SVG技术实现移动地理信息服务的基本原理,系统框架和
本程序可以将svg文件转换成Visio vsdx格式 平台:Windows 语言:C# 运行环境:.Net Framework 4.7.2 编译环境:Visual Studio 2022 注意需要在电脑上安装Visio,可一键批量转化,软件占用资源少,用起来简单又方便!