Beispiel #1
0
void
pdf__end_glyph(PDF *p)
{
    pdf_t3font *t3font = p->fonts[p->t3slot].t3font;
    pdf_t3glyph *glyph = &t3font->glyphs[t3font->curr_glyph];
    int ig = t3font->curr_glyph;

    if (t3font->pass != 1 && glyph->charproc_id != PDC_BAD_ID)
    {
        /* check whether pdf__save() and pdf__restore() calls are balanced */
        if (p->curr_ppt->sl > 0)
            pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0);

        pdf_end_text(p);
        pdc_end_pdfstream(p->out);              /* glyph description stream */
        pdc_end_obj(p->out);                    /* glyph description */

        pdc_put_pdfstreamlength(p->out, p->length_id);
    }

    PDF_SET_STATE(p, pdf_state_font);

    pdc_logg_cond(p->pdc, 1, trc_font,
        "\tEnd of Type3 font glyph \"%s\"\n",
        t3font->glyphs[ig].name);

    if (!p->pdc->smokerun)
        pdc_logg_cond(p->pdc, 1, trc_api, "[End glyph %d]\n", ig);
}
Beispiel #2
0
void
pdf_write_colormap(PDF *p, int slot)
{
    PDF_data_source src;
    pdf_colorspace *cs, *base;
    pdc_id length_id;

    cs   = &p->colorspaces[slot];

    if (cs->type != Indexed || cs->val.indexed.colormap_done == pdc_true)
	return;

    base = &p->colorspaces[cs->val.indexed.base];

    pdc_begin_obj(p->out, cs->val.indexed.colormap_id);	/* colormap object */
    pdc_begin_dict(p->out);

    if (pdc_get_compresslevel(p->out))
	pdc_puts(p->out, "/Filter/FlateDecode\n");

    /* Length of colormap object */
    length_id = pdc_alloc_id(p->out);
    pdc_objref(p->out, "/Length", length_id);
    pdc_end_dict(p->out);

    src.init		= NULL;
    src.fill		= pdf_data_source_buf_fill;
    src.terminate	= NULL;

    src.buffer_start	= (unsigned char *) cs->val.indexed.colormap;

    src.buffer_length = (size_t) (cs->val.indexed.palette_size *
				pdf_color_components(p, cs->val.indexed.base));

    src.bytes_available = 0;
    src.next_byte	= NULL;

    /* Write colormap data */
    pdf_copy_stream(p, &src, pdc_true);	/* colormap data */

    pdc_end_obj(p->out);				/* colormap object */

    pdc_put_pdfstreamlength(p->out, length_id);

    /* free the colormap now that it's written */
    pdc_free(p->pdc, cs->val.indexed.colormap);
    cs->val.indexed.colormap = NULL;
    cs->val.indexed.colormap_done = pdc_true;
} /* pdf_write_colormap */
Beispiel #3
0
void
pdf__end_glyph(PDF *p)
{
    PDF_SET_STATE(p, pdf_state_font);

    /* check whether pdf__save() and pdf__restore() calls are balanced */
    if (p->sl > 0)
        pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0);

    pdf_end_text(p);
    p->contents = c_none;

    pdc_end_pdfstream(p->out);                  /* glyph description stream */
    pdc_end_obj(p->out);                        /* glyph description */

    pdc_put_pdfstreamlength(p->out, p->length_id);
}
Beispiel #4
0
/* Finish the pattern definition. */
void
pdf__end_pattern(PDF *p)
{
    /* check whether pdf__save() and pdf__restore() calls are balanced */
    if (p->curr_ppt->sl > 0)
	pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0);

    pdf_end_text(p);
    pdc_end_pdfstream(p->out);
    pdc_end_obj(p->out);			/* pattern */

    pdc_put_pdfstreamlength(p->out, p->length_id);

    pdc_begin_obj(p->out, p->res_id);		/* Resource object */
    pdc_begin_dict(p->out);			/* Resource dict */

    pdf_write_page_fonts(p);			/* Font resources */

    pdf_write_page_colorspaces(p);		/* Color space resources */

    pdf_write_page_pattern(p);			/* Pattern resources */

    pdf_write_xobjects(p);			/* XObject resources */

    pdf_write_page_extgstates(p);		/* ExtGState resources */

    pdc_end_dict(p->out);			/* resource dict */
    pdc_end_obj(p->out);			/* resource object */

    pdf_pg_resume(p, -1);

    if (p->flush & pdc_flush_content)
	pdc_flush_stream(p->out);

    if (!p->pdc->smokerun)
        pdc_logg_cond(p->pdc, 1, trc_api, "[End pattern %d]\n",
                      p->pattern_number -1);
}