home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / bind / c / hello.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-04  |  941 b   |  45 lines  |  [TEXT/CWIE]

  1. /* $Id: hello.c,v 1.6.2.1 2001/05/16 12:25:50 york Exp $
  2.  * PDFlib client: hello example in C
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. #include "pdflib.h"
  10.  
  11. int
  12. main(void)
  13. {
  14.     PDF *p;
  15.     int font;
  16.  
  17.     p = PDF_new();
  18.  
  19.     /* open new PDF file */
  20.     if (PDF_open_file(p, "hello.pdf") == -1) {
  21.     fprintf(stderr, "Error: cannot open PDF file hello.pdf.\n");
  22.     exit(2);
  23.     }
  24.  
  25.     PDF_set_info(p, "Creator", "hello.c");
  26.     PDF_set_info(p, "Author", "Thomas Merz");
  27.     PDF_set_info(p, "Title", "Hello, world (C)!");
  28.  
  29.     PDF_begin_page(p, a4_width, a4_height);    /* start a new page    */
  30.  
  31.     font = PDF_findfont(p, "Helvetica-Bold", "host", 0);
  32.  
  33.     PDF_setfont(p, font, 24);
  34.     PDF_set_text_pos(p, 50, 700);
  35.     PDF_show(p, "Hello, world!");
  36.     PDF_continue_text(p, "(says C)");
  37.     PDF_end_page(p);                /* close page        */
  38.  
  39.     PDF_close(p);                /* close PDF document    */
  40.  
  41.     PDF_delete(p);                /* delete the PDF object */
  42.  
  43.     return 0;
  44. }
  45.