Skip to main content

Export DOCX to PDF

This is a simple code to convert any Word document to a PDF using the Word interop. using Word = Microsoft.Office.Interop.Word; … public Word.Document wordDocument { get; set; } public void ConvertWord2PDF() { var appWord = new Word.Application(); wordDocument = appWord.Documents.Open(@”D:\Tests\test.docx”); wordDocument.ExportAsFixedFormat(@”D:\Tests\test.pdf”, Word.WdExportFormat.wdExportFormatPDF); }  

Use a Dictionary

Here is a simple example of how to use a Dictionary with a Key-Value. var dico = new Dictionary<int, string>(); dico.Add(1, “Steeve”); dico.Add(2, “Morgan”); var result = dico.FirstOrDefault(x => x.Key == 1); var temp = result.Value; //temp = “Steeve”  

SaveFileDiaglog

Here is a simple example of how to use the native SaveFileDialog. var sfd = new SaveFileDialog { Filter = “PDF Documents|*.pdf”, DefaultExt = “.pdf”, FileName = “converted.pdf” }; // Show save file dialog box var result = sfd.ShowDialog(); // Get the location of the file if (result != true) return; var fileName = sfd.FileName; […]

Consume XML From A WebService

I will present two ways of gettingĀ an XML from a WebService and thenĀ read it as object(s). The first one will use validation. To validate an XML we generally use a XSD. This XSD can be provided in the XML it self as a reference or not (like in this case). The XSD is really usefull […]