//Loads an existing Word document
WordDocumentwordDocument = newWordDocument("Sample.docx", FormatType.Docx); //Initializes the ChartToImageConverter for converting charts during Word to pdf conversion wordDocument.ChartToImageConverter = newChartToImageConverter(); //Creates an instance of the DocToPDFConverter - responsible for Word to PDF conversion DocToPDFConverterconverter = newDocToPDFConverter(); //Sets true to enable fast rendering . converter.Settings.EnableFastRendering = true; //Sets a value indicating whether to optimize the memory usage for the identical images in Word to PDF conversion . converter.Settings.OptimizeIdenticalImages = true; //Converts Word document into PDF document PdfDocumentpdfDocument = converter.ConvertToPDF(wordDocument); //Saves the PDF file to file system pdfDocument.Save("WordtoPDF.pdf"); //Closes the instance of document objects pdfDocument.Close(true); wordDocument.Close(); |
FileStream docStream = new FileStream(@"Template.docx", FileMode.Open, FileAccess.Read); //Loads file stream into Word document WordDocument wordDocument = new WordDocument(docStream, Syncfusion.DocIO.FormatType.Automatic); //Instantiation of DocIORenderer for Word to PDF conversion DocIORenderer render = new DocIORenderer(); //Sets true to optimize the memory usage for identical images render.Settings.OptimizeIdenticalImages = true; //Converts Word document into PDF document PdfDocument pdfDocument = render.ConvertToPDF(wordDocument); //Releases all resources used by the Word document and DocIO Renderer objects render.Dispose(); wordDocument.Dispose(); //Saves the PDF file MemoryStream outputStream = new MemoryStream(); pdfDocument.Save(outputStream); //Closes the instance of PDF document object pdfDocument.Close(); |
//Loads an existing Word document WordDocumentwordDocument = newWordDocument("Sample.docx",FormatType.Docx); //Initializes the ChartToImageConverter for converting charts during Word to pdf conversion wordDocument.ChartToImageConverter = newChartToImageConverter(); //Creates an instance of the DocToPDFConverter - responsible for Word to PDF conversion DocToPDFConverterconverter = newDocToPDFConverter(); //Sets true to enable fast rendering . converter.Settings.EnableFastRendering = true; //Sets a value indicating whether to optimize the memory usage for the identical images in Word to PDF conversion . converter.Settings.OptimizeIdenticalImages = true; //Converts Word document into PDF document PdfDocumentpdfDocument = converter.ConvertToPDF(wordDocument); //Saves the PDF file to file system pdfDocument.Save("WordtoPDF.pdf"); //Closes the instance of document objects pdfDocument.Close(true); wordDocument.Close(); |