горизонтально расположенные полосы: белая, синяя, красная

Как конвертировать DOCX в PDF на C# и VB.NET

Конвертирование DOCX-файла в формат PDF

using System;
using System.IO;
using System.Collections;
namespace Sample
{
  class Test
  {
    static void Main(string[] args)
    {
      SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
      // After purchasing the license, please insert your serial number here to activate the component.
      //p.Serial = "XXXXXXXXXXX";
      if (p != null)
      {
        string docxPath = @"..\..\example.docx";
        string pdfPath = Path.ChangeExtension(docxPath, ".pdf");

        //Convert DOCX file to PDF file
        if (p.DocxToPdfConvertFile(docxPath, pdfPath) == 0)
          System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true });
        else
        {
          System.Console.WriteLine("Conversion failed!");
          Console.ReadLine();
        }
      }
    }
  }
}
Imports System
Imports System.IO
Namespace Sample
  Friend Class Test
    Shared Sub Main(ByVal args() As String)
      Dim p As New SautinSoft.PdfMetamorphosis()
      ' After purchasing the license, please insert your serial number here to activate the component.
      'p.Serial = "XXXXXXXXXXX"
      If p IsNot Nothing Then
        Dim docxPath As String = "..\..\example.docx"
        Dim pdfPath As String = Path.ChangeExtension(docxPath, ".pdf")

        ' Convert DOCX file to PDF file
        If p.DocxToPdfConvertFile(docxPath, pdfPath) = 0 Then
          System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfPath) With {.UseShellExecute = True})
        Else
          System.Console.WriteLine("Conversion failed!")
          Console.ReadLine()
        End If
      End If
    End Sub
  End Class
End Namespace

Конвертирование DOCX-файла в формат PDF в памяти

using System;
using System.IO;
using System.Collections;
namespace Sample
{
  class Test
  {
    static void Main(string[] args)
    {
      SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
      // After purchasing the license, please insert your serial number here to activate the component.
      //p.Serial = "XXXXXXXXXXX";
      if (p != null)
      {
        string docxPath = @"..\..\example.docx";
        string pdfPath = Path.ChangeExtension(docxPath, ".pdf");
        byte[] docx = File.ReadAllBytes(docxPath);

        // Convert DOCX to PDF in memory
        byte[] pdf = p.DocxToPdfConvertByte(docx);
        if (pdf != null)
        {
          // Save the PDF document to a file for a viewing purpose.
          File.WriteAllBytes(pdfPath, pdf);
          System.Diagnostics.Process.Start(pdfPath);
        }
        else
        {
          System.Console.WriteLine("Conversion failed!");
          Console.ReadLine();
        }
      }
    }
  }
}
Imports System
Imports System.IO
Namespace Sample
  Friend Class Test
    Shared Sub Main(ByVal args() As String)
      Dim p As New SautinSoft.PdfMetamorphosis()
      ' After purchasing the license, please insert your serial number here to activate the component.
      'p.Serial = "XXXXXXXXXXX";
      If p IsNot Nothing Then
        Dim docxPath As String = "..\..\example.docx"
        Dim pdfPath As String = Path.ChangeExtension(docxPath, ".pdf")
        Dim docx() As Byte = File.ReadAllBytes(docxPath)

        ' Convert DOCX to PDF in memory
        Dim pdf() As Byte = p.DocxToPdfConvertByte(docx)
        If pdf IsNot Nothing Then
          ' Save the PDF document to a file for a viewing purpose.
          File.WriteAllBytes(pdfPath, pdf)
          System.Diagnostics.Process.Start(pdfPath)
        Else
          System.Console.WriteLine("Conversion failed!")
          Console.ReadLine()
        End If
      End If
    End Sub
  End Class
End Namespace

Конвертирование DOC (Word 97-2003) в PDF-формат

using System;
using System.IO;
using System.Collections;
namespace Sample
{
  class Test
  {
    static void Main(string[] args)
    {
      SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
      // After purchasing the license, please insert your serial number here to activate the component.
      //p.Serial = "XXXXXXXXXXX";
      if (p != null)
      {
        string docPath = @"..\..\example.doc";
        string pdfPath = Path.ChangeExtension(docPath, ".pdf");

        // Convert DOC file to PDF file
        if (p.DocToPdfConvertFile(docPath, pdfPath) == 0)
          System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true });
        else
          {
            System.Console.WriteLine("Conversion failed!");
            Console.ReadLine();
          }
        }
      }
    }
  }
}
Imports System
Imports System.IO
Namespace Sample
  Friend Class Test
    Shared Sub Main(ByVal args() As String)
      Dim p As New SautinSoft.PdfMetamorphosis()
      ' After purchasing the license, please insert your serial number here to activate the component.
      'p.Serial = "XXXXXXXXXXX"
      If p IsNot Nothing Then
        Dim docPath As String = "..\..\example.doc"
        Dim pdfPath As String = Path.ChangeExtension(docPath, ".pdf")

        ' Convert DOC file to PDF file
        If p.DocToPdfConvertFile(docPath, pdfPath) = 0 Then
          System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfPath) With {.UseShellExecute = True})
        Else
          System.Console.WriteLine("Conversion failed!")
          Console.ReadLine()
        End If
      End If
    End Sub
  End Class
End Namespace

Конвертирование DOC (Word 97-2003) в PDF-формат в памяти

using System;
using System.IO;
using System.Collections;
namespace Sample
{
  class Test
  {
    static void Main(string[] args)
    {
      SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
      // After purchasing the license, please insert your serial number here to activate the component.
      //p.Serial = "XXXXXXXXXXX";
      if (p != null)
      {
        string docPath = @"..\..\example.doc";
        string pdfPath = Path.ChangeExtension(docPath, ".pdf");
        byte[] doc = File.ReadAllBytes(docPath);

        // Convert DOC to PDF in memory
        byte[] pdf = p.DocToPdfConvertByte(doc);
        if (pdf != null)
        {
          // Save the PDF document to a file for a viewing purpose.
          File.WriteAllBytes(pdfPath, pdf);
          System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true });
        }
        else
        {
          System.Console.WriteLine("Conversion failed!");
          Console.ReadLine();
        }
      }
    }
  }
}
Imports System
Imports System.IO
Namespace Sample
  Friend Class Test
    Shared Sub Main(ByVal args() As String)
      Dim p As New SautinSoft.PdfMetamorphosis()
      ' After purchasing the license, please insert your serial number here to activate the component.
      'p.Serial = "XXXXXXXXXXX";
      If p IsNot Nothing Then
        Dim docPath As String = "..\..\example.doc"
        Dim pdfPath As String = Path.ChangeExtension(docPath, ".pdf")
        Dim doc() As Byte = File.ReadAllBytes(docPath)

        ' Convert DOC to PDF in memory
        Dim pdf() As Byte = p.DocToPdfConvertByte(doc)
        If pdf IsNot Nothing Then
          ' Save the PDF document to a file for a viewing purpose.
          File.WriteAllBytes(pdfPath, pdf)
          System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfPath) With {.UseShellExecute = True})
        Else
          System.Console.WriteLine("Conversion failed!")
          Console.ReadLine()
        End If
      End If
    End Sub
  End Class
End Namespace

Другие примеры кода SautinSoft.PdfMetamorphosis

✦ DOCX/DOC в PDF RTF в PDF HTML в PDF Text в PDF Всё в PDF Split/Merge PDF Настройки PDF Запароленный PDF Watermark
 ВВЕРХ