当前位置: 首页>>代码示例>>C#>>正文


C# Document.ExportAsFixedFormat方法代码示例

本文整理汇总了C#中System.Windows.Forms.Document.ExportAsFixedFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ExportAsFixedFormat方法的具体用法?C# Document.ExportAsFixedFormat怎么用?C# Document.ExportAsFixedFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Document的用法示例。


在下文中一共展示了Document.ExportAsFixedFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertWord2PDF

        private void ConvertWord2PDF(string inputFile, string outputPath)
        {
            try
            {
                if (outputPath.Equals("") || !File.Exists(inputFile))
                {
                    throw new Exception("Either file does not exist or invalid output path");
                }

                // app to open the document belower
                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                Document wordDocument = new Document();

                // input variables
                object objInputFile = inputFile;
                object missParam = Type.Missing;

                wordDocument = wordApp.Documents.Open(ref objInputFile, ref missParam, ref missParam, ref missParam,
                    ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam,
                    ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam);

                if (wordDocument != null)
                {
                    // make the convertion
                    wordDocument.ExportAsFixedFormat(outputPath, WdExportFormat.wdExportFormatPDF, false,
                        WdExportOptimizeFor.wdExportOptimizeForOnScreen, WdExportRange.wdExportAllDocument,
                        0, 0, WdExportItem.wdExportDocumentContent, true, true,
                        WdExportCreateBookmarks.wdExportCreateWordBookmarks, true, true, false, ref missParam);
                }

                // close document and quit application
                wordDocument.Close();
                wordApp.Quit();

                MessageBox.Show("File successfully converted");
                ClearTextBoxes();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:fpgentil,项目名称:Word2PDF,代码行数:42,代码来源:Form1.cs

示例2: saveDocument

 public bool saveDocument(Document document, string outfile)
 {
     if (!Directory.Exists(Path.GetDirectoryName(outfile)))
         Directory.CreateDirectory(Path.GetDirectoryName(outfile));
     try
     {
         if (document != null)
             document.ExportAsFixedFormat(outfile,
                     paramExportFormat, paramOpenAfterExport,
                     paramExportOptimizeFor, paramExportRange, paramStartPage,
                     paramEndPage, paramExportItem, paramIncludeDocProps,
                     paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
                     paramBitmapMissingFonts, chkPDFA.Checked,
                     ref paramMissing);
     }
     catch (Exception ex)
     {
         FileLog.LogWrite("Fikk ikke til å lagre dokumentet. Filen '" + outfile + "' må behandles manuelt." + ex.Message, FileLog.logType.Info);
         LogFromThread(progress, "Fikk ikke til å lagre dokumentet. Filen '" + outfile + "' må behandles manuelt" + Environment.NewLine);
         return false;
     }
     return true;
 }
开发者ID:KDRS-SA,项目名称:IKAVA-Systembehandler,代码行数:23,代码来源:IKAVA_PDFConverter.cs


注:本文中的System.Windows.Forms.Document.ExportAsFixedFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。