Exemplo n.º 1
0
void
pdf_puts(PDF *p, const char *s)
{
#ifdef PDFLIB_EBCDIC

    char buffer[LINEBUFLEN];

    strcpy(buffer, s);
    pdf_make_ascii(buffer);
    pdf_write(p, (void *) buffer, strlen(buffer));

#else

    pdf_write(p, (void *) s, strlen(s));

#endif	/* PDFLIB_EBCDIC */
}
Exemplo n.º 2
0
PDFLIB_API void PDFLIB_CALL
PDF_add_note(
    PDF *p,
    float llx,
    float lly,
    float urx,
    float ury,
    const char *contents,
    const char *title,
    const char *icon,
    int open)
{
    static const char fn[] = "PDF_add_note";
    pdf_annot *ann;

    PDF_TRACE(("%s\t(pdf[%p], %f, %f, %f, %f, \"%s\", \"%s\", \"%s\", %d);\n",
    	fn, (void *) p, llx, lly, urx, ury, contents, title, icon, open));

    if (PDF_SANITY_CHECK_FAILED(p))
	return;

    PDF_CHECK_SCOPE(p, fn, pdf_state_page);

    ann = (pdf_annot *) p->malloc(p, sizeof(pdf_annot), "pdf_add_note");

    ann->type	  = ann_text;
    ann->open	  = open;
    ann->rect.llx = llx;
    ann->rect.lly = lly;
    ann->rect.urx = urx;
    ann->rect.ury = ury;

    if (p->compatibility == PDF_1_2 && icon != NULL && *icon != '\0')
	pdf_error(p, PDF_RuntimeError,
		"Note icons are not supported in PDF 1.2");

    if (icon == NULL || *icon == '\0')
	ann->icon = icon_text_note;
    else if (!strcmp(icon, "comment"))
	ann->icon = icon_text_comment;
    else if (!strcmp(icon, "insert"))
	ann->icon = icon_text_insert;
    else if (!strcmp(icon, "note"))
	ann->icon = icon_text_note;
    else if (!strcmp(icon, "paragraph"))
	ann->icon = icon_text_paragraph;
    else if (!strcmp(icon, "newparagraph"))
	ann->icon = icon_text_newparagraph;
    else if (!strcmp(icon, "key"))
	ann->icon = icon_text_key;
    else if (!strcmp(icon, "help"))
	ann->icon = icon_text_help;
    else
	pdf_error(p, PDF_ValueError,
		"Unknown icon type '%s' for text note", icon);
	
    /* title may be NULL */
    if (title != NULL) {
	ann->title = pdf_strdup(p, title);
#ifdef PDFLIB_EBCDIC
	if (!pdf_is_unicode(ann->title))
	    pdf_make_ascii(ann->title);
#endif
    } else
	ann->title = NULL;

    /* It is legal to create an empty text annnotation */
    if (contents != NULL) {
	ann->contents = pdf_strdup(p, contents);
#ifdef PDFLIB_EBCDIC
	if (!pdf_is_unicode(ann->contents))
	    pdf_make_ascii(ann->contents);
#endif
    } else
	ann->contents = NULL;

    pdf_add_annot(p, ann);
}
Exemplo n.º 3
0
/* Attach an arbitrary file to the PDF. Note that the actual
 * embedding takes place in PDF_end_page().
 * description, author, and mimetype may be NULL.
 */
PDFLIB_API void PDFLIB_CALL
PDF_attach_file(
    PDF *p,
    float llx,
    float lly,
    float urx,
    float ury,
    const char *filename,
    const char *description,
    const char *author,
    const char *mimetype,
    const char *icon)
{
    static const char fn[] = "PDF_attach_file";
    pdf_annot *ann;

    PDF_TRACE(("%s\t(pdf[%p], %f, %f, %f, %f, ", fn, (void *) p,
	llx, lly, urx, ury));

    PDF_TRACE(("\"%s\", \"%s\", \"%s\", \"%s\", \"%s\");\n",
    	filename, description, author, mimetype, icon));

    if (PDF_SANITY_CHECK_FAILED(p))
	return;

    PDF_CHECK_SCOPE(p, fn, pdf_state_page);

    if (p->compatibility == PDF_1_2)
	pdf_error(p, PDF_RuntimeError,
		"File attachments are not supported in PDF 1.2");

    if (filename == NULL)
	pdf_error(p, PDF_ValueError, "Empty file name for file attachment");

    ann = (pdf_annot *) p->malloc(p, sizeof(pdf_annot),"PDF_attach_file");

    ann->type	  = ann_attach;
    ann->rect.llx = llx;
    ann->rect.lly = lly;
    ann->rect.urx = urx;
    ann->rect.ury = ury;

    if (icon == NULL)
	ann->icon = icon_file_pushpin;
    else if (!strcmp(icon, "graph"))
	ann->icon = icon_file_graph;
    else if (!strcmp(icon, "paperclip"))
	ann->icon = icon_file_paperclip;
    else if (!strcmp(icon, "pushpin"))
	ann->icon = icon_file_pushpin;
    else if (!strcmp(icon, "tag"))
	ann->icon = icon_file_tag;
    else
	pdf_error(p, PDF_ValueError, "Unknown icon type '%s'for embedded file",
			icon);

    ann->filename = (char *) pdf_strdup(p, filename);

    if (description != NULL) {
	ann->contents = (char *) pdf_strdup(p, description);
#ifdef PDFLIB_EBCDIC
	if (!pdf_is_unicode(ann->contents))
	    pdf_make_ascii(ann->contents);
#endif
    }

    if (author != NULL) {
	ann->title = (char *) pdf_strdup(p, author);
#ifdef PDFLIB_EBCDIC
	if (!pdf_is_unicode(ann->title))
	    pdf_make_ascii(ann->title);
#endif
    }

    if (mimetype != NULL)
	ann->mimetype = (char *) pdf_strdup(p, mimetype);

    pdf_add_annot(p, ann);
}