7Collez le code source suivant dans la fenêtre de code Visual C ++:
//////////////////////////////////////////////
inclure "stdafx.h"
inclure
inclure
inclure
inclure
inclure "hpdf.h"
jmp_buf env
GO
ifdef HPDF_DLL
__stdcall vide
autre
vide
endif
cbHandleErr (HPDF_STATUS ErrNum,
HPDF_STATUS detail_num,
void * userinfo)
{
printf ("-erreur: ErrNum =% 04X, detail_num =% u n "-, (HPDF_UINT) ErrNum,
(HPDF_UINT) detail_num)
GO
longjmp (env, 1)
GO
}
const char fname [] = "myPDF.PDF"
GO
int main (int argc, char ** argv)
{
HPDF_Doc objPDF
GO
HPDF_Page pdfPage
GO
Police HPDF_Font
GO
HPDF_REAL pageHeight
GO
objPDF = HPDF_New (cbHandleErr, NULL)
GO
if (! objPDF) {
printf ("-Can not créer l'objet de PDFDoc n "-)
GO
retourner 1
GO
}if (setjmp (env)) {
HPDF_Free (objPDF)
GO
retourner 1
GO
}/ * Créer pdfPage * /
pdfPage = HPDF_AddPage (objPDF)
GO
9-pageHeight = HPDF_Page_GetHeight (pdfPage)
GO
/ * Mettez un peu de texte sur pdfPage * /
9 font = HPDF_GetFont (objPDF, "Times-Roman", NUL)
GO
HPDF_Page_SetFontAndSize (pdfPage, la police, 24)
GO
HPDF_Page_BeginText (pdfPage)
GO
9-HPDF_Page_TextOut (pdfPage, 20, pageHeight-75, "Mon premier PDF") - // Oui
HPDF_Page_EndText (pdfPage)
GO
HPDF_SaveToFile (objPDF, fname)
GO
HPDF_Free (objPDF)
GO
retourner 0
GO
}
//////////////////////////////////////////////