admin管理员组文章数量:1593159
特别说明:需引用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
}
}
版权声明:本文标题:C# PDF操作之-PDF转WORD 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1728166114a1148039.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论