C++操作Word转pdf

 word转pdf主要是利用word自带的函数,主要有三个函数(1)Saveas();(2)PrintOut();(3)ExportAsFixedFormat();这三个

函数可以实现:下面着重对其进行说明:

 
  

函数原型public: Void SaveAs( &Object^ FileName, //文件名含路径名,例如COleVariant(CW2T(_T("G:\\C++\\MFC2table1\\000.pdf"))) &Object^ FileFormat, //    17:wdFormatpdf &Object^ LockComments, //置false;COleVariant((short)false), &Object^ Password,     //置空;COleVariant(_T("")) &Object^ AddToRecentFiles, //置false;COleVariant((short)false), &Object^ WritePassword, //置空;COleVariant(_T("")) &Object^ ReadOnlyRecommended, //置false;COleVariant((short)false), &Object^ EmbedTrueTypeFonts, //置false;COleVariant((short)false), &Object^ SaveNativePictureFormat, //置false;COleVariant((short)false), &Object^ SaveFormsData, //置false;COleVariant((short)false), &Object^ SaveAsAOCELetter, //置false;COleVariant((short)false), &Object^ Encoding, //置false;COleVariant((short)false), &Object^ InsertLineBreaks, //置false;COleVariant((short)false), &Object^ AllowSubstitutions, //置false;COleVariant((short)false), &Object^ LineEnding, //置false;COleVariant((short)false), &Object^ AddBiDiMarks//置false;COleVariant((short)false), );

对于printOut()而言word中必须存在这个选项才可以执行;而ExportAsFixedFormat()似乎在C++中不能被调用成功,MSDN中C++就没有该函数,在C#中可以实现

其中主要第二个参数的设置:

Name Value Description
wdFormatDocument 0 Microsoft Office Word format.
wdFormatDOSText 4 Microsoft DOS text format.
wdFormatDOSTextLineBreaks 5 Microsoft DOS text with line breaks preserved.
wdFormatEncodedText 7 Encoded text format.
wdFormatFilteredHTML 10 Filtered HTML format.
wdFormatHTML 8 Standard HTML format.
wdFormatRTF 6 Rich text format (RTF).
wdFormatTemplate 1 Word template format.
wdFormatText 2 Microsoft Windows text format.
wdFormatTextLineBreaks 3 Windows text format with line breaks preserved.
wdFormatUnicodeText 7 Unicode text format.
wdFormatWebArchive 9 Web archive format.
wdFormatXML 11 Extensible Markup Language (XML) format.
wdFormatDocument97 0 Microsoft Word 97 document format.
wdFormatDocumentDefault 16 Word default document file format. For Microsoft Office Word 2007, this is the DOCX format.
wdFormatPDF 17 PDF format.
wdFormatTemplate97 1 Word 97 template format.
wdFormatXMLDocument 12 XML document format.
wdFormatXMLDocumentMacroEnabled 13 XML document format with macros enabled.
wdFormatXMLTemplate 14 XML template format.
wdFormatXMLTemplateMacroEnabled 15 XML template format with macros enabled.
wdFormatXPS 18 XPS format.

你可能感兴趣的:(Office自动化)