Ejemplo n.º 1
0
/* Fill a rectangle. */
int
gdev_pdf_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
			gx_color_index color)
{
    gx_device_pdf *pdev = (gx_device_pdf *) dev;
    int code;

    /* Make a special check for the initial fill with white, */
    /* which shouldn't cause the page to be opened. */
    if (color == pdev->white && !is_in_page(pdev))
	return 0;
    code = pdf_open_page(pdev, PDF_IN_STREAM);
    if (code < 0)
	return code;
    /* Make sure we aren't being clipped. */
    code = pdf_put_clip_path(pdev, NULL);
    if (code < 0)
	return code;
    pdf_set_pure_color(pdev, color, &pdev->saved_fill_color,
		       &pdev->fill_used_process_color,
		       &psdf_set_fill_color_commands);
    if (!pdev->HaveStrokeColor)
	pdev->saved_stroke_color = pdev->saved_fill_color;
    pprintd4(pdev->strm, "%d %d %d %d re f\n", x, y, w, h);
    return 0;
}
Ejemplo n.º 2
0
static int 
pdf_begin_transparency_group(gs_imager_state * pis, gx_device_pdf * pdev,
				const gs_pdf14trans_params_t * pparams)
{
    cos_dict_t *group_dict;
    bool in_page = is_in_page(pdev);
    const gs_state *gstate = gx_hld_get_gstate_ptr(pis);
    int code;

    if (gstate == NULL)
	return_error(gs_error_unregistered); /* Must not happen. */
    code = pdf_make_group_dict(pdev, pparams, pis, &group_dict);
    if (code < 0)
	return code;
    code = pdf_open_page(pdev, PDF_IN_STREAM);
    if (code < 0)
	return code;
    if (pdf_must_put_clip_path(pdev, gstate->clip_path)) {
	code = pdf_put_clip_path(pdev, gstate->clip_path);
	if (code < 0)
	    return code;
    }
    pdev->image_with_SMask = false;
    if (!in_page) 
	pdev->pages[pdev->next_page].group_id = group_dict->id;
    else if (pparams->image_with_SMask) {
	/* An internal group for the image implementation. 
	   See doimagesmask in gs/lib/pdf_draw.ps . 
	   Just set a flag for skipping pdf_end_transparency_group. */
	pdev->image_with_SMask = true;
    } else {
	pdf_resource_t *pres, *pres_gstate = NULL;

	code = pdf_prepare_drawing(pdev, pis, &pres_gstate);
	if (code < 0)
	    return code;
	code = pdf_end_gstate(pdev, pres_gstate);
	if (code < 0)
	    return code;
	code = pdf_enter_substream(pdev, resourceXObject, 
		gs_no_id, &pres, false, pdev->params.CompressPages);
	if (code < 0)
	    return code;
	return pdf_make_form_dict(pdev, pparams, pis, group_dict, (cos_dict_t *)pres->object);
    }
    return 0;
}