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#中可以实现

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

NameValueDescription
wdFormatDocument0Microsoft Office Word format.
wdFormatDOSText4Microsoft DOS text format.
wdFormatDOSTextLineBreaks5Microsoft DOS text with line breaks preserved.
wdFormatEncodedText7Encoded text format.
wdFormatFilteredHTML10Filtered HTML format.
wdFormatHTML8Standard HTML format.
wdFormatRTF6Rich text format (RTF).
wdFormatTemplate1Word template format.
wdFormatText2Microsoft Windows text format.
wdFormatTextLineBreaks3Windows text format with line breaks preserved.
wdFormatUnicodeText7Unicode text format.
wdFormatWebArchive9Web archive format.
wdFormatXML11Extensible Markup Language (XML) format.
wdFormatDocument970Microsoft Word 97 document format.
wdFormatDocumentDefault16Word default document file format. For Microsoft Office Word 2007, this is the DOCX format.
wdFormatPDF17PDF format.
wdFormatTemplate971Word 97 template format.
wdFormatXMLDocument12XML document format.
wdFormatXMLDocumentMacroEnabled13XML document format with macros enabled.
wdFormatXMLTemplate14XML template format.
wdFormatXMLTemplateMacroEnabled15XML template format with macros enabled.
wdFormatXPS18XPS format.
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值