本文整理汇总了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;
}
}
示例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;
}