Exemplo n.º 1
0
int main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    HPDF_Font font;
    HPDF_Page page;
    char fname[256];
    HPDF_Destination dst;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    /* error-handler */
    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);

    /* create default-font */
    font = HPDF_GetFont (pdf, "Helvetica", NULL);

    /* add a new page object. */
    page = HPDF_AddPage (pdf);

    HPDF_Page_SetWidth (page, 650);
    HPDF_Page_SetHeight (page, 500);

    dst = HPDF_Page_CreateDestination (page);
    HPDF_Destination_SetXYZ (dst, 0, HPDF_Page_GetHeight (page), 1);
    HPDF_SetOpenAction(pdf, dst);

    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, font, 20);
    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70);
    HPDF_Page_ShowText (page, "JpegDemo");
    HPDF_Page_EndText (page);

    HPDF_Page_SetFontAndSize (page, font, 12);

    draw_image (pdf, "rgb.jpg", 70, HPDF_Page_GetHeight (page) - 410,
                "24bit color image");
    draw_image (pdf, "gray.jpg", 340, HPDF_Page_GetHeight (page) - 410,
                "8bit grayscale image");

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 2
0
void echo2(HPDF_Page page, char *str1, int i, int j){

    HPDF_Page_EndText (page);

    HPDF_Page_Rectangle (page, 10 + (HPDF_Page_GetWidth(page)/100)*i, HPDF_Page_GetHeight(page)-25 - j*10, 200,
                20);
    HPDF_Page_Stroke (page);

    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 12 + (HPDF_Page_GetWidth(page)/100)*i, HPDF_Page_GetHeight(page)-20 - j*10, str1);
};
Exemplo n.º 3
0
HPDF_Page WPdfRenderer::createPage(int page)
{
#ifndef WT_TARGET_JAVA
    HPDF_Page result = HPDF_AddPage(pdf_);

    HPDF_Page_SetWidth(result, HPDF_Page_GetWidth(page_));
    HPDF_Page_SetHeight(result, HPDF_Page_GetHeight(page_));

    return result;
#else
    return Wt::Render::Utils::createPage(pdf_,
                                         HPDF_Page_GetWidth(page_),
                                         HPDF_Page_GetHeight(page_));
#endif
}
/*
 * Class:     org_libharu_PdfPage
 * Method:    getHeight
 * Signature: ()F
 */
JNIEXPORT jfloat JNICALL
Java_org_libharu_PdfPage_getHeight(JNIEnv *env, jobject obj) {
    jint page;
    /* Get mHPDFPagePointer */
    page = (*env)->GetIntField(env, obj, mHPDFPagePointer);
    return HPDF_Page_GetHeight((HPDF_Page) page);
}
Exemplo n.º 5
0
JNIEXPORT jfloat JNICALL Java_org_libharu_Page_getHeight
  (JNIEnv *env, jobject obj)
{
  haru_setup_error_handler(env, __func__);
  HPDF_Page page = get_HPDF_Page(env, obj); 
  jfloat height = HPDF_Page_GetHeight(page);
  haru_clear_error_handler();
  return height;
}
float PDFGenerator::pdfDoc_GetPageMaxHeight(bool ignoreMargins) const
{
  float result = 0;

  if (pdfDocument && pdfDocCurrentPage)
  {
    result = (float)HPDF_Page_GetHeight(pdfDocCurrentPage);

    if (!ignoreMargins)
    {
      result -= (_globalPageMarginBottom + _globalPageMarginTop);
    }

  }

  return result;
}
Exemplo n.º 7
0
int main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    HPDF_Font font;
    HPDF_Page page;
    char fname[256];
    HPDF_Image image;
	char *png_image_data;
	FILE *fp;

    HPDF_REAL x, y;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    /* error-handler */
    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);

    /* create default-font */
    font = HPDF_GetFont (pdf, "Helvetica", NULL);

    /* add a new page object. */
    page = HPDF_AddPage (pdf);

    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, font, 20);
    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70);
    HPDF_Page_ShowText (page, "RawImageDemo");
    HPDF_Page_EndText (page);

	int n;

	fp = fopen("2.png", "r");
	png_image_data = malloc(1024*1024);
	n = fread(png_image_data, 1, 1024*1024, fp);
	fclose(fp);

    /* load GrayScale raw-image (1bit) file from memory. */
    image = HPDF_LoadPngImageFromMem (pdf, png_image_data, n);

    /* Draw image to the canvas. (normal-mode with actual size.)*/
    HPDF_Page_DrawImage (page, image, 20, 20, 1024, 768);

	free(png_image_data);

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 8
0
int main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    HPDF_Font font;
    HPDF_Page page;
    char fname[256];
    HPDF_Image image;

    HPDF_REAL x, y;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    /* error-handler */
    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);

    /* create default-font */
    font = HPDF_GetFont (pdf, "Helvetica", NULL);

    /* add a new page object. */
    page = HPDF_AddPage (pdf);

    HPDF_Page_SetWidth (page, 172);
    HPDF_Page_SetHeight (page, 80);

    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, font, 20);
    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70);
    HPDF_Page_ShowText (page, "RawImageDemo");
    HPDF_Page_EndText (page);

    /* load RGB raw-image file. */
    #ifndef __WIN32__
    image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_rgb.dat",
            32, 32, HPDF_CS_DEVICE_RGB);
    #else
    image = HPDF_LoadRawImageFromFile (pdf, "rawimage\\32_32_rgb.dat",
            32, 32, HPDF_CS_DEVICE_RGB);
    #endif

    x = 20;
    y = 20;

    /* Draw image to the canvas. (normal-mode with actual size.)*/
    HPDF_Page_DrawImage (page, image, x, y, 32, 32);

    /* load GrayScale raw-image file. */
    #ifndef __WIN32__
    image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_gray.dat",
            32, 32, HPDF_CS_DEVICE_GRAY);
    #else
    image = HPDF_LoadRawImageFromFile (pdf, "rawimage\\32_32_gray.dat",
            32, 32, HPDF_CS_DEVICE_GRAY);
    #endif

    x = 70;
    y = 20;

    /* Draw image to the canvas. (normal-mode with actual size.)*/
    HPDF_Page_DrawImage (page, image, x, y, 32, 32);

    /* load GrayScale raw-image (1bit) file from memory. */
    image = HPDF_LoadRawImageFromMem (pdf, RAW_IMAGE_DATA, 32, 32,
                HPDF_CS_DEVICE_GRAY, 1);

    x = 120;
    y = 20;

    /* Draw image to the canvas. (normal-mode with actual size.)*/
    HPDF_Page_DrawImage (page, image, x, y, 32, 32);

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 9
0
void echo1(HPDF_Page page, char *str1, char *str2, int i){
    HPDF_Page_TextOut (page, 10, HPDF_Page_GetHeight(page)-20 - (i*10), str1);
    HPDF_Page_TextOut (page, 150, HPDF_Page_GetHeight(page)-20 - (i*10), str2);
};
Exemplo n.º 10
0
int main (int /* argc */, char **argv)
{
    const char *page_title = "Font Demo";
    HPDF_Doc  pdf;
    char fname[256];
    HPDF_Page page;
    HPDF_Font def_font;
    HPDF_REAL tw;
    HPDF_REAL height;
    HPDF_REAL width;
    HPDF_UINT i;
    HPDF_Image image;
    double x;
    double y;
    double iw;
    double ih;
    HPDF_Stream stream;
    
    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    /* Add a new page object. */
    page = HPDF_AddPage (pdf);

    height = HPDF_Page_GetHeight (page);
    width = HPDF_Page_GetWidth (page);

    /* Print the lines of the page. */
    HPDF_Page_SetLineWidth (page, 1);
    HPDF_Page_Rectangle (page, 50, 50, width - 100, height - 110);
    HPDF_Page_Stroke (page);

    /* Print the title of the page (with positioning center). */
    def_font = HPDF_GetFont (pdf, "Helvetica", NULL);
    HPDF_Page_SetFontAndSize (page, def_font, 24);

    tw = HPDF_Page_TextWidth (page, page_title);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, (width - tw) / 2, height - 50, page_title);
    HPDF_Page_EndText (page);

    /* output subtitle. */
    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, def_font, 16);
    HPDF_Page_TextOut (page, 60, height - 80, "<Standerd Type1 fonts samples>");
    HPDF_Page_EndText (page);

    HPDF_Page_BeginText (page);
    HPDF_Page_MoveTextPos (page, 60, height - 105);

    i = 0;
    while (font_list[i]) {
        const char* samp_text = "abcdefgABCDEFG12345!#$%&+-@?";
        HPDF_Font font = HPDF_GetFont (pdf, font_list[i], NULL);

        /* print a label of text */
        HPDF_Page_SetFontAndSize (page, def_font, 9);
        HPDF_Page_ShowText (page, font_list[i]);
        HPDF_Page_MoveTextPos (page, 0, -18);

        /* print a sample text. */
        HPDF_Page_SetFontAndSize (page, font, 20);
        HPDF_Page_ShowText (page, samp_text);
        HPDF_Page_MoveTextPos (page, 0, -20);

        i++;
    }

    HPDF_Page_EndText (page);

    /* Add a new page object. */
    page = HPDF_AddPage (pdf);

    height = HPDF_Page_GetHeight (page);
    width = HPDF_Page_GetWidth (page);
    
    /* load image file. */
    image = HPDF_LoadPngImageFromFile (pdf, "test.png");

    x = 100;
    y = 100;
    iw = HPDF_Image_GetWidth (image);
    ih = HPDF_Image_GetHeight (image);
    
    /* Draw image to the canvas. (normal-mode with actual size.)*/
    HPDF_Page_DrawImage (page, image, x, y, iw, ih);
    
    HPDF_SaveToFile (pdf, fname);
    
    /* write something via zlib */
    stream = HPDF_FileWriter_New( pdf->mmgr, "test2.raw" );    
    HPDF_Stream_WriteToStream( image->stream, stream, HPDF_STREAM_FILTER_FLATE_DECODE, NULL );
    HPDF_Stream_Free (stream);
    
    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 11
0
int main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    char fname[256];
    HPDF_Font font;
    const char *font_name;
    int i = 0;
    HPDF_Outline root;

    const char *encodings[] = {
            "StandardEncoding",
            "MacRomanEncoding",
            "WinAnsiEncoding",
            "ISO8859-2",
            "ISO8859-3",
            "ISO8859-4",
            "ISO8859-5",
            "ISO8859-9",
            "ISO8859-10",
            "ISO8859-13",
            "ISO8859-14",
            "ISO8859-15",
            "ISO8859-16",
            "CP1250",
            "CP1251",
            "CP1252",
            "CP1254",
            "CP1257",
            "KOI8-R",
            "Symbol-Set",
            "ZapfDingbats-Set",
            NULL
    };

    pdf = HPDF_NewEx (error_handler, NULL, NULL, 0, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    /* set compression mode */
    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);

    /* Set page mode to use outlines. */
    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE);

    /* get default font */
    font = HPDF_GetFont (pdf, "Helvetica", NULL);

    /* load font object */
    #ifdef __WIN32__
    font_name = HPDF_LoadType1FontFromFile (pdf, "type1\\a010013l.afm",
            "type1\\a010013l.pfb");
    #else
    font_name = HPDF_LoadType1FontFromFile (pdf, "type1/a010013l.afm",
            "type1/a010013l.pfb");
    #endif

    /* create outline root. */
    root = HPDF_CreateOutline (pdf, NULL, "Encoding list", NULL);
    HPDF_Outline_SetOpened (root, HPDF_TRUE);

    while (encodings[i]) {
        HPDF_Page page = HPDF_AddPage (pdf);
        HPDF_Outline outline;
        HPDF_Destination dst;
        HPDF_Font font2;

        HPDF_Page_SetWidth (page, PAGE_WIDTH);
        HPDF_Page_SetHeight (page, PAGE_HEIGHT);

        outline = HPDF_CreateOutline (pdf, root, encodings[i], NULL);
        dst = HPDF_Page_CreateDestination (page);
        HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page), 1);
        /* HPDF_Destination_SetFitB(dst); */
        HPDF_Outline_SetDestination(outline, dst);

        HPDF_Page_SetFontAndSize (page, font, 15);
        draw_graph (page);

        HPDF_Page_BeginText (page);
        HPDF_Page_SetFontAndSize (page, font, 20);
        HPDF_Page_MoveTextPos (page, 40, PAGE_HEIGHT - 50);
        HPDF_Page_ShowText (page, encodings[i]);
        HPDF_Page_ShowText (page, " Encoding");
        HPDF_Page_EndText (page);

        if (strcmp (encodings[i], "Symbol-Set") == 0)
            font2 = HPDF_GetFont (pdf, "Symbol", NULL);
        else if (strcmp (encodings[i], "ZapfDingbats-Set") == 0)
            font2 = HPDF_GetFont (pdf, "ZapfDingbats", NULL);
        else
            font2 = HPDF_GetFont (pdf, font_name, encodings[i]);

        HPDF_Page_SetFontAndSize (page, font2, 14);
        draw_fonts (page);

        i++;
    }

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 12
0
int main (int argc, char **argv)
{
    const char *page_title = "Font Demo";
    HPDF_Doc  pdf;
    char fname[256];
    HPDF_Page page;
    HPDF_Font def_font;
    HPDF_REAL tw;
    HPDF_REAL height;
    HPDF_REAL width;
    HPDF_UINT i;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    /* Add a new page object. */
    page = HPDF_AddPage (pdf);

    height = HPDF_Page_GetHeight (page);
    width = HPDF_Page_GetWidth (page);

    /* Print the lines of the page. */
    HPDF_Page_SetLineWidth (page, 1);
    HPDF_Page_Rectangle (page, 50, 50, width - 100, height - 110);
    HPDF_Page_Stroke (page);

    /* Print the title of the page (with positioning center). */
    def_font = HPDF_GetFont (pdf, "Helvetica", NULL);
    HPDF_Page_SetFontAndSize (page, def_font, 24);

    tw = HPDF_Page_TextWidth (page, page_title);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, (width - tw) / 2, height - 50, page_title);
    HPDF_Page_EndText (page);

    /* output subtitle. */
    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, def_font, 16);
    HPDF_Page_TextOut (page, 60, height - 80, "<Standerd Type1 fonts samples>");
    HPDF_Page_EndText (page);

    HPDF_Page_BeginText (page);
    HPDF_Page_MoveTextPos (page, 60, height - 105);

    i = 0;
    while (font_list[i]) {
        const char* samp_text = "ÏðèâåòabcdefgABCDEFG12345!#$%&+-@?";
        HPDF_Font font = HPDF_GetFont (pdf, font_list[i], "CP1251");

        /* print a label of text */
        HPDF_Page_SetFontAndSize (page, def_font, 9);
        HPDF_Page_ShowText (page, font_list[i]);
        HPDF_Page_MoveTextPos (page, 0, -18);

        /* print a sample text. */
        HPDF_Page_SetFontAndSize (page, font, 20);
        HPDF_Page_ShowText (page, samp_text);
        HPDF_Page_MoveTextPos (page, 0, -20);

        i++;
    }

    HPDF_Page_EndText (page);

    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 13
0
int main (int argc, char **argv)
{
    const char *page_title = "Text Demo";

    HPDF_Doc  pdf;
    HPDF_Font font;
    HPDF_Page page;
    char fname[256];

    const char* samp_text = "abcdefgABCDEFG123!#$%&+-@?";
    const char* samp_text2 = "The quick brown fox jumps over the lazy dog.";
    float tw;
    float fsize;
    int i;
    int len;

    float angle1;
    float angle2;
    float rad1;
    float rad2;

    float ypos;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    /* set compression mode */
    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);

    /* create default-font */
    font = HPDF_GetFont (pdf, "Helvetica", NULL);

    /* add a new page object. */
    page = HPDF_AddPage (pdf);

    /* draw grid to the page */
    print_grid  (pdf, page);

    /* print the lines of the page.
    HPDF_Page_SetLineWidth (page, 1);
    HPDF_Page_Rectangle (page, 50, 50, HPDF_Page_GetWidth(page) - 100,
                HPDF_Page_GetHeight (page) - 110);
    HPDF_Page_Stroke (page);
    */

    /* print the title of the page (with positioning center). */
    HPDF_Page_SetFontAndSize (page, font, 24);
    tw = HPDF_Page_TextWidth (page, page_title);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, (HPDF_Page_GetWidth(page) - tw) / 2,
                HPDF_Page_GetHeight (page) - 50, page_title);
    HPDF_Page_EndText (page);

    HPDF_Page_BeginText (page);
    HPDF_Page_MoveTextPos (page, 60, HPDF_Page_GetHeight(page) - 60);

    /*
     * font size
     */
    fsize = 8;
    while (fsize < 60) {
        char buf[50];
        int len;

        /* set style and size of font. */
        HPDF_Page_SetFontAndSize(page, font, fsize);

        /* set the position of the text. */
        HPDF_Page_MoveTextPos (page, 0, -5 - fsize);

        /* measure the number of characters which included in the page. */
        strcpy(buf, samp_text);
        len = HPDF_Page_MeasureText (page, samp_text,
                        HPDF_Page_GetWidth(page) - 120, HPDF_FALSE, NULL);

        /* truncate the text. */
        buf[len] = 0x00;

        HPDF_Page_ShowText (page, buf);

        /* print the description. */
        HPDF_Page_MoveTextPos (page, 0, -10);
        HPDF_Page_SetFontAndSize(page, font, 8);
        #ifdef __WIN32__
        _snprintf(buf, 50, "Fontsize=%.0f", fsize);
        #else
        snprintf(buf, 50, "Fontsize=%.0f", fsize);
        #endif
        HPDF_Page_ShowText (page, buf);

        fsize *= 1.5;
    }

    /*
     * font color
     */
    HPDF_Page_SetFontAndSize(page, font, 8);
    HPDF_Page_MoveTextPos (page, 0, -30);
    HPDF_Page_ShowText (page, "Font color");

    HPDF_Page_SetFontAndSize (page, font, 18);
    HPDF_Page_MoveTextPos (page, 0, -20);
    len = strlen (samp_text);
    for (i = 0; i < len; i++) {
        char buf[2];
        float r = (float)i / (float)len;
        float g = 1 - ((float)i / (float)len);
        buf[0] = samp_text[i];
        buf[1] = 0x00;

        HPDF_Page_SetRGBFill (page, r, g, 0.0);
        HPDF_Page_ShowText (page, buf);
    }
    HPDF_Page_MoveTextPos (page, 0, -25);

    for (i = 0; i < len; i++) {
        char buf[2];
        float r = (float)i / (float)len;
        float b = 1 - ((float)i / (float)len);
        buf[0] = samp_text[i];
        buf[1] = 0x00;

        HPDF_Page_SetRGBFill (page, r, 0.0, b);
        HPDF_Page_ShowText (page, buf);
    }
    HPDF_Page_MoveTextPos (page, 0, -25);

    for (i = 0; i < len; i++) {
        char buf[2];
        float b = (float)i / (float)len;
        float g = 1 - ((float)i / (float)len);
        buf[0] = samp_text[i];
        buf[1] = 0x00;

        HPDF_Page_SetRGBFill (page, 0.0, g, b);
        HPDF_Page_ShowText (page, buf);
    }

    HPDF_Page_EndText (page);

    ypos = 450;

    /*
     * Font rendering mode
     */
    HPDF_Page_SetFontAndSize(page, font, 32);
    HPDF_Page_SetRGBFill (page, 0.5, 0.5, 0.0);
    HPDF_Page_SetLineWidth (page, 1.5);

     /* PDF_FILL */
    show_description (page,  60, ypos,
                "RenderingMode=PDF_FILL");
    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos, "ABCabc123");
    HPDF_Page_EndText (page);

    /* PDF_STROKE */
    show_description (page, 60, ypos - 50,
                "RenderingMode=PDF_STROKE");
    HPDF_Page_SetTextRenderingMode (page, HPDF_STROKE);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos - 50, "ABCabc123");
    HPDF_Page_EndText (page);

    /* PDF_FILL_THEN_STROKE */
    show_description (page, 60, ypos - 100,
                "RenderingMode=PDF_FILL_THEN_STROKE");
    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_THEN_STROKE);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos - 100, "ABCabc123");
    HPDF_Page_EndText (page);

    /* PDF_FILL_CLIPPING */
    show_description (page, 60, ypos - 150,
                "RenderingMode=PDF_FILL_CLIPPING");
    HPDF_Page_GSave (page);
    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_CLIPPING);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos - 150, "ABCabc123");
    HPDF_Page_EndText (page);
    show_stripe_pattern (page, 60, ypos - 150);
    HPDF_Page_GRestore (page);

    /* PDF_STROKE_CLIPPING */
    show_description (page, 60, ypos - 200,
                "RenderingMode=PDF_STROKE_CLIPPING");
    HPDF_Page_GSave (page);
    HPDF_Page_SetTextRenderingMode (page, HPDF_STROKE_CLIPPING);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos - 200, "ABCabc123");
    HPDF_Page_EndText (page);
    show_stripe_pattern (page, 60, ypos - 200);
    HPDF_Page_GRestore (page);

    /* PDF_FILL_STROKE_CLIPPING */
    show_description (page, 60, ypos - 250,
                "RenderingMode=PDF_FILL_STROKE_CLIPPING");
    HPDF_Page_GSave (page);
    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_STROKE_CLIPPING);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, ypos - 250, "ABCabc123");
    HPDF_Page_EndText (page);
    show_stripe_pattern (page, 60, ypos - 250);
    HPDF_Page_GRestore (page);

    /* Reset text attributes */
    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL);
    HPDF_Page_SetRGBFill (page, 0, 0, 0);
    HPDF_Page_SetFontAndSize(page, font, 30);


    /*
     * Rotating text
     */
    angle1 = 30;                   /* A rotation of 30 degrees. */
    rad1 = angle1 / 180 * 3.141592; /* Calcurate the radian value. */

    show_description (page, 320, ypos - 60, "Rotating text");
    HPDF_Page_BeginText (page);
    HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1),
                330, ypos - 60);
    HPDF_Page_ShowText (page, "ABCabc123");
    HPDF_Page_EndText (page);


    /*
     * Skewing text.
     */
    show_description (page, 320, ypos - 120, "Skewing text");
    HPDF_Page_BeginText (page);

    angle1 = 10;
    angle2 = 20;
    rad1 = angle1 / 180 * 3.141592;
    rad2 = angle2 / 180 * 3.141592;

    HPDF_Page_SetTextMatrix (page, 1, tan(rad1), tan(rad2), 1, 320, ypos - 120);
    HPDF_Page_ShowText (page, "ABCabc123");
    HPDF_Page_EndText (page);


    /*
     * scaling text (X direction)
     */
    show_description (page, 320, ypos - 175, "Scaling text (X direction)");
    HPDF_Page_BeginText (page);
    HPDF_Page_SetTextMatrix (page, 1.5, 0, 0, 1, 320, ypos - 175);
    HPDF_Page_ShowText (page, "ABCabc12");
    HPDF_Page_EndText (page);


    /*
     * scaling text (Y direction)
     */
    show_description (page, 320, ypos - 250, "Scaling text (Y direction)");
    HPDF_Page_BeginText (page);
    HPDF_Page_SetTextMatrix (page, 1, 0, 0, 2, 320, ypos - 250);
    HPDF_Page_ShowText (page, "ABCabc123");
    HPDF_Page_EndText (page);


    /*
     * char spacing, word spacing
     */

    show_description (page, 60, 140, "char-spacing 0");
    show_description (page, 60, 100, "char-spacing 1.5");
    show_description (page, 60, 60, "char-spacing 1.5, word-spacing 2.5");

    HPDF_Page_SetFontAndSize (page, font, 20);
    HPDF_Page_SetRGBFill (page, 0.1, 0.3, 0.1);

    /* char-spacing 0 */
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, 140, samp_text2);
    HPDF_Page_EndText (page);

    /* char-spacing 1.5 */
    HPDF_Page_SetCharSpace (page, 1.5);

    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, 100, samp_text2);
    HPDF_Page_EndText (page);

    /* char-spacing 1.5, word-spacing 3.5 */
    HPDF_Page_SetWordSpace (page, 2.5);

    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, 60, 60, samp_text2);
    HPDF_Page_EndText (page);

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Exemplo n.º 14
0
		int fileWriter(HPDF_Doc  pdf,
			HPDF_Outline root,
			HPDF_Font font,
			const std::string curFile,
			const std::vector< std::string> vec) {

			auto func_footbar = [](std::string fileName)->std::string {
				std::ostringstream buffer;
				buffer << "  File:" << fileName.c_str() << "   Autor:XCL ";
				return buffer.str();
			};

			auto func_pageOutline = [&](HPDF_Page page, std::string curFile) {
				HPDF_Outline outline;
				HPDF_Destination dst;
				outline = HPDF_CreateOutline(pdf, root, curFile.c_str(), NULL);
				dst = HPDF_Page_CreateDestination(page);
				HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page), 1);// 1 = 默认百分比100
				HPDF_Outline_SetDestination(outline, dst);
			};
			
			auto func_drawRow = [](HPDF_Page page,std::string rid,std::string row,int y ) {
				HPDF_Page_BeginText(page);
				HPDF_Page_MoveTextPos(page, config::ROWID_WIDTH, y - 2);
				HPDF_Page_ShowText(page, rid.c_str());
				HPDF_Page_ShowText(page, row.c_str());
				HPDF_Page_EndText(page);
			};

			HPDF_Page page = nullptr;			
			HPDF_REAL width,height;		
			HPDF_UINT y = 0;		//  x =0,
			int currID = 0, pageID = 0, currRowCount;
			std::string ss, rid;
	
			for (int i = 0; i < vec.size(); i++) {							
				if (i == 0 || currRowCount >  config::PAGE_ROWNUM) {
					//////////////////////////////////////////////
					page = HPDF_AddPage(pdf);

					width = HPDF_Page_GetWidth(page);
					height = HPDF_Page_GetHeight(page);
//					x = 0;
					y = height - config::ROW_HEIGHT;

					func_pageOutline(page, curFile);
					HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);															

					{
						HPDF_RGBColor c = HPDF_Page_GetRGBFill(page);
						HPDF_Page_SetRGBStroke(page, 0.0, 0.5, 0);
						HPDF_Page_SetFontAndSize(page, font, config::FOOTBAR_FONT_SIZE);
						HPDF_Page_SetLineWidth(page, 0.5);
						HPDF_Page_MoveTo(page, 0, 13);
						HPDF_Page_LineTo(page, width, 16);
						HPDF_Page_Stroke(page);

						HPDF_Page_SetRGBFill(page, 0.0, 0, 0.5);
						HPDF_Page_BeginText(page);
						HPDF_Page_MoveTextPos(page, 40, config::FOOTBAR_FONT_SIZE - 5);
						HPDF_Page_ShowText(page, func_footbar(curFile).c_str());
						HPDF_Page_EndText(page);
						HPDF_Page_SetRGBFill(page, c.r, c.g, c.b);
					};
					
					y = height - config::ROW_HEIGHT * 2;
					HPDF_Page_SetFontAndSize(page, font, config::PAGE_FONT_SIZE);
					pageID++;
					currRowCount = 1;
					//////////////////////////////////////////////
				}
												
				///////////////////////////////////////////			
				 ss = vec[i];
				 HPDF_REAL wrid = HPDF_Page_TextWidth(page, rid.c_str());
			 NEWROW:			
				 HPDF_REAL wss = HPDF_Page_TextWidth(page, ss.c_str());			
				 rid = util::rowidWidth(currRowCount );
				 if (wrid + wss >  width) {
					 //简单处理:超过页宽,直接分成两行.足以应付大部份情况.
					 int center = ss.length() / 2;		 
					 func_drawRow(page, rid,ss.substr(0, center),y);
					 y -= config::ROW_HEIGHT;
					 currRowCount++;
					 ss = ss.substr(center);
					 goto NEWROW;
				 }
				 else {			
					func_drawRow(page, rid, ss,y);				
					y -= config::ROW_HEIGHT;		
					currRowCount++;
				 }
				//////////////////////////////////////////
			}
			return 0;
		} //end func
Exemplo n.º 15
0
double WPdfRenderer::pageHeight(int page) const
{
    return HPDF_Page_GetHeight(page_) * dpi_ / 72.0;
}
Exemplo n.º 16
0
int main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    HPDF_Page page;
    HPDF_Font def_font;
    HPDF_REAL height;
    HPDF_REAL width;
    HPDF_UINT i;
    int page_num = 1;
    int done = 0;
    char page_number[MAXSTRING];
    int line_num = 1;
    FILE *input_file = NULL;
    for (i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "-t") == 0)
        {
            strcpy(page_title, argv[++i]);
        }
        else if (strcmp(argv[i], "-o") == 0)
        {
            strcpy(fname, argv[++i]);
        }
        else if (strcmp(argv[i], "-k") == 0)
        {
            page_margin_odd = page_margin_kindle;
            page_margin_even = page_margin_kindle;
        }
        else if (strcmp(argv[i], "-n") == 0)
        {
            no_line_number = 1;
        }
        else if (strcmp(argv[i], "-h")==0)
        {
            usage();
        }
        else if (strcmp(argv[i], "-l") == 0)
        {
            use_landscape = 1;
            page_margin_odd = page_margin_odd_landscape;
            page_margin_even = page_margin_even_landscape;
            LINES_PER_PAGE=50;
        }
        else if (strcmp(argv[i], "-")==0)
        {
            input_file = stdin;
        }
        else
        {
            input_file = fopen(argv[i], "r");
        }
    }

    if (input_file == NULL)
    {
        printf("error: no input specified\n");
        usage();
    }

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }
    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }
    while (!done)
    {
        int n = 0;
        char buf[1000];
        char *p;

        while ((p = fgets(buf, 999, input_file)) && n < LINES_PER_PAGE)
        {
            if (buf[0] == '@')
            {
                if (strncmp(buf, "@title ", 7)==0)
                {
                    strcpy(page_title, buf+7);
                }
                else if (strncmp(buf, "@newpage", 8)==0)
                {
                    if (n != 0 && n != LINES_PER_PAGE-1)
                    {
                        line_num += LINES_PER_PAGE;
                        line_num -= line_num % LINES_PER_PAGE;
                        line_num ++;
                        break;
                    }
                }
                continue;
            }
            lines[n].line_num = line_num++;
            strcpy(lines[n].line, buf);
            n++;
        }

        /* If no more input in future, this is the last page,
         * flag as done.
         */
        if (p == NULL)
            done = 1;

        /* If no lines are read, we are done. */
        if (n == 0)
            break;

        /* Add a new page object. */
        page = HPDF_AddPage (pdf);
        HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, use_landscape?HPDF_PAGE_LANDSCAPE:HPDF_PAGE_PORTRAIT); 
        HPDF_Page_SetRGBFill(page, 0, 0, 0);
        
        height = HPDF_Page_GetHeight (page);
        width = HPDF_Page_GetWidth (page);

        page_margin = EVENPAGE(page_num) ? page_margin_even : page_margin_odd;
        page_size.cx = (int)width;
        page_size.cy = (int)height;

        def_font = HPDF_GetFont (pdf, default_font_name, NULL);
        HPDF_Page_SetFontAndSize (page, def_font, 16);
        print_page_header(pdf, page, page_title);
        print_page_content(pdf, page, lines, n);
        sprintf(page_number, "%d", page_num);
        print_page_footer(pdf, page, page_number);
        page_num++;
    }
    if (page_num > 1)
    {
        HPDF_SaveToFile (pdf, fname);
        printf("Output written to %s\n", fname);
    }
    else
    {
        printf("No output\n");
    }
    
    if (input_file != stdin && input_file != NULL)
        fclose(input_file);

    /* clean up */
    HPDF_Free (pdf);
    return 0;
}
Exemplo n.º 17
0
int
main (int argc, char **argv)
{
    HPDF_Doc  pdf;
    HPDF_Page page;
    char fname[256];
    HPDF_Font font;
    //float angle1;
    //float angle2;
    //float rad1;
    //float rad2;
    //HPDF_REAL page_height;
    HPDF_Rect rect;
    //int i;

    //const char* SAMP_TXT = "Дирк Мюллер: власть над миром принадлежит банкам";


    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    //printf("%s\n",HPDF_GetCurrentEncoder (pdf));

    /* add a new page object. */
    page = HPDF_AddPage (pdf);
    HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_LANDSCAPE); // HPDF_PAGE_PORTRAIT

    //print_grid  (pdf, page);

    //page_height = HPDF_Page_GetHeight (page);

    //page_height += 0;

    font = HPDF_GetFont (pdf, "Courier", "CP1251");
    HPDF_Page_SetTextLeading (page, 20);

    /* text_rect method */

    /* HPDF_TALIGN_LEFT */
    rect.left = 25;
    rect.top = 545;
    rect.right = 200;
    rect.bottom = rect.top - 20;



    //~ HPDF_Page_Rectangle (page, 200 , 300 , 300, 100);
    //~ HPDF_Page_Stroke (page);

    //~ HPDF_Page_BeginText (page);
    //~ HPDF_Page_SetFontAndSize (page, font, 10);


    //~ int cnt =0;
    //~ HPDF_Page_TextRect (page, 10 , 600, 50, 550,
            //~ "123 45 6789 123 45 6789",
                    //~ HPDF_TALIGN_LEFT, &cnt);
    //~ printf("printed %d\n", cnt);
    //~ HPDF_Page_EndText (page);

    HPDF_Page_BeginText (page);



    HPDF_Page_SetFontAndSize (page, font, 11);
    //HPDF_Page_TextOut (page, rect.left, rect.top + 3, "Поставщик");

    echo1(page, "Поставщик", "ООО «РЕКО»", 0);
    echo1(page, "ИНН", "4345363002", 1);
    echo1(page, "КПП", "434501001", 2);
    echo1(page, "Телефон/факс", "62-38-67, 78-88-58", 3);
    echo1(page, "Расчетный счет", "40702810200220090271", 4);
    echo1(page, "Корр. счет", "30101810100000000711", 5);
    echo1(page, "Банк", "ОАО КБ «Хлынов» г. Киров", 6);
    echo1(page, "БИК", "043304711", 7);
    echo1(page, "", "Счет № / от ", 8);
    echo1(page, "Плательщик: КОГКУ «Государственный архив социально-политической истории Кировской области»", "", 10);
    echo1(page, "Юр. г. Киров, ул. Казанская, 16а,", "", 11);
    echo1(page, "Факс: (8332) 35-75-56,", "", 12);
    echo1(page, "ИНН: 4345057460 ", "", 13);

    HPDF_Page_SetFontAndSize (page, font, 12);
    HPDF_Page_EndText (page);

    int collum_size[] = {40, 7, 10, 7, 12, 12, 12};

    char* text[] = {"Наименование товара", "Ед.Изм.", "Количество", "Цена", "Сумма без НДС", "Сумма НДС", "Всего с НДС",
        "1. Оказание услуг хостинга с 01 апреля 2015г. по 30 июня 2015г.", "шт.", "1", "5100=00", "5100=00", "0", "5100=00",
        "Всего к оплате:", "", "", "", "5100=00", "0", "5100=00"
        };

    table(page, font, 3, 7, 10,  HPDF_Page_GetHeight(page)-20 - (17*10), 20, /*!*/
            collum_size, text);

    draw_image (pdf, "shtamp2.png", 100, 0 , "8bit alpha.");

    int collum_size2[] = {50, 50};
    char* text2[] = {"Итого: Пять тысяч сто рублей 00 копеек", "5100=00 ",
            "ООО «РЕКО» применяет упрощенную систему налогообложения", "",
            "Директор ООО «РЕКО» ______________ /Лажинцев П.В./ ", " Главный бухгалтер ______________/_________________/ "
        };
    table(page, font, 3, 2, 10,  HPDF_Page_GetHeight(page)-20 - (25*10), 20, /*!*/
            collum_size2, text2);




    /* HPDF_TALIGN_RIGTH */
    //~ rect.left = 220;
    //~ rect.right = 395;
//~
    //~ HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
                //~ rect.top - rect.bottom);
    //~ HPDF_Page_Stroke (page);
//~
    //~ HPDF_Page_BeginText (page);
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 10);
    //~ HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_RIGTH");
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 13);
    //~ HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
                //~ SAMP_TXT, HPDF_TALIGN_RIGHT, NULL);
//~
//~
    //~ HPDF_Page_EndText (page);

    //~ /* HPDF_TALIGN_CENTER */
    //~ rect.left = 25;
    //~ rect.top = 475;
    //~ rect.right = 200;
    //~ rect.bottom = rect.top - 40;
//~
    //~ HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
                //~ rect.top - rect.bottom);
    //~ HPDF_Page_Stroke (page);
//~
    //~ HPDF_Page_BeginText (page);
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 10);
    //~ HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_CENTER");
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 13);
    //~ HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
                //~ SAMP_TXT, HPDF_TALIGN_CENTER, NULL);
//~
    //~ HPDF_Page_EndText (page);
//~
    //~ /* HPDF_TALIGN_JUSTIFY */
    //~ rect.left = 220;
    //~ rect.right = 395;
//~
    //~ HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
                //~ rect.top - rect.bottom);
    //~ HPDF_Page_Stroke (page);
//~
    //~ HPDF_Page_BeginText (page);
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 10);
    //~ HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_JUSTIFY");
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 13);
    //~ HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
                //~ SAMP_TXT, HPDF_TALIGN_JUSTIFY, NULL);
//~
    //~ HPDF_Page_EndText (page);
//~
//~
//~
    //~ /* Skewed coordinate system */
    //~ HPDF_Page_GSave (page);
//~
    //~ angle1 = 5;
    //~ angle2 = 10;
    //~ rad1 = angle1 / 180 * 3.141592;
    //~ rad2 = angle2 / 180 * 3.141592;
//~
    //~ HPDF_Page_Concat (page, 1, tan(rad1), tan(rad2), 1, 25, 350);
    //~ rect.left = 0;
    //~ rect.top = 40;
    //~ rect.right = 175;
    //~ rect.bottom = 0;
//~
    //~ HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
                //~ rect.top - rect.bottom);
    //~ HPDF_Page_Stroke (page);
//~
    //~ HPDF_Page_BeginText (page);
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 10);
    //~ HPDF_Page_TextOut (page, rect.left, rect.top + 3, "Skewed coordinate system");
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 13);
    //~ HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
                //~ SAMP_TXT, HPDF_TALIGN_LEFT, NULL);
//~
    //~ HPDF_Page_EndText (page);
//~
    //~ HPDF_Page_GRestore (page);
//~
//~
    //~ /* Rotated coordinate system */
    //~ HPDF_Page_GSave (page);
//~
    //~ angle1 = 5;
    //~ rad1 = angle1 / 180 * 3.141592;
//~
    //~ HPDF_Page_Concat (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), 220, 350);
    //~ rect.left = 0;
    //~ rect.top = 40;
    //~ rect.right = 175;
    //~ rect.bottom = 0;
//~
    //~ HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
                //~ rect.top - rect.bottom);
    //~ HPDF_Page_Stroke (page);
//~
    //~ HPDF_Page_BeginText (page);
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 10);
    //~ HPDF_Page_TextOut (page, rect.left, rect.top + 3, "Rotated coordinate system");
//~
    //~ HPDF_Page_SetFontAndSize (page, font, 13);
    //~ HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
                //~ SAMP_TXT, HPDF_TALIGN_LEFT, NULL);
//~
    //~ HPDF_Page_EndText (page);
//~
    //~ HPDF_Page_GRestore (page);
//~
//~
    //~ /* text along a circle */
    //~ HPDF_Page_SetGrayStroke (page, 0);
    //~ HPDF_Page_Circle (page, 210, 190, 145);
    //~ HPDF_Page_Circle (page, 210, 190, 113);
    //~ HPDF_Page_Stroke (page);
//~
    //~ angle1 = 360 / (strlen (SAMP_TXT));
    //~ angle2 = 180;
//~
    //~ HPDF_Page_BeginText (page);
    //~ font = HPDF_GetFont (pdf, "Courier-Bold", NULL);
    //~ HPDF_Page_SetFontAndSize (page, font, 30);
//~
    //~ for (i = 0; i < strlen (SAMP_TXT); i++) {
        //~ char buf[2];
        //~ float x;
        //~ float y;
//~
        //~ rad1 = (angle2 - 90) / 180 * 3.141592;
        //~ rad2 = angle2 / 180 * 3.141592;
//~
        //~ x = 210 + cos(rad2) * 122;
        //~ y = 190 + sin(rad2) * 122;
//~
        //~ HPDF_Page_SetTextMatrix(page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), x, y);
//~
        //~ buf[0] = SAMP_TXT[i];
        //~ buf[1] = 0;
        //~ HPDF_Page_ShowText (page, buf);
        //~ angle2 -= angle1;
    //~ }
//~
    //~ HPDF_Page_EndText (page);

    /* save the document to a file */
    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}