static void Main() { // Create converter instance using (DocxToPdfConverter converter = new DocxToPdfConverter()) { // Perform conversion converter.ConvertDocxToPdf("sample.docx", "result.pdf"); } // Open result document in default PDF viewer Process.Start("result.pdf"); }
static void Main(string[] args) { using (DocxToPdfConverter converter = new DocxToPdfConverter()) { converter.PageSize = PaperKind.A4; converter.Orientation = PaperOrientation.Portrait; converter.Footer = "<p style=\"color: blue;\">FOOTER TEXT</p>"; converter.ConvertDocxToPdf("sample.docx", "result.pdf"); } // Open result file in default PDF viewer Process.Start("result.pdf"); }
public static void Convert(string absolutePath) { DocxToPdfConverter converter = new DocxToPdfConverter(); using (Stream stream = System.IO.File.OpenRead(absolutePath)) { converter.Load(stream); } converter.PdfStandard = PdfStandard.Pdf; using (var stream = System.IO.File.OpenWrite(absolutePath + ".pdf")) { converter.Save(stream); } }
static void Main(string[] args) { using (DocxToPdfConverter converter = new DocxToPdfConverter()) { converter.PageSize = PaperKind.A4; converter.Orientation = PaperOrientation.Portrait; converter.Footer = "<p style=\"color: blue;\">FOOTER TEXT</p>"; converter.ConvertDocxToPdf("sample.docx", "result.pdf"); } // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); }
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()); }