| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3330 人关注过本帖
标题:excel、word转换成pdf
只看楼主 加入收藏
hhy420459674
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:203
专家分:179
注 册:2010-4-9
结帖率:54.9%
收藏
已结贴  问题点数:10 回复次数:6 
excel、word转换成pdf
如何将excel、word转换成pdf呢
分不够,有了多给点哈
谢谢了!我急用啊~~~
搜索更多相关主题的帖子: excel word 
2011-01-21 16:29
baoyuwang198
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:55
专家分:180
注 册:2011-1-22
收藏
得分:10 
可以从网上下载ICSharpCode.SharpZipLib.dll、itextsharp.dll这两个组件
然后 编程实现转换
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using iTextSharp.text;
using iTextSharp.text.pdf;
using

namespace CreatePDFDocument
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //该变量保存PDF的文档名
        public static string filePath = "";

        //创建PDF文档
        private void button1_Click(object sender, EventArgs e)
        {
            //给出文件保存信息,确定保存位置
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "PDF文件(*.PDF)|*.PDF";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                filePath = saveFileDialog.FileName;
                //开始创建PDF文档
                Document document = new Document();
                PdfWriter.getInstance(document, new FileStream(filePath, FileMode.Create));
                document.Open();
                BaseFont baseFont = BaseFont.createFont(@"c:\windows\fonts\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font = new iTextSharp.text.Font(baseFont, 20);
                document.Add(new Paragraph(richTextBox1.Text, font));
                document.Close();
                MessageBox.Show("祝贺你,文档创建成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }
    }
}

曾经我们两个人28楼上仰望星星
如今我一个人28层楼下仰望过去
2011-01-22 19:50
baoyuwang198
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:55
专家分:180
注 册:2011-1-22
收藏
得分:0 
顺便T一下 网上也有 转换工具,可以去百度下

曾经我们两个人28楼上仰望星星
如今我一个人28层楼下仰望过去
2011-01-22 19:51
hhy420459674
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:203
专家分:179
注 册:2010-4-9
收藏
得分:0 
回复 2楼 baoyuwang198
ICSharpCode.SharpZipLib.dll、itextsharp.dll
请问这两个组建在哪里下载啊?我在网上没有找到,下载下来的都是有问题的,感觉的是文件损坏的那种!
帮个忙 谢谢!
2011-01-23 12:38
isolated
Rank: 1
来 自:北京
等 级:新手上路
帖 子:23
专家分:0
注 册:2009-3-23
收藏
得分:0 
很好的知识,学习下

http://www.
2011-02-14 22:03
jyhfr67ihfr
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-2-24
收藏
得分:0 


这几款pdf转换软件好用

免费下载pdf转换成word转换器 http://www. 

pdf转换成word转换器 http://dl.

pdf转换成word http://www.

另外这款word转换成pdf格式转换器也很好用万能word转pdf转换器 http://www.

 
2014-02-24 14:57
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:0 
我是用office2007组件 然后另存为pdf 这样比较稳妥 几乎不出什么错误吧 主要代码你可以参考一下
程序代码:
    //Word转换成pdf
        /// <summary>
        /// 把Word文件转换成为PDF格式文件
        /// </summary>
        /// <param name="sourcePath">源文件路径</param>
        /// <param name="targetPath">目标文件路径</param>
        /// <returns>true=转换成功</returns>
        public static bool DOCConvertToPDF(string sourcePath, string targetPath)
        {
            bool result = false;
            Microsoft.Office.Interop.Word.WdExportFormat exportFormat = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;
            object paramMissing = Type.Missing;
            Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new Microsoft.Office.Interop.Word.ApplicationClass();
            Microsoft.Office.Interop.Word.Document wordDocument = null;
            try
            {
                object paramSourceDocPath = sourcePath;
                string paramExportFilePath = targetPath;
                Microsoft.Office.Interop.Word.WdExportFormat paramExportFormat = exportFormat;
                bool paramOpenAfterExport = false;
                Microsoft.Office.Interop.Word.WdExportOptimizeFor paramExportOptimizeFor = Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint;
                Microsoft.Office.Interop.Word.WdExportRange paramExportRange = Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument;
                int paramStartPage = 0;
                int paramEndPage = 0;
                Microsoft.Office.Interop.Word.WdExportItem paramExportItem = Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent;
                bool paramIncludeDocProps = true;
                bool paramKeepIRM = true;
                Microsoft.Office.Interop.Word.WdExportCreateBookmarks paramCreateBookmarks = Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks;
                bool paramDocStructureTags = true;
                bool paramBitmapMissingFonts = true;
                bool paramUseISO19005_1 = false;
                wordDocument = wordApplication.Documents.Open(
                ref paramSourceDocPath, ref paramMissing, ref paramMissing,
                ref paramMissing, ref paramMissing, ref paramMissing,
                ref paramMissing, ref paramMissing, ref paramMissing,
                ref paramMissing, ref paramMissing, ref paramMissing,
                ref paramMissing, ref paramMissing, ref paramMissing,
                ref paramMissing);
                if (wordDocument != null)
                    wordDocument.ExportAsFixedFormat(paramExportFilePath,
                    paramExportFormat, paramOpenAfterExport,
                    paramExportOptimizeFor, paramExportRange, paramStartPage,
                    paramEndPage, paramExportItem, paramIncludeDocProps,
                    paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
                    paramBitmapMissingFonts, paramUseISO19005_1,
                    ref paramMissing);
                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                if (wordDocument != null)
                {
                    wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing);
                    wordDocument = null;
                }
                if (wordApplication != null)
                {
                    wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing);
                    wordApplication = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            return result;
        }

        /// <summary>
        /// 转换方法 ppt to pdf
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="targetPath"></param>
        /// <param name="targetFileType"></param>
        /// <returns></returns>
        private static bool Convert(string sourcePath, string targetPath, PpSaveAsFileType targetFileType)
        {
            bool result;
            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();
                persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);

                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                if (persentation != null)
                {
                    persentation.Close();
                    persentation = null;
                }
                if (application != null)
                {
                    application.Quit();
                    application = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            return result;
        }


 

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2014-02-24 15:56
快速回复:excel、word转换成pdf
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035706 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved