#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "grid_sheet.h"
#include "handler.h"
#include "utils.h"
void
{
while (iy < 50) {
y + iy);
iy += 3;
}
}
void
const char *text)
{
}
int main (int argc, char **argv)
{
const char *page_title = "Text Demo";
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 (demo_error_handler, NULL);
if (!pdf) {
printf ("error: cannot create PdfDoc object\n");
return 1;
}
if (setjmp(env)) {
return 1;
}
print_grid (pdf, page);
fsize = 8;
while (fsize < 60) {
char buf[50];
int len;
strcpy(buf, samp_text);
buf[len] = 0x00;
HPDF_snprintf(buf, 50, "Fontsize=%.0f", fsize);
fsize *= 1.5;
}
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;
}
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;
}
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;
}
ypos = 450;
show_description (page, 60, ypos,
"RenderingMode=PDF_FILL");
show_description (page, 60, ypos - 50,
"RenderingMode=PDF_STROKE");
show_description (page, 60, ypos - 100,
"RenderingMode=PDF_FILL_THEN_STROKE");
show_description (page, 60, ypos - 150,
"RenderingMode=PDF_FILL_CLIPPING");
show_stripe_pattern (page, 60, ypos - 150);
show_description (page, 60, ypos - 200,
"RenderingMode=PDF_STROKE_CLIPPING");
show_stripe_pattern (page, 60, ypos - 200);
show_description (page, 60, ypos - 250,
"RenderingMode=PDF_FILL_STROKE_CLIPPING");
show_stripe_pattern (page, 60, ypos - 250);
angle1 = 30;
show_description (page, 320, ypos - 60, "Rotating text");
330, ypos - 60);
show_description (page, 320, ypos - 120, "Skewing text");
angle1 = 10;
angle2 = 20;
show_description (page, 320, ypos - 175, "Scaling text (X direction)");
show_description (page, 320, ypos - 250, "Scaling text (Y direction)");
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");
return 0;
}
HPDF_STATUS HPDF_SaveToFile(HPDF_Doc pdf, const char *filename)
Saves the current document to file.
void HPDF_Free(HPDF_Doc pdf)
Revoke a document object and all resources.
HPDF_Doc HPDF_New(HPDF_Error_Handler user_error_fn, void *user_data)
Create an instance of a document object and initialize it.
HPDF_Font HPDF_GetFont(HPDF_Doc pdf, const char *font_name, const char *encoding_name)
Get requested font object handle.
HPDF_STATUS HPDF_Page_SetCharSpace(HPDF_Page page, HPDF_REAL value)
Set text character spacing.
HPDF_STATUS HPDF_Page_SetLineWidth(HPDF_Page page, HPDF_REAL line_width)
Set width of the line used to stroke paths.
HPDF_STATUS HPDF_Page_Stroke(HPDF_Page page)
Paint current path.
HPDF_STATUS HPDF_Page_SetRGBStroke(HPDF_Page page, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b)
Set stroke color (RGB).
HPDF_STATUS HPDF_Page_MoveTo(HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
Start new subpath and move current point for drawing path.
HPDF_STATUS HPDF_Page_SetRGBFill(HPDF_Page page, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b)
Set filling color (RGB).
HPDF_STATUS HPDF_Page_TextOut(HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, const char *text)
Put text to the specified position.
HPDF_STATUS HPDF_Page_SetWordSpace(HPDF_Page page, HPDF_REAL value)
Set text word spacing.
HPDF_STATUS HPDF_Page_GSave(HPDF_Page page)
Save the page's current graphics state to the stack.
HPDF_STATUS HPDF_Page_SetFontAndSize(HPDF_Page page, HPDF_Font font, HPDF_REAL size)
Set the type of font and size leading.
HPDF_STATUS HPDF_Page_LineTo(HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
Append path from current point to specified point.
HPDF_STATUS HPDF_Page_ShowText(HPDF_Page page, const char *text)
Put text at the current text position on the page.
HPDF_STATUS HPDF_Page_GRestore(HPDF_Page page)
Restore graphics state which is saved by HPDF_Page_GSave().
HPDF_STATUS HPDF_Page_SetTextRenderingMode(HPDF_Page page, HPDF_TextRenderingMode mode)
Set text rendering mode.
HPDF_STATUS HPDF_Page_BeginText(HPDF_Page page)
Begin text object and set text position to (0, 0).
HPDF_STATUS HPDF_Page_EndText(HPDF_Page page)
Finish text object.
HPDF_STATUS HPDF_Page_MoveTextPos(HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
Change current text position using the specified offset values.
HPDF_UINT HPDF_Page_MeasureText(HPDF_Page page, const char *text, HPDF_REAL width, HPDF_BOOL wordwrap, HPDF_REAL *real_width)
Calculate byte length which can be included within the specified width.
HPDF_REAL HPDF_Page_TextWidth(HPDF_Page page, const char *text)
Get text width in current font size, character spacing and word spacing.
HPDF_REAL HPDF_Page_GetHeight(HPDF_Page page)
Get page height.
HPDF_Page HPDF_AddPage(HPDF_Doc pdf)
Create new page and add it after the last page of document.
HPDF_REAL HPDF_Page_GetWidth(HPDF_Page page)
Get page width.
HPDF_Font HPDF_Page_GetCurrentFont(HPDF_Page page)
Get page current font handle.
HPDF_REAL HPDF_Page_GetCurrentFontSize(HPDF_Page page)
Get page current font size.
HPDF_RGBColor HPDF_Page_GetRGBFill(HPDF_Page page)
Get page current filling color value (RGB).
HPDF_STATUS HPDF_SetCompressionMode(HPDF_Doc pdf, HPDF_UINT mode)
Set compression mode.
HPDF_STATUS HPDF_Page_SetTextMatrix(HPDF_Page page, HPDF_REAL a, HPDF_REAL b, HPDF_REAL c, HPDF_REAL d, HPDF_REAL x, HPDF_REAL y)
#define HPDF_COMP_ALL
Definition: hpdf_consts.h:82
#define HPDF_FALSE
Definition: hpdf_consts.h:27
#define HPDF_PI
Definition: hpdf_consts.h:32
unsigned int HPDF_UINT
Definition: hpdf_types.h:45
float HPDF_REAL
Definition: hpdf_types.h:79
@ HPDF_FILL
Definition: hpdf_types.h:327
@ HPDF_STROKE_CLIPPING
Definition: hpdf_types.h:332
@ HPDF_FILL_STROKE_CLIPPING
Definition: hpdf_types.h:333
@ HPDF_FILL_THEN_STROKE
Definition: hpdf_types.h:329
@ HPDF_STROKE
Definition: hpdf_types.h:328
@ HPDF_FILL_CLIPPING
Definition: hpdf_types.h:331
Definition: hpdf_objects.h:421
Definition: hpdf_doc.h:36
Definition: hpdf_types.h:287
HPDF_REAL r
Definition: hpdf_types.h:288
HPDF_REAL b
Definition: hpdf_types.h:290
HPDF_REAL g
Definition: hpdf_types.h:289