C# 将PDF文件转换为word格式

    Pdf(Portable Document Format)意为“便携式文档格式”,是现在最流行的文件格式之一,它有很多优点如:尺寸较小、阅读方便、操作系统平台通用等,非常适合在网络上传播和使用。如今在我们的日常生活中已随处可见PDF文件的身影,例如产品说明、电子图书、网络资料、电子邮件等,PDF文件已被越来越多的人使用。但在使用过程中,我们会发现一个问题,那就是我们很难对PDF文件进行文本和格式编辑。而一直以来,MS Word 都是最流行的文字处理程序。因此有些时候为了方便编辑,我们通常会将PDF文件转换为word格式。

     Spire.PDF软件给开发者提供了一种以C#编程的方式,在.NET平台上将PDF文件转换为word的功能。下面我们就一起来探讨如何使用Spire.PDF来实现这一功能。

     有需要的朋友,可以从E-iceblue官网上下载使用。安装完成后,将bin文件夹下的相关.dll文件添加引用至Visual Studio。

                       

下面是代码片段:

步骤1:创建一个新的PDF文件并加载要转换的PDF文档。

PdfDocument doc = new PdfDocument();

doc.LoadFromFile("图文版丽江旅游攻略大全.pdf");

步骤2:调用SaveToFile方法将PDF文档转换为word格式;

doc.SaveToFile("图文版丽江旅游攻略大全.doc", FileFormat.DOC);

步骤3:保存文档并重新打开;

System.Diagnostics.Process.Start("图文版丽江旅游攻略大全.doc");

 原PDF文件截图:

转换成word文档后的效果截图:

 

全部代码:

using Spire.Pdf;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace convert_pdf_to_word

{

    class Program

    {

        static void Main(string[] args)

        {

            PdfDocument doc = new PdfDocument();

            doc.LoadFromFile("图文版丽江旅游攻略大全.pdf");

            doc.SaveToFile("图文版丽江旅游攻略大全.doc", FileFormat.DOC);

            System.Diagnostics.Process.Start("图文版丽江旅游攻略大全.doc");

        }

    }

}

 

C#代码实现Markdown到Word文档和PDF文件 本文演示了如何通过.NET平台使用C#代码将Markdown文件转换为Word文档和PDF文件,提供步骤及代码示例。 阅读详情

相关推荐

使用C#实现Excel/Word到PDF的转换教程

PDF(便携式文档格式)已经成为数字文档共享的标准。它由Adobe公司开发,其核心特点在于能够保持文件在不同设备和平台上的格式一致性,无论操作系统或字体如何,文档都能以相同的形式展现。在这一章节中,我们将深入了解Microsoft Office套件中最常用的应用——Excel和Word,揭示它们的基础功能以及如何在日常工作中高效使用这些工具。C#是一种由微软开发的面向对象的编程语言,它从C和C++语言中继承了多种特性,是.NET框架的主要编程语言之一。

weixin_42348783的博客 558

C#中将PDF文件转换为word文档

在 C# 中将 PDF 文件转换为 Word 文档可以借助第三方库来实现。一种常用的方法是使用 Aspose.PDF for .NET 和 Aspose.Words for .NET 这两个库来实现 PDF 到 Word 的转换。

m0_61534830的博客 1798

C#中PDF文件转WORD文件

C#中PDF文件转WORD文件

c#利用word控件将pdf转为word

c#利用word控件将pdf转为word文档

m0_37570176的博客 919

C#中PDF文件转WORD文件--完整版)

C#中PDF文件转WORD文件--完整版)

C#中PDF文件转WORD文件--201903

C#中PDF文件转WORD文件--201903

常见文件格式转国产ofd案例,支持pdf、word、txt;

【代码】常见文件格式转ofd案例,支持pdf、word、txt;

weixin_52236586的博客 217

FPGA+滨淞CCD实战:手把手教你搭建S7031/S10142成像电路(附避坑指南)

本文详细介绍了使用FPGA驱动滨淞CCD传感器(S7031/S10142)构建高精度成像系统的完整实战流程。内容涵盖核心器件选型、系统架构规划、电路板(焦面板与接口板)设计要点、FPGA Verilog逻辑实现,并提供了从电源管理、信号调理到数据采集的详细避坑指南,帮助读者从零搭建稳定可靠的成像电路。

weixin_29271263的博客 227

C# PDF操作之-PDF转WORD

特别说明:需引用Aspose.PDF.dll 代码案例: OpenFileDialog openFileDialog1 = new OpenFileDialog(); //显示选择文件对话框 openFileDialog1.Filter = "All files (*.*)|*.*|pdf files (*.pdf)|*.pdf"; o...

Diamond、的博客 2003

VSCode+Typst零配置写作指南:5分钟搞定论文排版环境(含实时预览技巧)

本文介绍如何利用VSCode和Typst快速搭建零配置的论文排版环境,5分钟内实现高效写作与实时预览。Typst作为轻量级排版工具,结合LaTeX的精度与现代化语法,显著提升学术写作效率,特别适合需要频繁调整格式的研究人员。

weixin_30642561的博客 108

Windows下Fortran调用CGNS库的完整踩坑实录:从HDF5、CMake到VS2019+IVF2020的保姆级配置

本文详细记录了在Windows环境下使用Fortran调用CGNS库的完整配置过程,涵盖HDF5安装、CMake配置、VS2019与IVF2020集成等关键步骤。通过实战经验分享,帮助开发者解决常见编译错误和链接问题,实现高效的Fortran与CGNS库集成。

weixin_28707739的博客 349

Excel转换成PDF

public class Office2Pdf { public bool DOCConvertToPDF(string sourcePath, string targetPath) { //StreamReader reader = new StreamReader("temp.doc", Encoding.GetEn...

weixin_30270889的博客 118

3分钟搞懂欧式距离变换(EDT):从暴力算法到Felzenszwalb的演进史

本文系统梳理了欧式距离变换(EDT)从暴力算法到高效线性算法的演进历程。重点解析了光栅扫描算法和Felzenszwalb算法的核心思想与实现,并探讨了其在机器人路径规划中生成欧几里得符号距离场(ESDF)的关键应用,为开发者提供了清晰的算法选型与实战指南。

fern8的博客 976

利用Aspose.PDF for .NET实现pdf转word

早期版本的Microsoft Word以.doc扩展名的二进制格式保存文档。在Office 2007发行版中,Microsoft采用了Office Open XML(OOXML),该格式基于XML和二进制文件的组合,这些文件与ZIP归档文件结合在一起。Word现在使用.docx作为保存文档的默认扩展名。 将PDF转换为Word DOC 用于.NET的Aspose.PDF可让您使用简单的代码行将PDF文件读取并转换为 .NET应用程序中的Word文档。可以使用C#和其他.NET编程语言在.NET WinF

刘联其的个人分享 2349

王爽《汇编语言》课程设计2(不涉及软盘版本)

assume cs:code,ds:data,ss:stack stack segment db 128 dup (0) stack ends data segment db 256 dup (0) data ends code segment start: mov ax,stack mov ss,ax mov sp,128 ...

weixin_41944412的博客 1178

【忍者算法】从生活案例理解滑动窗口最大值:一个超直观的思路讲解|LeetCode 239 滑动窗口最大值

点此看全部题解更多干货,请关注公众号【忍者算法】,回复【刷题清单】获取完整题解目录~

忍者算法的博客 630

把Word转换成pdf程序

using oWord = Microsoft.Office.Interop.Word; private void WordConvert()   {     oWord.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();     Type wordType= word.GetTyp

jiaoyazi2011的专栏 584

利用恒源云云端GPU高效训练YOLOv11模型全流程:从环境搭建到模型部署,让你摆脱硬件束缚

记住,云端GPU的核心优势是“弹性算力+一键环境”,只要把握好这一工具特性,再结合YOLOv11的高性能模型架构,你也能在计算机视觉领域快速落地项目。接下来,我们从工具准备到模型部署,一步步带你实现高效训练,真正帮你解决资源与效率的核心痛点。凭借其在目标检测、实例分割任务上的卓越性能,成为众多开发者的首选。据统计,使用云端GPU训练YOLOv11,在处理百万级数据集时,训练效率较本地普通GPU提升。在安防监控中,YOLOv11可实时检测人员、车辆异常行为,某园区采用该方案后,异常事件识别准确率达。

LXY_LOVE36的博客 213

C#PDF转Word

C#PDF转Word C#实现PDF文件转Word文件,需要引入Spire.Pdf.dll和Spire.License.dll,免费版本的Spire.Pdf只支持转换10也以内的PDF。这里为大家提供了付费版的百度网盘下载链接: https://pan.baidu.com/s/1R3BhMQh8XwAUcE-Pa_OOBA 提取码: 4k1f 下载好后,把Spire.Pdf.dll和Spire.License.dll拷到项目文件夹中(位置任意,找得到就行)。 程序中添加引用 因为代码量较..

u013934107的博客 2146

PCIe协议之 Equalization篇 之 谈谈几种模式

对于两端有能力最高支持 32 GT/s 及以上速率的设备,如果把目标速度设置为 8 GT/s 或 16 GT/s 速率,是不建议采用 Bypass-Equalization-to-Highest-Rate 模式的,即便采用了,也不会针对 8 GT/s 或 16 GT/s 的目标速率进行 EQ。对于支持 32 GT/s 及以上速率的设备,其可能根本无需工作在 8 GT/s 或 16 GT/s 速率,这时再针对 8 GT/s 或 16 GT/s 速率进行 EQ,多少有点浪费。

那么菜的博客 561

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

C# pdf转word

引用组件Spire.Pdf,去官网下载安装,在bin目录里面有需要的dll文件。 static void Main(string[] args) { #region Pdf转word PdfDocument doc = new PdfDocument(); doc.LoadF...

dingtuo8679的博客 424

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

C# convert Word/PPT/Excel to pdf by Microsoft.Office.Interop

/******************************************************************************** ** Company: github ** Auth:    Zhen(Evan)Wang  ** Date:    1/3/2018 1:59:32 PM ** Description:     ** Update Log:

Impossible==I'm possible. 754

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: [转载] 武汉海达数云技术有限公司 - 软件研发员工资详情(武汉,2015年)
下一篇: R中package的安装
weixin_34026276
博客等级 码龄11年 6372粉丝 1261原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值