Ejemplo n.º 1
0
void export_image(const Array<T>& x, std::string filename, double winMin, double winMax, colormap cm)
{
  auto y = colorize<T>(x, winMin, winMax, cm);

  cairo_surface_t *surface;
  cairo_t *cr;

  bool png = false;
  if(filename.substr(filename.find_last_of(".") + 1) == "png")
    png = true;

  if(png)
    surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, y.shape(1), y.shape(0));
  else
    surface = cairo_pdf_surface_create(filename.c_str(), y.shape(1), y.shape(0));

  cr = cairo_create(surface);

  cairo_surface_t *image;

  image = cairo_image_surface_create_for_data((unsigned char*) y.data(),
                                              CAIRO_FORMAT_ARGB32, shape(y,1), shape(y,0), shape(y,1) * sizeof(int32_t));

  //cairo_scale (cr, 256.0/w, 256.0/h);

  cairo_set_source_surface (cr, image, 0, 0);
  cairo_paint (cr);

  cairo_surface_destroy (image);

  if(png)
  {
    cairo_surface_flush(surface);
    cairo_surface_write_to_png(surface, filename.c_str());
  } else
  {
    cairo_show_page(cr);
  }

  cairo_surface_destroy(surface);
  cairo_destroy(cr);

}
Ejemplo n.º 2
0
void T2PPage::print()
// Prints the page.
{
  // White background.
  cairo_set_source_rgb(cairo, 1.0, 1.0, 1.0);
  cairo_paint(cairo);

  // Headers.
  if (text_reference_area->has_content()) {
    header_reference_area->print(number, print_date, text_reference_area->left_running_header(), text_reference_area->right_running_header(), text_reference_area->suppress_headers(), text_reference_area->left_running_first_chapter(), text_reference_area->left_running_last_chapter(), text_reference_area->right_running_first_chapter(), text_reference_area->right_running_last_chapter());
  }
  // Print the reference areas.
  header_reference_area->print();
  text_reference_area->print();
  footer_reference_area->print();

  // Output this page.
  cairo_show_page(cairo);
}
Ejemplo n.º 3
0
cairo_status_t
_cairo_boilerplate_svg_finish_surface (cairo_surface_t		*surface)
{
    svg_target_closure_t *ptc = cairo_surface_get_user_data (surface,
	                                                     &svg_closure_key);
    cairo_status_t status;

    /* Both surface and ptc->target were originally created at the
     * same dimensions. We want a 1:1 copy here, so we first clear any
     * device offset on surface.
     *
     * In a more realistic use case of device offsets, the target of
     * this copying would be of a different size than the source, and
     * the offset would be desirable during the copy operation. */
    cairo_surface_set_device_offset (surface, 0, 0);

    if (ptc->target) {
	cairo_t *cr;
	cr = cairo_create (ptc->target);
	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint (cr);
	cairo_show_page (cr);
	status = cairo_status (cr);
	cairo_destroy (cr);

	if (status)
	    return status;

	cairo_surface_finish (surface);
	status = cairo_surface_status (surface);
	if (status)
	    return status;

	surface = ptc->target;
    }

    cairo_surface_finish (surface);
    status = cairo_surface_status (surface);
    if (status)
	return status;

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 4
0
int
main (void)
{
    cairo_test_context_t ctx;
    cairo_t *cr;
    const char *filename = "svg-surface.svg";
    cairo_surface_t *surface;

    cairo_test_init (&ctx, "svg-surface");
    if (! (cairo_test_is_target_enabled (&ctx, "svg11") ||
	   cairo_test_is_target_enabled (&ctx, "svg12")))
    {
	cairo_test_fini (&ctx);
	return CAIRO_TEST_UNTESTED;
    }

    surface = cairo_svg_surface_create (filename,
					WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
    if (cairo_surface_status (surface)) {
	cairo_test_log (&ctx,
			"Failed to create svg surface for file %s: %s\n",
			filename,
			cairo_status_to_string (cairo_surface_status (surface)));
	cairo_test_fini (&ctx);
	return CAIRO_TEST_FAILURE;
    }

    cr = cairo_create (surface);

    draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);

    cairo_show_page (cr);

    cairo_destroy (cr);
    cairo_surface_destroy (surface);

    printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");

    cairo_test_fini (&ctx);

    return CAIRO_TEST_SUCCESS;
}
Ejemplo n.º 5
0
static void cairogen_end_page(GVJ_t * job)
{
    cairo_t *cr = (cairo_t *) job->context;
    cairo_surface_t *surface;
    cairo_status_t status;

    switch (job->render.id) {

#ifdef CAIRO_HAS_PNG_FUNCTIONS
    case FORMAT_PNG:
        surface = cairo_get_target(cr);
	cairo_surface_write_to_png_stream(surface, writer, job);
	break;
#endif

    case FORMAT_PS:
    case FORMAT_PDF:
    case FORMAT_SVG:
	cairo_show_page(cr);
	surface = cairo_surface_reference(cairo_get_target(cr));
	cairo_surface_finish(surface);
	status = cairo_surface_status(surface);
	cairo_surface_destroy(surface);
	if (status != CAIRO_STATUS_SUCCESS)
	    fprintf(stderr, "cairo: %s\n", cairo_status_to_string(status));
	break;

    case FORMAT_CAIRO:
    default:
        surface = cairo_get_target(cr);
        if (cairo_image_surface_get_width(surface) == 0 || cairo_image_surface_get_height(surface) == 0) {
	    /* apparently cairo never allocates a surface if nothing was ever written to it */
/* but suppress this error message since a zero area surface seems to happen during normal operations, particular in -Tx11
	    fprintf(stderr, "ERROR: cairo surface has zero area, this may indicate some problem during rendering shapes.\n");
 - jce */
	}
	job->imagedata = (char *)(cairo_image_surface_get_data(surface));	
	break;
       	/* formatting will be done by gvdevice_format() */
    }
}
Ejemplo n.º 6
0
Archivo: svg.c Proyecto: 4179e1/misc
int main (void)
{
	cairo_surface_t *surface;
	cairo_t *cr;

	surface = cairo_svg_surface_create ("image.svg", 504, 648);
	cr = cairo_create (surface);

	cairo_set_source_rgb (cr, 0, 0, 0);
	cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, 40.0);

	cairo_move_to (cr, 10.0, 50.0);
	cairo_show_text (cr, "Hello world!");

	cairo_show_page (cr);

	cairo_surface_destroy (surface);
	cairo_destroy (cr);

	return 0;
}
Ejemplo n.º 7
0
void Shape::Render(const char *path){
  if(geom_ == NULL) return;
  cairo_surface_t *surface = cairo_ps_surface_create(path, width_, height_);
  if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
    std::cout << cairo_status_to_string(cairo_surface_status(surface)) << std::endl;
    exit(1);
    return;
  }

  ctx_ = cairo_create(surface);

  OGREnvelope env;
  geom_->getEnvelope(&env);
  cairo_matrix_t mat;
  matrix_init(&mat, width_, height_, &env);
  cairo_set_matrix(ctx_, &mat);

  Dispatch(geom_);

  cairo_show_page(ctx_);
  cairo_destroy(ctx_);
  cairo_surface_destroy(surface);
}
Ejemplo n.º 8
0
void gt_graphics_cairo_save_to_stream(const GtGraphics *gg, GtStr *stream)
{
  const GtGraphicsCairo *g = (const GtGraphicsCairo*) gg;
  GT_UNUSED cairo_status_t rval;
  cairo_surface_t *bgsurf = NULL;
  cairo_t *bgc = NULL;
  gt_assert(g && stream);

  /* do nothing if no surface was created */
  if (g->from_context)
    return;
  switch (g->type)
  {
    case GT_GRAPHICS_PNG:
      /* blend rendered image with background color */
      bgsurf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, g->width,
                                          g->height);
      bgc = cairo_create(bgsurf);
      cairo_set_source_rgba(bgc, g->bg_color.red, g->bg_color.green,
                                 g->bg_color.blue, g->bg_color.alpha);
      cairo_paint(bgc);
      cairo_set_source_surface(bgc, g->surf, 0, 0);
      cairo_paint(bgc);
      rval = cairo_surface_write_to_png_stream(bgsurf, str_write_func, stream);
      gt_assert(rval == CAIRO_STATUS_SUCCESS); /* str_write_func() is sane */
      cairo_destroy(bgc);
      cairo_surface_destroy(bgsurf);
      break;
    default:
      cairo_show_page(g->cr);
      cairo_surface_flush(g->surf);
      cairo_surface_finish(g->surf);
      gt_str_reset(stream);
      gt_str_append_str(stream, g->outbuf);
      gt_assert(gt_str_length(stream) > 0);
  }
}
/* The only reason we go through all these machinations to write a PNG
 * image is to _really ensure_ that the data actually landed in our
 * buffer through the paginated surface to the test_paginated_surface.
 *
 * If we didn't implement this function then the default
 * cairo_surface_write_to_png would result in the paginated_surface's
 * acquire_source_image function replaying the meta-surface to an
 * intermediate image surface. And in that case the
 * test_paginated_surface would not be involved and wouldn't be
 * tested.
 */
cairo_status_t
_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
						        const char	*filename)
{
    cairo_surface_t *image;
    cairo_format_t format;
    test_paginated_closure_t *tpc;
    cairo_status_t status;

    /* show page first.  the automatic show_page is too late for us */
    /* XXX use cairo_surface_show_page() when that's added */
    cairo_t *cr = cairo_create (surface);
    cairo_show_page (cr);
    cairo_destroy (cr);

    tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);

    format = cairo_boilerplate_format_from_content (tpc->content);

    image = cairo_image_surface_create_for_data (tpc->data,
						 format,
						 tpc->width,
						 tpc->height,
						 tpc->stride);

    status = cairo_surface_write_to_png (image, filename);
    if (status) {
	CAIRO_BOILERPLATE_LOG ("Error writing %s: %s. Exiting\n",
			       filename,
			       cairo_status_to_string (status));
	exit (1);
    }

    cairo_surface_destroy (image);

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 10
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam        values[1];
  GimpPDBStatusType       status = GIMP_PDB_SUCCESS;
  GimpRunMode             run_mode;

  /* Plug-in variables */
  gboolean                single_image;
  gboolean                defaults_proc;

  /* Plug-In variables */
  cairo_surface_t        *pdf_file;
  cairo_t                *cr;
  GimpExportCapabilities  capabilities;

  guint32                 i = 0;
  gint32                  j = 0;

  gdouble                 x_res, y_res;
  gdouble                 x_scale, y_scale;

  gint32                  image_id;
  gboolean                exported;
  GimpImageBaseType       type;

  gint32                  temp;

  gint                   *layers;
  gint32                  num_of_layers;
  GimpDrawable           *layer;
  cairo_surface_t        *layer_image;
  gdouble                 opacity;
  gint                    x, y;
  GimpRGB                 layer_color;
  gboolean                single_color;

  gint32                  mask_id = -1;
  GimpDrawable           *mask = NULL;
  cairo_surface_t        *mask_image = NULL;
  FILE                   *fp;

  INIT_I18N ();

  /* Setting mandatory output values */
  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  /* Initializing all the settings */
  multi_page.image_count = 0;

  if (! init_vals (name, nparams, param, &single_image,
             &defaults_proc, &run_mode))
    {
      values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
      return;
    }

  /* Starting the executions */
  if (run_mode == GIMP_RUN_INTERACTIVE)
    {
      if (single_image)
        {
          if (! gui_single ())
            {
              values[0].data.d_status = GIMP_PDB_CANCEL;
              return;
            }
        }
      else if (! gui_multi ())
        {
          values[0].data.d_status = GIMP_PDB_CANCEL;
          return;
        }

      if (file_name == NULL)
        {
          values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
          gimp_message (_("You must select a file to save!"));
          return;
        }
    }

  fp = g_fopen (file_name, "wb");
  pdf_file = cairo_pdf_surface_create_for_stream (write_func, fp, 1, 1);
  if (cairo_surface_status (pdf_file) != CAIRO_STATUS_SUCCESS)
    {
      char *str = g_strdup_printf
        (_("An error occured while creating the PDF file:\n"
           "%s\n"
           "Make sure you entered a valid filename and that the selected location isn't read only!"),
         cairo_status_to_string (cairo_surface_status (pdf_file)));

      gimp_message (str);
      g_free (str);

      values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
      return;
    }
  cr = cairo_create (pdf_file);

  capabilities = GIMP_EXPORT_CAN_HANDLE_RGB | GIMP_EXPORT_CAN_HANDLE_ALPHA |
    GIMP_EXPORT_CAN_HANDLE_GRAY | GIMP_EXPORT_CAN_HANDLE_LAYERS |
    GIMP_EXPORT_CAN_HANDLE_INDEXED;
  if (optimize.apply_masks)
    capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS;

  for (i = 0; i < multi_page.image_count; i++)
    {
      /* Save the state of the surface before any changes, so that settings
       * from one page won't affect all the others */
      cairo_save (cr);

      image_id =  multi_page.images[i];

      /* We need the active layer in order to use gimp_image_export */
      temp = gimp_image_get_active_drawable (image_id);
      if (temp == -1)
        exported = gimp_export_image (&image_id, &temp, NULL, capabilities) == GIMP_EXPORT_EXPORT;
      else
        exported = FALSE;
      type = gimp_image_base_type (image_id);

      gimp_image_get_resolution (image_id, &x_res, &y_res);
      x_scale = 72.0 / x_res;
      y_scale = 72.0 / y_res;

      cairo_pdf_surface_set_size (pdf_file,
                                  gimp_image_width (image_id) * x_scale,
                                  gimp_image_height (image_id) * y_scale);

      /* This way we set how many pixels are there in every inch.
       * It's very important for PangoCairo */
      cairo_surface_set_fallback_resolution (pdf_file, x_res, y_res);

      /* PDF is usually 72 points per inch. If we have a different resolution,
       * we will need this to fit our drawings */
      cairo_scale (cr, x_scale, y_scale);

      /* Now, we should loop over the layers of each image */
      layers = gimp_image_get_layers (image_id, &num_of_layers);

      for (j = 0; j < num_of_layers; j++)
        {
          layer = gimp_drawable_get (layers [num_of_layers-j-1]);
          opacity = gimp_layer_get_opacity (layer->drawable_id)/100.0;

          /* Gimp doesn't display indexed layers with opacity below 50%
           * And if it's above 50%, it will be rounded to 100% */
          if (type == GIMP_INDEXED)
            {
              if (opacity <= 0.5)
                opacity = 0.0;
              else
                opacity = 1.0;
            }

          if (gimp_item_get_visible (layer->drawable_id)
              && (! optimize.ignore_hidden || (optimize.ignore_hidden && opacity > 0.0)))
            {
              mask_id = gimp_layer_get_mask (layer->drawable_id);
              if (mask_id != -1)
                {
                  mask = gimp_drawable_get (mask_id);
                  mask_image = get_drawable_image (mask);
                }

              gimp_drawable_offsets (layer->drawable_id, &x, &y);

              /* For raster layers */
              if (!gimp_item_is_text_layer (layer->drawable_id))
                {
                  layer_color = get_layer_color (layer, &single_color);
                  cairo_rectangle (cr, x, y, layer->width, layer->height);

                  if (optimize.vectorize && single_color)
                    {
                      cairo_set_source_rgba (cr, layer_color.r, layer_color.g, layer_color.b, layer_color.a * opacity);
                      if (mask_id != -1)
                        cairo_mask_surface (cr, mask_image, x, y);
                      else
                        cairo_fill (cr);
                    }
                  else
                    {
                      cairo_clip (cr);
                      layer_image = get_drawable_image (layer);
                      cairo_set_source_surface (cr, layer_image, x, y);
                      cairo_push_group (cr);
                      cairo_paint_with_alpha (cr, opacity);
                      cairo_pop_group_to_source (cr);
                      if (mask_id != -1)
                        cairo_mask_surface (cr, mask_image, x, y);
                      else
                        cairo_paint (cr);
                      cairo_reset_clip (cr);

                      cairo_surface_destroy (layer_image);
                    }
                }
              /* For text layers */
              else
                {
                  drawText (layer, opacity, cr, x_res, y_res);
                }
            }

          /* We are done with the layer - time to free some resources */
          gimp_drawable_detach (layer);
          if (mask_id != -1)
            {
              gimp_drawable_detach (mask);
              cairo_surface_destroy (mask_image);
            }
        }
      /* We are done with this image - Show it! */
      cairo_show_page (cr);
      cairo_restore (cr);

      if (exported)
        gimp_image_delete (image_id);
    }

  /* We are done with all the images - time to free the resources */
  cairo_surface_destroy (pdf_file);
  cairo_destroy (cr);

  fclose (fp);
  /* Finally done, let's save the parameters */
  gimp_set_data (DATA_OPTIMIZE, &optimize, sizeof (optimize));
  if (!single_image)
    {
      g_strlcpy (multi_page.file_name, file_name, MAX_FILE_NAME_LENGTH);
      gimp_set_data (DATA_IMAGE_LIST, &multi_page, sizeof (multi_page));
    }

}
Ejemplo n.º 11
0
Archivo: result.cpp Proyecto: nodag/psa
void SaveSummary(const std::string &fname, Result &result, Config &config)
{
    const float fnorm = 2.f / sqrtf(result.npoints);
    const float rnorm = 1.f / sqrtf(2.f / (SQRT3 * result.npoints));
    
    const int csize = 512;  // Composition cell size
    const double dashes[] = { 6.0, 3.0 };
    
    cairo_surface_t *surface =
    cairo_pdf_surface_create(fname.c_str(), 2*csize, 1.5*csize);
    cairo_pdf_surface_restrict_to_version(surface, CAIRO_PDF_VERSION_1_4);
    
    cairo_t *cr = cairo_create(surface);
    unsigned char *imgdata = NULL;
    cairo_surface_t *image = NULL;
    
    // Draw points
    const float radius = 2.0;
    cairo_identity_matrix(cr);
    cairo_set_source_rgba(cr, 0, 0, 0, 1);
    for (int i = 0; i < result.points.size(); ++i) {
        float x = result.points[i].x * csize;
        float y = (1.f - result.points[i].y) * csize;
        cairo_arc(cr, x, y, radius, 0, TWOPI);
        cairo_fill(cr);
    }
    
    // Draw radial power reference level
    cairo_identity_matrix(cr);
    cairo_set_source_rgba(cr, 0.6, 0.6, 0.6, 1);
    cairo_set_line_width(cr, 1.0);
    cairo_set_dash(cr, dashes, 2, 0);
    const float rpref = 1.f - (1.f - config.fymin) / (config.fymax - config.fymin);
    cairo_move_to(cr,   csize, csize + rpref*csize/2);
    cairo_line_to(cr, 2*csize, csize + rpref*csize/2);
    cairo_stroke(cr);
    
    // Draw radial power
    cairo_identity_matrix(cr);
    cairo_set_source_rgba(cr, 0, 0, 0, 1);
    cairo_set_line_width(cr, 1.0);
    cairo_set_dash(cr, NULL, 0, 0);
    for (int i = 0; i < result.rp.size(); ++i) {
        float x = i / (float) result.rp.size();
        float y = 1.f - (result.rp[i] - config.fymin) / (config.fymax - config.fymin);
        Clamp01(y);
        if (i == 0)
            cairo_move_to(cr, csize + x*csize, csize + y*csize/2);
        else
            cairo_line_to(cr, csize + x*csize, csize + y*csize/2);
    }
    cairo_stroke(cr);
    
    // Draw spectrum
    int stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24,
                                               result.spectrum.width);
    result.spectrum.GetRGBA(imgdata);
    image = cairo_image_surface_create_for_data(imgdata, CAIRO_FORMAT_RGB24,
                                                result.spectrum.width,
                                                result.spectrum.height,
                                                stride);
    cairo_identity_matrix(cr);
    cairo_translate(cr, csize, 0);
    cairo_scale(cr, csize / (float) result.spectrum.width,
                    csize / (float) result.spectrum.height);
    cairo_set_source_surface(cr, image, 0, 0);
    cairo_paint(cr);
    
    // Draw RDF reference level
    cairo_identity_matrix(cr);
    cairo_set_source_rgba(cr, 0.6, 0.6, 0.6, 1);
    cairo_set_line_width(cr, 1.0);
    cairo_set_dash(cr, dashes, 2, 0);
    const float rdfref = 1.f - (1.f - config.rymin) / (config.rymax - config.rymin);
    cairo_move_to(cr, 0, csize + rdfref*csize/2);
    cairo_line_to(cr, csize, csize + rdfref*csize/2);
    cairo_stroke(cr);
    
    // Draw RDF
    cairo_identity_matrix(cr);
    cairo_set_source_rgba(cr, 0, 0, 0, 1);
    cairo_set_line_width(cr, 1.0);
    cairo_set_dash(cr, NULL, 0, 0);
    for (int i = 0; i < result.rdf.size(); ++i) {
        float x = i / (float) result.rdf.size();
        float y = 1.f - (result.rdf[i] - config.rymin) / (config.rymax - config.rymin);
        Clamp01(y);
        if (i == 0)
            cairo_move_to(cr, x*csize, csize + y*csize/2);
        else
            cairo_line_to(cr, x*csize, csize + y*csize/2);
    }
    cairo_stroke(cr);
    
    // Draw separators
    cairo_identity_matrix(cr);
    cairo_set_line_width(cr, 1.0);
    cairo_set_source_rgba(cr, 0, 0, 0, 1);
    cairo_move_to(cr, 0, csize);
    cairo_line_to(cr, 2*csize, csize);
    cairo_stroke(cr);
    cairo_move_to(cr, csize, 0);
    cairo_line_to(cr, csize, 1.5*csize);
    cairo_stroke(cr);
    
    // Draw labels
    cairo_identity_matrix(cr);
    cairo_set_font_size(cr, 12.0);
    cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
                           CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_source_rgba(cr, 0, 0, 0, 1);
    cairo_move_to(cr, 0.0125 * csize, 1.025 * csize);
    cairo_show_text(cr, "RDF");
    cairo_stroke(cr);
    cairo_move_to(cr, 1.0125 * csize, 1.025 * csize);
    cairo_show_text(cr, "Power Spectrum");
    cairo_stroke(cr);
    
    // Draw stats box
#ifdef PSA_HAS_CGAL
    int nlines = 5;
#else
    int nlines = 4;
#endif
    nlines += (result.nsets > 1);
    double offset = 0.03;
    double bsize[] = { 0.33 * csize, (nlines * offset + 0.01) * csize };
    double banchor = 0.0125 * csize;
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.7);
    cairo_rectangle(cr, banchor, banchor, bsize[0], bsize[1]);
    cairo_fill(cr);
    
    // Draw stats and corresponding labels
    cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);
    cairo_set_font_size(cr, 12.0);
    cairo_select_font_face(cr, "monospace", CAIRO_FONT_SLANT_NORMAL,
                           CAIRO_FONT_WEIGHT_NORMAL);
    const int len = 128;
    char label[len];
    double tanchor[2] = { 1.75 * banchor, 0.9 * banchor };
    
    int i = 1;
    if (result.nsets > 1) {
        snprintf(label, len, "Averaged over %d sets", result.nsets);
        cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize);
        cairo_show_text(cr, label);
        ++i;
    }
    snprintf(label, len, "Gbl. Mindist   %.5f", result.stats.mindist * rnorm);
    cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize); ++i;
    cairo_show_text(cr, label);
    snprintf(label, len, "Avg. Mindist   %.5f", result.stats.avgmindist * rnorm);
    cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize); ++i;
    cairo_show_text(cr, label);
#ifdef PSA_HAS_CGAL
    snprintf(label, len, "Orient. order  %.5f", result.stats.orientorder);
    cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize); ++i;
    cairo_show_text(cr, label);
#endif
    snprintf(label, len, "Eff. Nyquist   %.5f", result.stats.effnyquist * fnorm);
    cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize); ++i;
    cairo_show_text(cr, label);
    snprintf(label, len, "Oscillations   %.5f", result.stats.oscillations);
    cairo_move_to(cr, tanchor[0], tanchor[1] + i * offset * csize); ++i;
    cairo_show_text(cr, label);

    cairo_stroke(cr);
    
    // Save and clean up
    cairo_show_page(cr);
    cairo_surface_destroy(image);
    if (imgdata) delete[] imgdata;
    cairo_destroy(cr);
    cairo_surface_destroy(surface);
}
static cairo_status_t
_cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface,
							const char	*filename)
{
    win32_target_closure_t *ptc = cairo_surface_get_user_data (surface, &win32_closure_key);
    char command[4096];
    cairo_surface_t *src_image, *dst_image;
    cairo_t *cr;
    cairo_status_t status;

    /* Both surface and ptc->target were originally created at the
     * same dimensions. We want a 1:1 copy here, so we first clear any
     * device offset on surface.
     *
     * In a more realistic use case of device offsets, the target of
     * this copying would be of a different size than the source, and
     * the offset would be desirable during the copy operation. */
    cairo_surface_set_device_offset (surface, 0, 0);

    if (ptc->target) {
	cairo_t *cr;
	cr = cairo_create (ptc->target);
	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint (cr);
	cairo_show_page (cr);
	cairo_destroy (cr);

	cairo_surface_finish (surface);
	surface = ptc->target;
    }

    cairo_surface_finish (surface);
    EndPage (ptc->dc);
    EndDoc (ptc->dc);
    sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
	     ptc->width + ptc->left_margin, ptc->height + ptc->bottom_margin, filename, ptc->filename);

    if (system (command) != 0)
	return CAIRO_STATUS_WRITE_ERROR;

    /* Create a new image from the ghostscript image that has the
     * left and bottom margins removed */

    src_image = cairo_image_surface_create_from_png (filename);
    status = cairo_surface_status (src_image);
    if (status)
	return status;

    dst_image = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
					    ptc->width,
					    ptc->height);
    cr = cairo_create (dst_image);
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_surface (cr, src_image, -ptc->left_margin, 0);
    cairo_paint (cr);
    cairo_destroy (cr);

    cairo_surface_write_to_png (dst_image, filename);
    status = cairo_surface_status (dst_image);
    if (status)
	return status;

    cairo_surface_destroy (src_image);
    cairo_surface_destroy (dst_image);

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 13
0
	void lime_cairo_show_page (double handle) {
		
		cairo_show_page ((cairo_t*)(intptr_t)handle);
		
	}
Ejemplo n.º 14
0
void cairo_context::show_page()
{
    cairo_show_page(cairo_.get());
    check_object_status_and_throw_exception(*this);
}
Ejemplo n.º 15
0
void Context::showPage()
{
	cairo_show_page( mCairo );
}
Ejemplo n.º 16
0
int log2pdf(log2pdf_params *p) {

	/** First of all, we read the entire map into memory */
	FILE *input_file = open_file_for_reading(p->input_filename);
	if(!input_file) return 0;
	
	LDP*scans; int nscans;
	
	if(!ld_read_some_scans_distance(input_file,  &scans, &nscans,
		 p->use_reference, p->distance_xy, deg2rad(p->distance_th_deg) ) ){
		sm_error("Could not read map from file '%s'.\n", p->input_filename); 
		return 0;
	}
	
	if(nscans == 0) {
		sm_error("I could not read any scan from file '%s'.\n", p->input_filename);
		return 0;
	}
	
	sm_debug("Read map: %d scans in total.\n", nscans);

	/** Let's find the bounding box for the map */
	double bb_min[2], bb_max[2];
	double offset[3] = {0,0,0};
	lda_get_bounding_box(scans, nscans, bb_min, bb_max, offset, p->use_reference, p->laser.horizon);
	
	bb_min[0] -= p->padding;
	bb_min[1] -= p->padding;
	bb_max[0] += p->padding;
	bb_max[1] += p->padding;
	

	sm_debug("Bounding box: %f %f -- %f %f.\n", bb_min[0], bb_min[1],
		bb_max[0], bb_max[1]);

		
	/* Create PDF surface and setup paper size and transformations */
	int max_width_points = p->dimension;
	int max_height_points = p->dimension;
	cairo_surface_t *surface;
	cairo_t *cr;

	if(!create_pdf_surface(p->output_filename, max_width_points, max_height_points, 
		bb_min, bb_max, &surface, &cr)) return 0;

	/* Draw pose path */
	if(p->pose_path.draw) {
		cairo_save(cr);
		
		cr_set_style(cr, &(p->pose_path));
		cr_lda_draw_pose_path(cr, scans, nscans, p->use_reference);

		if(nscans > 0 && p->laser.pose.draw) {
			cairo_set_source_rgb(cr, 0.3, 0.0, 1.0);
			double *pose0 = ld_get_reference_pose(scans[0], p->use_reference);
			cairo_arc(cr, pose0[0], pose0[1], p->start_pose_width, 0.0, 2*M_PI);
			cairo_fill(cr);
		}

		cairo_restore(cr);
	}

	/* Draw map */
	int k; for(k=0;k<nscans;k++) {
		LDP ld = scans[k];
		double *pose = ld_get_reference_pose(ld, p->use_reference);
		if(!pose) continue;
		
		double offset[3] = {0,0, deg2rad(p->offset_theta_deg) };
		double world_pose[3];
		oplus_d(offset, pose, world_pose);
				
		cairo_save(cr);
		cr_set_reference(cr, world_pose);
		cr_ld_draw(cr, ld, &(p->laser));
		cairo_restore(cr);
	}

	cairo_show_page (cr);

	cairo_destroy (cr);
	cairo_surface_destroy (surface);
	return 1;
}
Ejemplo n.º 17
0
int main() {
    json_t *root;
    json_error_t error;
    root = json_load_file("../test.json", 0, &error);
    if(root == 0){
        printf("ERRO AO LER ARQUIVO, linha %d!\n", error.line);
        return error.line;
    }
    const char * fileName = JSON_getString(root, "fileName");
    printf("O nome do arquivo é: %s\n", fileName); 
    const char * format = JSON_getString(root, "format");
    if(strcmp(format, "png") != 0 && strcmp(format, "pdf") != 0 ){
        printf("Formato: o formato %s não é  suportado!\n", format);
        return 0;
    }
    printf("O formato é: %s\n", JSON_getString(root, "format"));
    const char * name = JSON_getString(root, "name");
    printf("O titulo do grafico é: %s\n", name);
    int width = JSON_getInt(root, "width");
    if(width < 200 || width > 1000){
        printf("Width: medida não suportada!\n");
        return 0;
    }
    printf("Width: %d\n", width);
    int height = JSON_getInt(root, "height");
    if(height < 200 || height > 1000){
        printf("Height: medida não suportada!\n");
        return 0;
    }
    printf("Height: %d\n", height);
    int type = JSON_getInt(root, "type");
    printf("Type: %d\n", type);
    double aux;
    //aux = height/width;
    if(height>width) aux = (width/200);
    else aux = (height/200);   
            
    cairo_surface_t *surface; 
    if(strcmp(format, "png") == 0){
 	    surface =   	
	    cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
    }
    else{
        surface =
        cairo_pdf_surface_create(fileName, width, height);
    }
    cairo_t *context = cairo_create(surface);

    cairo_set_source_rgba(context, 1, 1, 1, 1);
    cairo_rectangle(context, 0, 0, width, height);
    cairo_fill(context);        

    Color pointColor = JSON_getColor(root);
    Point *points = JSON_getPoints(root);
    if(type == 0 || type == 1) create_point(context, points, width, height, type, aux, pointColor); 
    
    if (type==2) {
        draw_area(context, points, width, height, aux, pointColor);
        create_point(context, points, width, height, type, aux, pointColor);
    }
    
    draw_line(context, points, width, height, type, aux, pointColor);
    
    write_text(context, name, width, height, aux, pointColor);

    if(strcmp(JSON_getString(root, "format"), "png") == 0)	cairo_surface_write_to_png(surface, fileName);
    else cairo_show_page(context); 
    	
    cairo_destroy(context);
    cairo_surface_destroy(surface);
    
        
    return 0;
}
Ejemplo n.º 18
0
EXPORT void slate_cairo_paint(cairo_t* c) {

  cairo_show_page(c);


}
Ejemplo n.º 19
0
int
main (void)
{
    cairo_test_context_t ctx;
    cairo_surface_t *surface;
    cairo_t *cr;
    cairo_status_t status;
    const char *filename;
    size_t i;
    char dsc[255];

    cairo_test_init (&ctx, "ps-features");
    if (! cairo_test_is_target_enabled (&ctx, "ps")) {
	cairo_test_fini (&ctx);
	return CAIRO_TEST_UNTESTED;
    }

    filename = "ps-features.ps";

    /* We demonstrate that the initial size doesn't matter (we're
     * passing 0,0), if we use cairo_ps_surface_set_size on the first
     * page. */
    surface = cairo_ps_surface_create (filename, 0, 0);

    cairo_ps_surface_dsc_comment (surface, "%%Title: ps-features");
    cairo_ps_surface_dsc_comment (surface, "%%Copyright: Copyright (C) 2006 Red Hat, Inc.");

    cairo_ps_surface_dsc_begin_setup (surface);
    cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *PageSize letter");
    cairo_ps_surface_dsc_comment (surface, "%%IncludeFeature: *MediaColor White");

    cr = cairo_create (surface);

    cairo_select_font_face (cr, "Bitstream Vera Sans",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, TEXT_SIZE);

    for (i=0; i < ARRAY_SIZE(pages); i++) {
	cairo_ps_surface_set_size (surface,
				   pages[i].width_in_points,
				   pages[i].height_in_points);
	cairo_ps_surface_dsc_begin_page_setup (surface);
	snprintf (dsc, 255, "%%IncludeFeature: *PageSize %s", pages[i].page_size_alias);
	cairo_ps_surface_dsc_comment (surface, dsc);
	if (i % 2) {
	    snprintf (dsc, 255, "%%IncludeFeature: *MediaType Glossy");
	    cairo_ps_surface_dsc_comment (surface, dsc);
	}

	cairo_move_to (cr, TEXT_SIZE, TEXT_SIZE);
	cairo_show_text (cr, pages[i].page_size);
	cairo_show_text (cr, " - ");
	cairo_show_text (cr, pages[i].orientation);
	cairo_show_page (cr);
    }

    status = cairo_status (cr);

    cairo_destroy (cr);
    cairo_surface_destroy (surface);

    if (status) {
	cairo_test_log (&ctx, "Failed to create ps surface for file %s: %s\n",
			filename, cairo_status_to_string (status));
	return CAIRO_TEST_FAILURE;
    }

    printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename);

    cairo_test_fini (&ctx);

    return CAIRO_TEST_SUCCESS;
}
Ejemplo n.º 20
0
void implf()
{
  int lf,yv,xv;
  double wep;
  //char zt[17] = "                \0";
  char  zn[20],zn2[20];

  yv = ydeb;
for ( lf=0; lf < derlig; ++lf)	{
  if ( yv >= yfin || ligfac[lf].typlig == SPAG)	{	// saut de page
      cairo_show_page(cr);
      sfac_spag();
      yv = ydeb;
											    }
if (ligfac[lf].typlig == DETAIL )	{
   if (  parlf[CSFlibprod].y != 0) {
	cairotextlf(CSFlibprod);
	cairo_move_to(cr, parlf[CSFlibprod].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
							      }
   if (  parlf[CSFquant].y != 0)	{
	cairotextlf(CSFquant);
	cairo_move_to(cr, parlf[CSFquant].x, yv);
	formfloat(zn2,ligfac[lf].quant);
	sprintf(zn,"%10s",zn2);
	cairo_show_text(cr, zn);
 								     }
   if (  parlf[CSFunit].y != 0)	{
	cairotextlf(CSFunit);
	cairo_move_to(cr, parlf[CSFunit].x, yv);
	cairo_show_text(cr, ligfac[lf].unit);
						      }
   if (  parlf[CSFctax].y != 0)	{
	cairotextlf(CSFctax);
	cairo_move_to(cr, parlf[CSFctax].x, yv);
	cairo_show_text(cr, ligfac[lf].codtax);
						      }
   if (  parlf[CSFpu].y != 0)	{
	cairotextlf(CSFpu);
	cairo_move_to(cr, parlf[CSFpu].x, yv);
	cairo_show_text(cr, ligfac[lf].spriunit);
 							     }
   if (  parlf[CSFval].y != 0)	{
	cairotextlf(CSFval);
	cairo_move_to(cr, parlf[CSFval].x, yv);
	cairo_show_text(cr, ligfac[lf].svalor);
	//   ltof(ligfac[lf].valor,zt,13);
	//   cairo_show_text(cr, zt);
						      }
   if (  parlf[CSFcodprod].y != 0) {
	cairotextlf(CSFcodprod);
	cairo_move_to(cr, parlf[CSFcodprod].x, yv);
	cairo_show_text(cr, ligfac[lf].codprod);
 							     }
 									}
else if (ligfac[lf].typlig == DETLIB )	{
   if (  parlf[CSFlibprod].y != 0) {
	cairotextlf(CSFlibprod);
	cairo_move_to(cr, parlf[CSFlibprod].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
 							     }
									    }
else if (ligfac[lf].typlig == LQQ )	{
      if (  parlf[CSFlibvar].y != 0) {
	cairotextlf(CSFlibvar);
	cairo_move_to(cr, parlf[CSFlibvar].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
								      }
								    }
else if (ligfac[lf].typlig == TAX ||
   ligfac[lf].typlig == TIX)	{	// on se base sur DETAIL
   if (  parlf[CSFlibprod].y != 0) {
	cairotextlf(CSFlibprod);
	cairo_move_to(cr, parlf[CSFlibprod].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
 							     }
   if (  parlf[CSFpu].y != 0)	{
	cairotextlf(CSFpu);
	cairo_move_to(cr, parlf[CSFpu].x, yv);
	cairo_show_text(cr, ligfac[lf].spriunit);
						      }
   if (  parlf[CSFval].y != 0)	{
	cairotextlf(CSFval);
	cairo_move_to(cr, parlf[CSFval].x, yv);
	cairo_show_text(cr, ligfac[lf].svalor);
	//   ltof(ligfac[lf].valor,zt,13);
	//   cairo_show_text(cr, zt);
						      }
 								   }
else if (ligfac[lf].typlig == CALTOT )	{
   if (  parlf[CSFlibtot].y != 0) {
	cairotextlf(CSFlibtot);
	cairo_move_to(cr, parlf[CSFlibtot].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
 							     }
   if (  parlf[CSFvaltot].y != 0) {
	cairotextlf(CSFvaltot);
	cairo_move_to(cr, parlf[CSFvaltot].x, yv);
	cairo_show_text(cr, ligfac[lf].svalor);
	//   ltof(ligfac[lf].valor,zt,13);
	//   cairo_show_text(cr, zt);
 							     }
 									   }
else if (ligfac[lf].typlig == GENCAL )	{	// traits
   if (  parlf[CSFvaltot].y != 0) {	// on se base sur valtot
	cairotextlf(CSFvaltot);
	if ( strcmp(ligfac[lf].codprod,".ttt") == 0) wep = 0.7;
	else  wep = 1.4;
	xv = parlf[CSFvaltot].x + 5;
	cairo_set_line_width (cr, wep);
	cairo_move_to(cr, xv, yv);
	cairo_line_to(cr, xv + 80, yv); // 6 x 16
	cairo_stroke(cr);
 							     }
								    }
else if (ligfac[lf].typlig == TPP )	{
   if (  parlf[CSFlibtot].y != 0) {
	cairotextlf(CSFlibtot);
	cairo_move_to(cr, parlf[CSFlibtot].x, yv);
	cairo_show_text(cr, ligfac[lf].libprod);
 							     }
  if (  parlf[CSFstot].y != 0) {
	cairotextlf(CSFstot);
	cairo_move_to(cr, parlf[CSFstot].x, yv);
	cairo_show_text(cr, ligfac[lf].spriunit);
	//   ltof(ligfac[lf].valor,zt,13);
	//   cairo_show_text(cr, zt);
 						     }
 								   }
    yv += dy;
					  }	// fin lecture lignes fac
}
Ejemplo n.º 21
0
static int gt_sketch_page_runner(GT_UNUSED int argc,
                                 const char **argv,
                                 int parsed_args,
                                 void *tool_arguments,
                                 GtError *err)
{
  SketchPageArguments *arguments = tool_arguments;
  int had_err = 0;
  GtFeatureIndex *features = NULL;
  GtRange qry_range, sequence_region_range;
  GtStyle *sty = NULL;
  GtStr *prog, *gt_style_file;
  GtDiagram *d = NULL;
  GtLayout *l = NULL;
  GtBioseq *bioseq = NULL;
  GtCanvas *canvas = NULL;
  const char *seqid = NULL, *outfile;
  unsigned long start, height, num_pages = 0;
  double offsetpos, usable_height;
  cairo_surface_t *surf = NULL;
  cairo_t *cr = NULL;
  GtTextWidthCalculator *twc;
  gt_error_check(err);

  features = gt_feature_index_memory_new();

  if (cairo_version() < CAIRO_VERSION_ENCODE(1, 8, 6))
    gt_warning("Your cairo library (version %s) is older than version 1.8.6! "
               "These versions contain a bug which may result in "
               "corrupted PDF output!", cairo_version_string());

  /* get style */
  sty = gt_style_new(err);
  if (gt_str_length(arguments->stylefile) == 0)
  {
    prog = gt_str_new();
    gt_str_append_cstr_nt(prog, argv[0],
                          gt_cstr_length_up_to_char(argv[0], ' '));
    gt_style_file = gt_get_gtdata_path(gt_str_get(prog), err);
    gt_str_delete(prog);
    gt_str_append_cstr(gt_style_file, "/sketch/default.style");
  }
  else
  {
    gt_style_file = gt_str_ref(arguments->stylefile);
  }
  had_err = gt_style_load_file(sty, gt_str_get(gt_style_file), err);

  outfile = argv[parsed_args];
  if (!had_err)
  {
    /* get features */
    had_err = gt_feature_index_add_gff3file(features, argv[parsed_args+1], err);
     if (!had_err && gt_str_length(arguments->seqid) == 0) {
      seqid = gt_feature_index_get_first_seqid(features);
      if (seqid == NULL)
      {
        gt_error_set(err, "GFF input file must contain a sequence region!");
        had_err = -1;
      }
    }
    else if (!had_err
               && !gt_feature_index_has_seqid(features,
                                              gt_str_get(arguments->seqid)))
    {
      gt_error_set(err, "sequence region '%s' does not exist in GFF input file",
                   gt_str_get(arguments->seqid));
      had_err = -1;
    }
    else if (!had_err)
      seqid = gt_str_get(arguments->seqid);
  }

  /* set text */
  if (gt_str_length(arguments->text) == 0)
  {
    gt_str_delete(arguments->text);
    arguments->text = gt_str_new_cstr(argv[parsed_args+1]);
  }

  if (!had_err)
  {
    /* set display range */
    gt_feature_index_get_range_for_seqid(features, &sequence_region_range,
                                         seqid);
    qry_range.start = (arguments->range.start == GT_UNDEF_ULONG ?
                         sequence_region_range.start :
                         arguments->range.start);
    qry_range.end   = (arguments->range.end == GT_UNDEF_ULONG ?
                         sequence_region_range.end :
                         arguments->range.end);

    /* set output format */
    if (strcmp(gt_str_get(arguments->format), "pdf") == 0)
    {
      surf = cairo_pdf_surface_create(outfile,
                                      mm_to_pt(arguments->pwidth),
                                      mm_to_pt(arguments->pheight));
    }
    else if (strcmp(gt_str_get(arguments->format), "ps") == 0)
    {
      surf =  cairo_ps_surface_create(outfile,
                                      mm_to_pt(arguments->pwidth),
                                      mm_to_pt(arguments->pheight));
    }
    gt_log_log("created page with %.2f:%.2f dimensions\n",
                                                  mm_to_pt(arguments->pwidth),
                                                  mm_to_pt(arguments->pheight));

    offsetpos = TEXT_SPACER + arguments->theight + TEXT_SPACER;
    usable_height = mm_to_pt(arguments->pheight)
                              - arguments->theight
                              - arguments->theight
                              - 4*TEXT_SPACER;

    if (gt_str_length(arguments->seqfile) > 0) {
      bioseq = gt_bioseq_new(gt_str_get(arguments->seqfile), err);
    }

    cr = cairo_create(surf);
    cairo_set_font_size(cr, 8);
    twc = gt_text_width_calculator_cairo_new(cr, sty);
    for (start = qry_range.start; start <= qry_range.end;
         start += arguments->width)
    {
      GtRange single_range;
      GtCustomTrack *ct = NULL;
      const char *seq;
      single_range.start = start;
      single_range.end = start + arguments->width;

      if (had_err)
        break;

      d = gt_diagram_new(features, seqid, &single_range, sty, err);
      if (!d) {
        had_err = -1;
        break;
      }
      if (bioseq) {
        seq = gt_bioseq_get_sequence(bioseq, 0);
        ct = gt_custom_track_gc_content_new(seq,
                                      gt_bioseq_get_sequence_length(bioseq, 0),
                                      800, 70, 0.4, true);
        gt_diagram_add_custom_track(d, ct);
      }

      l = gt_layout_new_with_twc(d, mm_to_pt(arguments->width), sty, twc, err);
      had_err = gt_layout_get_height(l, &height, err);
      if (!had_err) {
        if (gt_double_smaller_double(usable_height - 10 - 2*TEXT_SPACER
              - arguments->theight, offsetpos + height))
        {
            draw_header(cr, gt_str_get(arguments->text), argv[parsed_args+1],
                        seqid, num_pages, mm_to_pt(arguments->pwidth),
                        mm_to_pt(arguments->pheight),
                        arguments->theight);
          cairo_show_page(cr);
          offsetpos = TEXT_SPACER + arguments->theight + TEXT_SPACER;
          num_pages++;
        }
        canvas = gt_canvas_cairo_context_new(sty,
                                             cr,
                                             offsetpos,
                                             mm_to_pt(arguments->pwidth),
                                             height,
                                             NULL,
                                             err);
        if (!canvas)
          had_err = -1;
        offsetpos += height;
        if (!had_err)
          had_err = gt_layout_sketch(l, canvas, err);
      }
      gt_canvas_delete(canvas);
      gt_layout_delete(l);
      gt_diagram_delete(d);
      if (ct)
        gt_custom_track_delete(ct);
    }
    draw_header(cr, gt_str_get(arguments->text), argv[parsed_args+1], seqid,
                num_pages, mm_to_pt(arguments->pwidth),
                mm_to_pt(arguments->pheight),
                arguments->theight);
    cairo_show_page(cr);
    num_pages++;
    gt_log_log("finished, should be %lu pages\n", num_pages);
    gt_text_width_calculator_delete(twc);
    cairo_destroy(cr);
    cairo_surface_flush(surf);
    cairo_surface_finish(surf);
    cairo_surface_destroy(surf);
    cairo_debug_reset_static_data();
    if (bioseq)
      gt_bioseq_delete(bioseq);
    gt_style_delete(sty);
    gt_str_delete(gt_style_file);
    gt_feature_index_delete(features);
  }
  return had_err;
}
Ejemplo n.º 22
0
static void BM_NewPage(const pGEcontext gc, pDevDesc dd)
{
    pX11Desc xd = (pX11Desc) dd->deviceSpecific;
    char buf[PATH_MAX];
    cairo_status_t res;

    xd->npages++;
    if (xd->type == PNG || xd->type == JPEG || xd->type == BMP) {
	if (xd->npages > 1) {
	    /* try to preserve the page we do have */
	    BM_Close_bitmap(xd);
	    if (xd->fp) fclose(xd->fp);
	}
	snprintf(buf, PATH_MAX, xd->filename, xd->npages);
	xd->fp = R_fopen(R_ExpandFileName(buf), "wb");
	if (!xd->fp)
	    error(_("could not open file '%s'"), buf);
    }
    else if(xd->type == PNGdirect || xd->type == TIFF) {
	if (xd->npages > 1) {
	    xd->npages--;
	    BM_Close_bitmap(xd);
	    xd->npages++;
	}
    }
#ifdef HAVE_CAIRO_SVG
    else if(xd->type == SVG) {
	if (xd->npages > 1 && xd->cs) {
	    cairo_show_page(xd->cc);
	    if(!xd->onefile) {
		cairo_surface_destroy(xd->cs);
		cairo_destroy(xd->cc);
	    }
	}
	if(xd->npages == 1 || !xd->onefile) {
	    snprintf(buf, PATH_MAX, xd->filename, xd->npages);
	    xd->cs = cairo_svg_surface_create(R_ExpandFileName(buf),
					      (double)xd->windowWidth,
					      (double)xd->windowHeight);
	    res = cairo_surface_status(xd->cs);
	    if (res != CAIRO_STATUS_SUCCESS) {
		xd->cs = NULL;
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
	    if(xd->onefile)
		cairo_svg_surface_restrict_to_version(xd->cs, CAIRO_SVG_VERSION_1_2);
	    xd->cc = cairo_create(xd->cs);
	    res = cairo_status(xd->cc);
	    if (res != CAIRO_STATUS_SUCCESS) {
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
	    cairo_set_antialias(xd->cc, xd->antialias);
	}
    }
#endif
#ifdef HAVE_CAIRO_PDF
    else if(xd->type == PDF) {
	if (xd->npages > 1) {
	    cairo_show_page(xd->cc);
	    if(!xd->onefile) {
		cairo_surface_destroy(xd->cs);
		cairo_destroy(xd->cc);
	    }
	}
	if(xd->npages == 1 || !xd->onefile) {
	    snprintf(buf, PATH_MAX, xd->filename, xd->npages);
	    xd->cs = cairo_pdf_surface_create(R_ExpandFileName(buf),
					      (double)xd->windowWidth,
					      (double)xd->windowHeight);
	    res = cairo_surface_status(xd->cs);
	    if (res != CAIRO_STATUS_SUCCESS) {
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
	    xd->cc = cairo_create(xd->cs);
	    res = cairo_status(xd->cc);
	    if (res != CAIRO_STATUS_SUCCESS) {
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
	    cairo_set_antialias(xd->cc, xd->antialias);
	}
    }
#endif
#ifdef HAVE_CAIRO_PS
    else if(xd->type == PS) {
	if (xd->npages > 1 && !xd->onefile) {
	    cairo_show_page(xd->cc);
	    cairo_surface_destroy(xd->cs);
	    cairo_destroy(xd->cc);
	}
	if(xd->npages == 1 || !xd->onefile) {
	    snprintf(buf, PATH_MAX, xd->filename, xd->npages);
	    xd->cs = cairo_ps_surface_create(R_ExpandFileName(buf),
					     (double)xd->windowWidth,
					     (double)xd->windowHeight);
	    res = cairo_surface_status(xd->cs);
	    if (res != CAIRO_STATUS_SUCCESS) {
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
// We already require >= 1.2
#if CAIRO_VERSION_MAJOR > 2 || CAIRO_VERSION_MINOR >= 6
	    if(!xd->onefile)
		cairo_ps_surface_set_eps(xd->cs, TRUE);
#endif
	    xd->cc = cairo_create(xd->cs);
	    res = cairo_status(xd->cc);
	    if (res != CAIRO_STATUS_SUCCESS) {
		error("cairo error '%s'", cairo_status_to_string(res));
	    }
	    cairo_set_antialias(xd->cc, xd->antialias);
	}
    }
#endif
    else
	error(_("unimplemented cairo-based device"));

    cairo_reset_clip(xd->cc);
    if (xd->type == PNG  || xd->type == TIFF|| xd->type == PNGdirect) {
	/* First clear it */
	cairo_set_operator (xd->cc, CAIRO_OPERATOR_CLEAR);
	cairo_paint (xd->cc);
	cairo_set_operator (xd->cc, CAIRO_OPERATOR_OVER);
	xd->fill = gc->fill;
    } else
	xd->fill = R_OPAQUE(gc->fill) ? gc->fill: xd->canvas;
    CairoColor(xd->fill, xd);
    cairo_new_path(xd->cc);
    cairo_paint(xd->cc);
}
Ejemplo n.º 23
0
/*
 * gera relatorio ...
 *
 * ret: -1 =>  algum erro encontrado ...
 * ret:  0  => ok!
 */
int
impressao_geral (cairo_t *cr, char *sql)
{
    FILE *fp;
    char *sheader;
    char *sbuffer;
    char *cstr;
    long int len = 1; /* + */
    char car;
    GList *columns;
    double x = MARGEM_ESQUERDA, y = MARGEM_SUPERIOR;
    cairo_text_extents_t extents;
    const char *utf8 = "+";
    /* Controle de impressao de pagina */
    static long int actual_page = 0;
    static double start_field = 0.0;
    static double end_field = 0.0;
    double redundancy = 0.7;
    
    printf ("impressao_geral\n");
    
    /*
     * Listagem
     */
    char *command = g_strdup_printf ("/usr/share/xmoney/sh/print %s", sql);
    
    fp = popen (command, "r");
    
    g_free (command);
    
    if ((car = fgetc (fp)) != '+')
    {
	cairo_set_source_rgb (cr, 250, 250, 250);
	cairo_paint (cr);
        cairo_set_source_rgb (cr, 0, 0, 0);
	cairo_select_font_face (cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, 20.0);
	cairo_move_to (cr, 20.0, 40.0);
	cairo_show_text (cr, "Ops! Sem dados disponiveis para listagem aqui!");
	
	return -1;
    }
    
    /*
     * Prop. fonte
     */
    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_select_font_face (cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, TamanhoFonte);
    cairo_text_extents (cr, utf8, &extents);
    
    /*
     * Cabecalho
     */
    columns = NULL; // g_list_alloc ();
    
    /* ---+ */
    while ((car = getc (fp)) != '\n')
    {
	++ len;
	
	if (car == '+')
	{
	    columns = g_list_append (columns, g_strdup_printf ("%ld", len));
	    
	    if ((extents.width * len) > LarguraPagina)
	    {
		++ actual_page;
	    }
	    else
	    {
		end_field = len;
	    }
	}
	
	printf ("%c", car);
    }
    
    printf ("\n");
    
    printf ("Largura Pagina: %f\n"
            "Largura Campos: %f\n",
            LarguraPagina, extents.width * len);
    
    GList *list = g_list_first (columns);
    printf ("list->length = %d\n", g_list_length (list));
    while (list)
    {
	printf ("coluna : %d\n", atoi ((char *) list->data));
	
	list = list->next;
    }
    
    printf ("string width :    %f\n"
            "       height:    %f\n"
	    "       x_bearing: %f\n"
	    "       y_bearing: %f\n"
	    "       x_advance: %f\n"
	    "       y_advance: %f\n",
	    extents.width,     extents.height,
	    extents.x_bearing, extents.y_bearing,
	    extents.x_advance, extents.y_advance);
    
    /*
     * Fundo branco pagina
     */
    cairo_set_source_rgb (cr, 255, 255, 255);
    cairo_rectangle (cr, 0.0, 0.0, LarguraPagina, AlturaPagina);
    cairo_fill (cr);
    
    /*
     * Fundo verde cabelho
     */
    cairo_set_source_rgb (cr, 0, 100, 0);
    cairo_rectangle (cr, x, y, (extents.width + redundancy) * len, extents.height * 3);
    cairo_fill (cr);
    
    // linha topo ...
    cairo_set_source_rgb (cr, 0, 0, 0); // preto
    cairo_move_to (cr, x, y);
    cairo_line_to (cr, x + ((extents.width + redundancy) * len), y);
    cairo_stroke (cr);
    
    // cabecalho sql
    sheader = (char *) malloc (len);
    sbuffer = (char *) malloc (len);
    
    fread (sheader, len, 1, fp);
    cstr = strndup (sbuffer, len);
    
    while ((car = getc (fp)) != '\n');
    
    y += extents.height * 2;
    cairo_move_to (cr, x, y);
    cairo_show_text (cr, cstr = strndup (sheader, len));
    free (cstr);
    
    /* +---+ */
    while ((car = getc (fp)) != '\n');
    
    // linha debaixo do cabecalho ...
    y += extents.height;
    cairo_move_to (cr, x, y);
    cairo_line_to (cr, x + ((extents.width + redundancy) * len), y);
    cairo_stroke (cr);
    
    /*
     * Linhas
     */
    char n_linhas = 0;
    int bottom_y;
    y += extents.height * 2;
    while (fread (sbuffer, len, 1, fp))
    {
	cstr = strndup (sbuffer, len);
	
	if (cstr [0] == '+')
	{
	    cairo_move_to (cr, x, bottom_y);
	    cairo_line_to (cr, x + ((extents.width + redundancy) * len), bottom_y);
	    cairo_stroke (cr);
	    free (cstr);
	    break;
	}
	
	// Listagem
   	cairo_move_to (cr, x, y);
	cairo_show_text (cr, cstr);
	free (cstr);
	
	bottom_y = y + extents.height;
	
	//cairo_move_to (cr, x, y - 10.0);
	//cairo_line_to (cr, WIDTH_POINTS, y - 10.0);
	//cairo_stroke (cr);
	
	
	/* Espera nova linha ... */
	while ((car = getc (fp)) != '\n');
	
	++ n_linhas;
	if (n_linhas > 40)
	{
	    // linha debaixo da listatem
	    y += extents.height;
	    cairo_move_to (cr, x, y);
	    cairo_line_to (cr, x + ((extents.width + redundancy) * len), y);
	    cairo_stroke (cr);
	    cairo_show_page (cr);
	    
	    y = MARGEM_ESQUERDA;
	    x = MARGEM_SUPERIOR;
	    n_linhas = 0;
	    
	    // linha topo da listagem
	    cairo_move_to (cr, x, y);
	    cairo_line_to (cr, x + ((extents.width + redundancy) * len), y);
	    cairo_stroke (cr);
	}
	
	y += extents.height * 2;
    }
    
    free (sheader);
    free (sbuffer);
    g_list_free (columns);
    fclose (fp);
    
    return 0;
}
Ejemplo n.º 24
0
static void
create_pages (Pqueue * queue)
{
	gchar * msg;
	gdouble line_height;
	guint i, id;
	glong index;
	PangoLayoutLine * line;
	PangoRectangle ink_rect, logical_rect;

	g_return_if_fail (queue);
	g_return_if_fail (queue->pos < strlen(queue->text));
	while (queue->pos < strlen (queue->text))
	{
		while (gtk_events_pending ())
			gtk_main_iteration ();
		for (i = 0; i < queue->lines_per_page; i++)
		{
			line = pango_layout_iter_get_line (queue->iter);
			pango_layout_iter_next_line (queue->iter);
			pango_layout_iter_get_line_extents (queue->iter, &ink_rect, &logical_rect);
			index = pango_layout_iter_get_index (queue->iter);
			if (index == 0)
			{
				i = queue->lines_per_page;
				queue->pos = strlen (queue->text);
				g_message ("%s", _("Error: Pango iter index is zero."));
				continue;
			}
			line_height = logical_rect.height / PANGO_SCALE;
			if ((queue->page_height + line_height) > (queue->height - (EDGE_MARGIN/2)))
			{
				queue->pos += index;
				queue->page_height = EDGE_MARGIN;
				gtk_progress_bar_pulse (queue->progressbar);
				pango_cairo_update_layout (queue->cr, queue->layout);
				queue->layout = make_new_page (queue->context, queue->desc, queue->height, queue->width);
				i = queue->lines_per_page;
				queue->page_count++;
				pango_layout_set_text (queue->layout, (queue->text+queue->pos), -1);
				queue->iter = pango_layout_get_iter (queue->layout);
				pango_cairo_show_layout_line (queue->cr, line);
				pango_cairo_update_layout (queue->cr, queue->layout);
				cairo_show_page (queue->cr);
			}
			else
				pango_cairo_show_layout_line (queue->cr, line);
			queue->page_height += line_height;
			cairo_move_to (queue->cr, SIDE_MARGIN / 2, queue->page_height);
		}
	}
	pango_layout_iter_free (queue->iter);
	gtk_progress_bar_set_fraction (queue->progressbar, 0.0);
	cairo_surface_destroy(queue->surface);
	pango_font_description_free (queue->desc);
	g_object_unref (queue->context);
	g_object_unref (queue->layout);
	cairo_destroy (queue->cr);
	id = gtk_statusbar_get_context_id (queue->statusbar, PACKAGE);
	msg = g_strdup_printf (ngettext("Saved PDF file. (%ld page)",
		"Saved PDF file (%ld pages).", queue->page_count), queue->page_count);
	gtk_statusbar_push (queue->statusbar, id, msg);
	g_free (msg);
}
Ejemplo n.º 25
0
	void lime_cairo_show_page (value handle) {
		
		cairo_show_page ((cairo_t*)val_data (handle));
		
	}
Ejemplo n.º 26
0
void hb_export_pdf_listview(GtkTreeView *treeview, gchar *filepath, gchar *accname)
{
cairo_surface_t *surf;
cairo_t *cr;
PdfPrintContext ppc;
PangoFontDescription *desc;
PangoLayout *layout;
GtkTreeModel *model;
GtkTreeIter	iter;
gboolean valid;
gint i, col;

	
	DB( g_print("[gtk-chart] export to pdf\n") );

	model = gtk_tree_view_get_model(treeview);
	
	papersize(&ppc);

	//gchar *filename = "/home/max/Desktop/hb-txn-export.pdf";
	double width;	//=210 * 2.83;
	double height;	//=297 * 2.83;
	
	width  = ppc.w;
	height = ppc.h;

	surf = cairo_pdf_surface_create (filepath, width, height);
	
	if( cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS )
	//todo: manage error later on
		return;

	
	cr = cairo_create (surf);
	//cairo_pdf_surface_set_size(surf, width * 2.83, height * 2.83);

	//g_print("width=%d\n", cairo_image_surface_get_width( surf));
	double x1, x2, y1, y2;
	cairo_clip_extents (cr, &x1, &y1, &x2, &y2);

	DB( g_print("surface w=%f, h=%f\n", x2 - x1, y2 - y1) );
	double pwidth = x2 - x1;
	
	
	/* Create a PangoLayout, set the font and text */
	layout = pango_cairo_create_layout (cr);

	/* get and copy the font from the treeview widget */
	gtk_style_context_get(gtk_widget_get_style_context(GTK_WIDGET(treeview)), GTK_STATE_FLAG_NORMAL, "font", &desc, NULL);
	ppc.desc = pango_font_description_copy(desc);

	DB( g_print("family: %s\n", pango_font_description_get_family(desc)) );
	DB( g_print("size: %d (%d)\n", pango_font_description_get_size (desc), pango_font_description_get_size (desc )/PANGO_SCALE) );


	
	/* header is 1 line for date page number at top, then a title in bold, then 2 empty lines */
	gint header_height = PDF_FONT_NORMAL * 2 + PDF_FONT_TITLE;
	gint nb_lines = gtk_tree_model_iter_n_children(model, NULL);

	/* should include here the headertitle line */
	
	gint lpp = floor ((height-header_height-ppc.mt-ppc.mb) / (PDF_FONT_NORMAL + PDF_LINE_MARGIN));
	gint page, num_pages = (nb_lines - 1) / lpp + 1;

	DB( g_print("\n - should pdf %d lines, lpp=%d, num_pages=%d\n", nb_lines, lpp, num_pages) );


	gint tot_lines = 0;
	gint cur_page_line = 1;

	gchar dbuffer[255];
	gchar amtbuf[G_ASCII_DTOSTR_BUF_SIZE];
	gchar balbuf[G_ASCII_DTOSTR_BUF_SIZE];

	GDate *date = g_date_new ();

	//cairo_set_font_size(cr, PDF_FONT_NORMAL);
	pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_NORMAL * PANGO_SCALE);
	pango_layout_set_font_description (layout, ppc.desc);
	
	/* reset struct */
	hb_pdf_set_col_title(&ppc);
	
	for(col=0;col<PDF_NUMCOL;col++)
	{
	int tw, th;

		ppc.column_width[col] = 0;
		pango_layout_set_text (layout, ppc.column_txt[col], -1);
		pango_layout_get_size (layout, &tw, &th);
		ppc.column_width[col] = MAX(ppc.column_width[col], tw / PANGO_SCALE);
	}


	DB( g_print(" - compute width\n") );

	/* first pass to get max width */
	valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
	while (valid)
	{
	Transaction *txn;
	int tw, th;
			
		gtk_tree_model_get (model, &iter, LST_DSPOPE_DATAS, &txn, -1);

		i = 0;
		g_date_set_julian (date, txn->date);
		g_date_strftime (dbuffer, 255-1, "%x", date);
		pango_layout_set_text (layout, dbuffer, -1);
		pango_layout_get_size (layout, &tw, &th);
		ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
		
		i = 1;
		if(txn->info != NULL && strlen(txn->info) > 0)
		{
			pango_layout_set_text (layout, txn->info, -1);
			pango_layout_get_size (layout, &tw, &th);
			ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
		}
		
		i = 4;
		hb_strfnum(amtbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->amount, txn->kcur, GLOBALS->minor);
		pango_layout_set_text (layout, amtbuf, -1);
		pango_layout_get_size (layout, &tw, &th);
		ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);

		i = 5;
		pango_layout_set_text (layout, "R", -1);
		pango_layout_get_size (layout, &tw, &th);
		ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);

		i = 6;
		hb_strfnum(balbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->balance, txn->kcur, GLOBALS->minor);
		pango_layout_set_text (layout, balbuf, -1);
		pango_layout_get_size (layout, &tw, &th);
		ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);

		valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
	}

	/* distribute remaining size */
	gdouble tmp = pwidth - ppc.ml - ppc.mr - (PDF_COL_MARGIN*PDF_NUMCOL);


	DB( g_print(" page width=%f, remain width=%f\n", pwidth, tmp) );
	
	tmp -= ppc.column_width[0];
	tmp -= ppc.column_width[4];
	tmp -= ppc.column_width[5];
	tmp -= ppc.column_width[6];
	
	/* info=1/4 payee=1/4 memo=2/4 */
	ppc.column_width[1] = tmp / 4;;
	ppc.column_width[2] = tmp / 4;
	ppc.column_width[3] = 2*tmp / 4;

	DB( g_print(" page width=%f, remain width=%f\n", width, tmp) );
	
	#if MYDEBUG == 1
	for(i=0;i<PDF_NUMCOL;i++)
		g_print(" col%d=%g ", i, ppc.column_width[i]);

	g_print("\n");
	#endif

	DB( g_print("\n - start printing\n") );
	
	gint y;
	page = 1;
	valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
	while (valid)
	{
	Transaction *txn;
	int tw, th;
			
		gtk_tree_model_get (model, &iter, LST_DSPOPE_DATAS, &txn, -1);

		//DB( g_print(" - %d, %d, %s\n", x, y, txn->memo) );
		if(cur_page_line == 1)
		{
			//helpdraw
			#if HELPDRAW == 1
			//page with margin
			hb_pdf_draw_help_rect(cr, 0xFF0000FF, ppc.ml+0.5, ppc.mt+0.5, width-(ppc.ml+ppc.mr), height - (ppc.mt+ppc.mb));
			hb_pdf_draw_help_rect(cr, 0xFF00FFFF, ppc.ml+0.5, ppc.mt+0.5, width-(ppc.ml+ppc.mr), header_height);
			#endif

			cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);

			// draw account title
			pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_TITLE * PANGO_SCALE);
			pango_layout_set_font_description (layout, ppc.desc);

			pango_layout_set_text (layout, accname, -1);
			pango_layout_get_pixel_size (layout, &tw, &th);
			cairo_move_to(cr, pwidth/2 - (tw/2), ppc.mt);
			pango_cairo_show_layout (cr, layout);

			// draw column titles
			pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_NORMAL * PANGO_SCALE);
			pango_layout_set_font_description (layout, ppc.desc);

			g_sprintf(dbuffer, "Page %d/%d", page, num_pages);
			pango_layout_set_text (layout, dbuffer, -1);
			pango_layout_get_pixel_size (layout, &tw, &th);
			cairo_move_to(cr, pwidth - ppc.mr - tw, ppc.mt);
			pango_cairo_show_layout (cr, layout);

			//x = ppc.ml;
			y = ppc.mt + header_height - (PDF_FONT_NORMAL + PDF_LINE_MARGIN);
			hb_pdf_set_col_title(&ppc);

			hb_pdf_draw_line(&ppc, cr, y, TRUE, FALSE);
		}

		/* print a single line */
		//x = ppc.ml;
		y = ppc.mt + header_height + (cur_page_line * (PDF_FONT_NORMAL + PDF_LINE_MARGIN));



		/* reset struct */
		for(i=0;i<PDF_NUMCOL;i++)
		{
			ppc.column_txt[i] = NULL;
		}
		
		i = 0;
		g_date_set_julian (date, txn->date);
		g_date_strftime (dbuffer, 255-1, "%x", date);
		ppc.column_txt[i] = dbuffer;
		
		i = 1;
		ppc.column_txt[i] = txn->info;

		i = 2;
		Payee *p = da_pay_get(txn->kpay);
		if(p)
			ppc.column_txt[i] = p->name;

		i = 3;
		/*Category *c = da_cat_get(txn->kcat);
		if(c)
			ppc.column_txt[i] = da_cat_get_fullname(c);*/
		ppc.column_txt[i] = txn->memo;
			
		i = 4;
		hb_strfnum(amtbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->amount, txn->kcur, GLOBALS->minor);
		ppc.column_txt[i] = amtbuf;

		i = 5;
		ppc.column_txt[i] = "";
		if(txn->status == TXN_STATUS_CLEARED)
			ppc.column_txt[i] = "c";
		else
		if(txn->status == TXN_STATUS_RECONCILED)
			ppc.column_txt[i] = "R";
		
		i = 6;
		hb_strfnum(balbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->balance, txn->kcur, GLOBALS->minor);
		ppc.column_txt[i] = balbuf;

		hb_pdf_draw_line(&ppc, cr, y, FALSE, (cur_page_line % 2));
		
		/* free any fullcat name */
		/*if(ppc.column_txt[3] != NULL)
			g_free(ppc.column_txt[3]);*/
		
		/* export page */		
		if(cur_page_line >= lpp)
		{
			DB( g_print("\n - next page %d\n", page) );
			
			cairo_show_page(cr);
			cur_page_line = 0;
			page++;
		}

		cur_page_line++;
		tot_lines++;
		valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
	}

	g_date_free(date);

	g_object_unref (layout);
	pango_font_description_free (ppc.desc);

	cairo_destroy (cr);
	cairo_surface_destroy (surf);

}