pdf.c
来自「windows下PDF文档的开发包」· C语言 代码 · 共 2,468 行 · 第 1/5 页
C
2,468 行
convert_to_long_ex(image);
convert_to_string_ex(optlist);
retval = PDF_fill_imageblock(pdf,
Z_LVAL_PP(page),
Z_STRVAL_PP(blockname),
Z_LVAL_PP(image),
Z_STRVAL_PP(optlist));
RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */
}
/* }}} */
/* TODO [optlist] */
/* {{{ proto int pdf_fill_pdfblock(int pdfdoc, int page, string spotname, int contents, string optlist);
* Process a PDF block according to its properties. */
PHP_FUNCTION(pdf_fill_pdfblock)
{
zval **p, **page, **blockname, **contents, **optlist;
PDF *pdf;
int retval;
if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &blockname, &contents, &optlist) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf);
convert_to_long_ex(page);
convert_to_string_ex(blockname);
convert_to_long_ex(contents);
convert_to_string_ex(optlist);
retval = PDF_fill_pdfblock(pdf,
Z_LVAL_PP(page),
Z_STRVAL_PP(blockname),
Z_LVAL_PP(contents),
Z_STRVAL_PP(optlist));
RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */
}
/* }}} */
/* TODO [optlist] */
/* {{{ proto int pdf_fill_textblock(int pdfdoc, int page, string spotname, string text, string optlist);
* Process a text block according to its properties. */
PHP_FUNCTION(pdf_fill_textblock)
{
zval **p, **page, **blockname, **text, **optlist;
PDF *pdf;
int retval;
if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &blockname, &text, &optlist) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf);
convert_to_long_ex(page);
convert_to_string_ex(blockname);
convert_to_string_ex(text);
convert_to_string_ex(optlist);
retval = PDF_fill_textblock(pdf,
Z_LVAL_PP(page),
Z_STRVAL_PP(blockname),
Z_STRVAL_PP(text),
Z_STRLEN_PP(text),
Z_STRVAL_PP(optlist));
RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */
}
/* }}} */
/* p_color.c */
/* {{{ proto int pdf_makespotcolor(int pdfdoc, string spotname);
* Make a named spot color from the current color. */
PHP_FUNCTION(pdf_makespotcolor)
{
zval **arg1, **arg2;
PDF *pdf;
int spotcolor;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_string_ex(arg2);
spotcolor = PDF_makespotcolor(pdf,
Z_STRVAL_PP(arg2),
Z_STRLEN_PP(arg2));
RETURN_LONG(spotcolor); /* offset handled in PDFlib Kernel */
}
/* }}} */
/* {{{ proto void pdf_setcolor(int pdfdoc, string fstype, string colorspace, float c1 [, float c2 [, float c3 [, float c4]]]);
* Set the current color space and color. fstype is "fill", "stroke", or "both". */
PHP_FUNCTION(pdf_setcolor)
{
zval **p, **fstype, **colorspace, **c1, **c2, **c3, **c4;
PDF *pdf;
int argc = ZEND_NUM_ARGS();
if(argc < 4 || argc > 7) {
WRONG_PARAM_COUNT;
}
switch(argc) {
case 4:
if(zend_get_parameters_ex(4, &p, &fstype, &colorspace, &c1) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 5:
if(zend_get_parameters_ex(5, &p, &fstype, &colorspace, &c1, &c2) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 6:
if(zend_get_parameters_ex(6, &p, &fstype, &colorspace, &c1, &c2, &c3) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 7:
if(zend_get_parameters_ex(7, &p, &fstype, &colorspace, &c1, &c2, &c3, &c4) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf);
convert_to_string_ex(fstype);
convert_to_string_ex(colorspace);
convert_to_double_ex(c1);
if(argc > 4) convert_to_double_ex(c2);
if(argc > 5) convert_to_double_ex(c3);
if(argc > 6) convert_to_double_ex(c4);
PDF_setcolor(pdf,
Z_STRVAL_PP(fstype),
Z_STRVAL_PP(colorspace),
(float) Z_DVAL_PP(c1),
(float) ((argc>4) ? Z_DVAL_PP(c2):0),
(float) ((argc>5) ? Z_DVAL_PP(c3):0),
(float) ((argc>6) ? Z_DVAL_PP(c4):0));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setgray(int pdfdoc, float value)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setgray)
{
zval **arg1, **arg2;
PDF *pdf;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
PDF_setcolor(pdf, "both", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setgray_fill(int pdfdoc, float value)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setgray_fill)
{
zval **arg1, **arg2;
PDF *pdf;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
PDF_setcolor(pdf, "fill", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setgray_stroke(int pdfdoc, float value)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setgray_stroke)
{
zval **arg1, **arg2;
PDF *pdf;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
PDF_setcolor(pdf, "stroke", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setrgbcolor(int pdfdoc, float red, float green, float blue)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setrgbcolor)
{
zval **arg1, **arg2, **arg3, **arg4;
PDF *pdf;
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
PDF_setcolor(pdf, "both", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setrgbcolor_fill)
{
zval **arg1, **arg2, **arg3, **arg4;
PDF *pdf;
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
PDF_setcolor(pdf, "fill", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue)
* Depricated user pdf_setcolor instead */
PHP_FUNCTION(pdf_setrgbcolor_stroke)
{
zval **arg1, **arg2, **arg3, **arg4;
PDF *pdf;
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
PDF_setcolor(pdf, "stroke", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0);
RETURN_TRUE;
}
/* }}} */
/* p_draw.c */
/* {{{ proto void pdf_arc(int pdfdoc, float x, float y, float r, float alpha, float beta)
* Draw a counterclockwise circular arc from alpha to beta degrees. */
PHP_FUNCTION(pdf_arc)
{
zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6;
PDF *pdf;
if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
convert_to_double_ex(arg5);
convert_to_double_ex(arg6);
PDF_arc(pdf, (float) Z_DVAL_PP(arg2),
(float) Z_DVAL_PP(arg3),
(float) Z_DVAL_PP(arg4),
(float) Z_DVAL_PP(arg5),
(float) Z_DVAL_PP(arg6));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_arcn(int pdfdoc, float x, float y, float r, float alpha, float beta);
* Draw a clockwise circular arc from alpha to beta degrees. */
PHP_FUNCTION(pdf_arcn)
{
zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6;
PDF *pdf;
if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
convert_to_double_ex(arg5);
convert_to_double_ex(arg6);
PDF_arcn(pdf,
(float) Z_DVAL_PP(arg2),
(float) Z_DVAL_PP(arg3),
(float) Z_DVAL_PP(arg4),
(float) Z_DVAL_PP(arg5),
(float) Z_DVAL_PP(arg6));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_circle(int pdfdoc, float x, float y, float r)
* Draw a circle with center (x, y) and radius r. */
PHP_FUNCTION(pdf_circle)
{
zval **arg1, **arg2, **arg3, **arg4;
PDF *pdf;
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
PDF_circle(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_clip(int pdfdoc)
* Use the current path as clipping path. */
PHP_FUNCTION(pdf_clip)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_clip(pdf);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_closepath(int pdfdoc)
* Close the current path. */
PHP_FUNCTION(pdf_closepath)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_closepath(pdf);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_closepath_fill_stroke(int pdfdoc)
* Close the path, fill, and stroke it. */
PHP_FUNCTION(pdf_closepath_fill_stroke)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_closepath_fill_stroke(pdf);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_closepath_stroke(int pdfdoc)
* Close the path, and stroke it. */
PHP_FUNCTION(pdf_closepath_stroke)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_closepath_stroke(pdf);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3)
* Draw a Bezier curve from the current point, using 3 more control points. */
PHP_FUNCTION(pdf_curveto)
{
zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7;
PDF *pdf;
if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_double_ex(arg2);
convert_to_double_ex(arg3);
convert_to_double_ex(arg4);
convert_to_double_ex(arg5);
convert_to_double_ex(arg6);
convert_to_double_ex(arg7);
PDF_curveto(pdf, (float) Z_DVAL_PP(arg2),
(float) Z_DVAL_PP(arg3),
(float) Z_DVAL_PP(arg4),
(float) Z_DVAL_PP(arg5),
(float) Z_DVAL_PP(arg6),
(float) Z_DVAL_PP(arg7));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_endpath(int pdfdoc)
* End the current path without filling or stroking it. */
PHP_FUNCTION(pdf_endpath)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_endpath(pdf);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto void pdf_fill(int pdfdoc)
* Fill the interior of the path with the current fill color. */
PHP_FUNCTION(pdf_fill)
{
zval **arg1;
PDF *pdf;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
PDF_fill(pdf);
RETURN_TRUE;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?