zoukankan      html  css  js  c++  java
  • .Net中World转PDF

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Aspose.Words;
    using System.IO;
    using Microsoft.Office.Interop.Word;

    namespace MyFilterTest.Tools
    {
    public class WorldTranslatePDF
    {
    public bool WordToPDF2(string sourcePath)
    {
    bool result = false;
    Application application = new Application();
    Microsoft.Office.Interop.Word.Document document = null;

    try

    {
    application.Visible = false;

    document = application.Documents.Open(sourcePath);

    string PDFPath = sourcePath.Replace(".doc", ".pdf");//pdf存放位置

    if (!File.Exists(PDFPath))//存在PDF,不需要继续转换

    {
    document.ExportAsFixedFormat(PDFPath, WdExportFormat.wdExportFormatPDF);
    }
    result = true;
    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message);
    result = false;
    }
    finally
    {
    document.Close();
    }
    return result;
    }
    public bool WordToPDF1(string sourcePath)
    {
    try
    {
    Aspose.Words.Document doc = new Aspose.Words.Document(sourcePath);
    string targetPath = sourcePath.ToUpper().Replace(".DOCX", ".PDF");
    doc.Save(targetPath, SaveFormat.Pdf);
    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message);
    return false;
    }
    return true;
    }

    }
    }

  • 相关阅读:
    ios原生项目内嵌u3d工程
    u3d内嵌H5游戏 设置cookie
    unity3d IL2CPP for android
    unity3D内嵌android项目
    Django 跨域问题
    tensorflow 调试tfdbg
    Cuda9.1+cunn7.1+Tensorflow1.7-GUP
    shader
    lua 中protobuf repeated 嵌套类 复合类型
    30岁的思考
  • 原文地址:https://www.cnblogs.com/gsh0921/p/10444834.html
Copyright © 2011-2022 走看看