admin管理员组

文章数量:1593448

特别说明:需引用Aspose.PDF.dll

代码案例:

OpenFileDialog openFileDialog1 = new OpenFileDialog();     //显示选择文件对话框
            openFileDialog1.Filter = "All files (*.*)|*.*|pdf files (*.pdf)|*.pdf";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                int index = openFileDialog1.FileName.LastIndexOf('\\');
                PdfHelper.dataDir = openFileDialog1.FileName.Substring(0, index) + "\\";//显示文件路径
                PdfHelper.dataName = openFileDialog1.FileName.Substring(index + 1, openFileDialog1.FileName.Length - index - 1);
                PdfHelper.Run();
                MessageBox.Show("结束");
            }

 PdfHelper.cs帮助类:

class PdfHelper
    {
        public static string dataDir = "";
        public static string dataName = "";

        public static void Run()
        {
            // ExStart:PDFToDOC
            // The path to the documents directory.
            //string dataDir = //RunExamples.GetDataDir_AsposePdf_DocumentConversion();

            // Open the source PDF document
            Document pdfDocument = new Document(dataDir + dataName);

            // Save the file into MS document format
            pdfDocument.Save(dataDir + "PDFToDOC_out.doc", SaveFormat.Doc);
            // ExEnd:PDFToDOC        

        }
    }

 

本文标签: 操作PDFword