LOGO

LOGO
LOGO
ads header

Breaking News

OFFİCE BELGELERİNİ PDF YEÇEVİRMEK

Office belgelerini pdf ye çevirmek.

1.YÖNTEM:
https://www.e-iceblue.com/Download/download-word-for-net-free.html
Ücretsiz Spire.Doc for .NET'deki ilgi alanlarınız için teşekkür ederiz . Ticari ve kişisel kullanımınız için herhangi bir uyarı mesajı olmaksızın tamamen ücretsizdir. Ücretsiz sürüm 500 paragraf ve 25 tablo ile sınırlıdır . Bu sınırlama, dosya okuma veya yazma sırasında zorlanır. Word belgelerini PDF ve XPS dosyalarına dönüştürürken, sadece PDF ve XPS dosyasının ilk 3 sayfasını alabilirsiniz. Gereksinimleriniz sınırlamayı aşarsa, lütfen Spire.Doc'un Ticari Sürümü'nü kullanın .

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string wordfile = Server.MapPath(@"~\Belgeler\01.02.2017-1.docx");

        string pdfpath = System.IO.Path.GetDirectoryName(wordfile);
        
        Document document = new Document();
        document.LoadFromFile(wordfile);
        //embeds full fonts by default when IsEmbeddedAllFonts is set to true.
        ToPdfParameterList ppl = new ToPdfParameterList();
        ppl.IsEmbeddedAllFonts = true;

        //Save doc file to pdf.
        document.SaveToFile(pdfpath+@"\Sample.pdf", ppl);
        
    }
}

2.YOL:BİLGİSAYARDA OFFİCE YÜKLÜ İSE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



using Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Office.Core;




public partial class _Default : System.Web.UI.Page
{

    public string CreatePDF(string path, string exportDir)
    {
        Application app = new Application();
        app.DisplayAlerts = WdAlertLevel.wdAlertsNone;
        app.Visible = true;

        var objPresSet = app.Documents;
        var objPres = objPresSet.Open(path, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);

        var baseFileName = Path.GetFileNameWithoutExtension(path);
        var pdfFileName = baseFileName + ".pdf";
        var pdfPath = Path.Combine(exportDir, pdfFileName);

        try
        {
            objPres.ExportAsFixedFormat(
                pdfPath,
                WdExportFormat.wdExportFormatPDF,
                false,
                WdExportOptimizeFor.wdExportOptimizeForPrint,
                WdExportRange.wdExportAllDocument
            );
        }
        catch
        {
            pdfPath = null;
        }
        finally
        {
            objPres.Close();
        }
        return pdfPath;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        
        string filename = Server.MapPath( @"~/Document/Test.docx");
        string pathfile=System.IO.Path.GetDirectoryName(filename);
        Response.Write(pathfile);

        CreatePDF(filename, pathfile);
    }
}


Hiç yorum yok