PDF
This page was created by Hans.karlsen@mdriven.net on 2018-05-14. Last edited by Stephanie@mdriven.net on 2025-02-19.

MDriven reports are created with open document text (odt) or open document spreadsheet formats (ods).

If you need to convert the odt to PDF there are online services available. If you rather do this your self you can buy a third party library that has this ability or you can simply automate word (for odt) and have it save your odt as PDF.

   Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();        
   foreach (var file in files)        
   {          
     if (System.IO.Path.GetExtension(file.FileName.ToLower()) == ".odt" )          
     {            
            if (File.Exists(file.FileName)) // Protect againts doublettes
            {
              _Document doc = word.Documents.Open(file.FileName);
              doc.Activate();
              string newfile;
              if (pdf)
              {
                newfile = System.IO.Path.ChangeExtension(file.FileName, ".pdf");
                doc.SaveAs2(newfile, WdSaveFormat.wdFormatPDF);
              }
              object oMissing = System.Reflection.Missing.Value;
              doc.Close(ref oMissing, ref oMissing, ref oMissing);
              File.Delete(file.FileName);
              file.FileName = newfile;
            }
        
        }
        Microsoft.Office.Interop.Word._Application app = word.Application;
        app.Quit();
      }
MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments