|
#pragma warning (disable:
4192)
//
automatically excluding 'IStream' while importing type library
#import <XFCom.tlb> no_namespace
// Import the XF
COM+ library
#include <stdio.h>
int main(int argc, char*
argv[])
{
// Initialize
COM libraries
::CoInitialize(NULL);
try
{
// Create
a new instance of the engine
IXFRendererPtr engine(__uuidof(XFRenderer));
// Render
some XSL-FO text and place the output into a file
// The
output format will be detected from the output file's name
// (in
this case is XOF_PDF).
engine->render(L"<fo:root
xmlns:fo='http://www.w3.org/1999/XSL/Format'>"
L"<fo:layout-master-set>"
L"<fo:simple-page-master
master-name='all-pages'>"
L"<fo:region-body
region-name='xsl-region-body' margin='0.7in'/>"
L"</fo:simple-page-master>"
L"</fo:layout-master-set>"
L"<fo:page-sequence
master-reference='all-pages'>"
L"<fo:flow
flow-name='xsl-region-body'>"
L"<fo:block>Hello
World!</fo:block>"
L"</fo:flow>"
L"</fo:page-sequence>"
L"</fo:root>",
L"C:\\HelloWorld.pdf");
printf("Document
rendered successfully!\n");
}
catch
(_com_error& e)
{
// Report any errors that may occur
if
(e.Description().length())
printf("Error occured: %s\n", (LPCSTR)e.Description());
else
if (e.ErrorMessage())
printf("Error occured: %s\n", e.ErrorMessage());
else
printf("Unknown error occured: 0x%08X\n", e.Error());
}
::CoUninitialize();
return 0;
}
|