Esempio n. 1
0
        private string _createPDF()
        {
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();

            // C# doesn't have optional arguments so we'll need a dummy value
            object oMissing = System.Reflection.Missing.Value;

            word.Visible        = false;
            word.ScreenUpdating = false;

            //FileInfo wordFile = _filePath;

            // Cast as Object for word Open method
            //Object filename = (Object)wordFile.FullName;
            Object filename = _filePath;

            // Use the dummy value as a placeholder for optional arguments
            Document doc = word.Documents.Open(ref filename, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            doc.Activate();

            //object outputFileName = wordFile.FullName.Replace(".doc", ".pdf");
            object outputFileName = Path.Combine(SimpleServerExtensionMethods.GetArchivePath(_archive), "preview", _hexFolder, _hexValue + ".pdf");
            object fileFormat     = WdSaveFormat.wdFormatPDF;

            // Save document into PDF Format
            doc.SaveAs(ref outputFileName,
                       ref fileFormat, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            object saveChanges = WdSaveOptions.wdDoNotSaveChanges;

            ((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
            doc = null;

            ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);
            word = null;

            return(outputFileName.ToString());
        }
Esempio n. 2
0
 public static string GetFilePath(string objid, string ext = "pdf", string scope = "basis")
 {
     return(Path.Combine(SimpleServerExtensionMethods.GetArchivePath("DMSArchiv"), scope, GetHexFolder(objid), GetHexValue(objid) + "." + ext));
 }