-
Notifications
You must be signed in to change notification settings - Fork 12
/
DocxToPdfHelper.cs
35 lines (31 loc) · 1.01 KB
/
DocxToPdfHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace iDiTect.Converter.Demo
{
public static class DocxToPdfHelper
{
public static void Convert()
{
DocxToPdfConverter converter = new DocxToPdfConverter();
//Load Word document from stream
using (Stream stream = File.OpenRead("sample.docx"))
{
converter.Load(stream);
}
//Or load Word document form byte array
//converter.Load(File.ReadAllBytes("sample.docx"));
//Choose pdf compliance level, PDF or PDF/A
converter.PdfStandard = PdfStandard.Pdf;
//Convert Word to pdf, and save it to file stream
using (var stream = File.OpenWrite("convert.pdf"))
{
converter.Save(stream);
}
//Or save it to byte array
//File.WriteAllBytes("convert.pdf", converter.SaveAsBytes());
}
}
}