149 fprintf(stderr,
"[imageio_format_pdf] invalid paper size: `%s'!\n",
d->size);
156 fprintf(stderr,
"[imageio_format_pdf] invalid border size: `%s'! using 0\n",
d->border);
177 *page_border = border;
185 void *exif,
int exif_len, int32_t imgid,
int num,
int total,
struct dt_dev_pixelpipe_t *pipe,
186 const gboolean export_masks)
193 float page_width, page_height, page_border;
194 float page_dpi =
d->params.dpi;
196 if(
_paper_size(&
d->params, &page_width, &page_height, &page_border))
199 unsigned int compression =
d->params.compression;
206 fprintf(stderr,
"[imageio_format_pdf] could not export to file: `%s'!\n", filename);
212 pdf->
title = *
d->params.title ?
d->params.title : NULL;
215 d->actual_filename = g_strdup(filename);
216 d->page_border = page_border;
221 if(imgid > 0 &&
d->params.icc &&
d->params.mode ==
MODE_NORMAL)
227 for(GList *iter =
d->icc_profiles; iter; iter = g_list_next(iter))
239 cmsSaveProfileToMem(profile->
profile, 0, &len);
242 unsigned char *buf = malloc(
sizeof(
unsigned char) * len);
243 cmsSaveProfileToMem(profile->
profile, buf, &len);
249 d->icc_profiles = g_list_append(
d->icc_profiles, icc);
254 void *image_data = NULL;
261 if(
d->params.bpp == 8)
266 const uint8_t *in_ptr = (
const uint8_t *)in;
267 uint8_t *out_ptr = (uint8_t *)image_data;
268 for(
int y = 0; y < data->
height; y++)
270 for(
int x = 0;
x < data->
width;
x++, in_ptr += 4, out_ptr += 3)
271 memcpy(out_ptr, in_ptr, 3);
279 const uint16_t *in_ptr = (
const uint16_t *)in;
280 uint16_t *out_ptr = (uint16_t *)image_data;
281 for(
int y = 0; y < data->
height; y++)
283 for(
int x = 0;
x < data->
width;
x++, in_ptr += 4, out_ptr += 3)
285 for(
int c = 0; c < 3; c++)
286 out_ptr[c] = (0xff00 & (in_ptr[c] << 8)) | (in_ptr[c] >> 8);
296 d->images = g_list_append(
d->images, image);
302 int n_images = g_list_length(
d->images);
310 for(
const GList *iter =
d->images; iter; iter = g_list_next(iter))
332 d->icc_profiles = NULL;
336 d->actual_filename = NULL;
337 d->icc_profiles = NULL;
355 return "application/pdf";
379 float page_width, page_height, page_border;
380 float page_dpi =
d->params.dpi;
382 if(
_paper_size(&
d->params, &page_width, &page_height, &page_border))
457 dt_conf_set_string(
"plugins/imageio/format/pdf/title", gtk_entry_get_text(GTK_ENTRY(widget)));
462 dt_conf_set_string(
"plugins/imageio/format/pdf/border", gtk_entry_get_text(GTK_ENTRY(widget)));
481 dt_conf_set_float(
"plugins/imageio/format/pdf/dpi", gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)));
521 self->
widget = gtk_grid_new();
522 GtkGrid *grid = GTK_GRID(self->
widget);
532 d->title = GTK_ENTRY(gtk_entry_new());
534 gtk_entry_set_placeholder_text(
d->title,
"untitled");
535 gtk_entry_set_width_chars(
d->title, 5);
536 gtk_widget_set_hexpand(GTK_WIDGET(
d->title),
TRUE);
537 gtk_grid_attach(grid, GTK_WIDGET(
d->title), 1, line, 1, 1);
538 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->title), _(
"enter the title of the pdf"));
542 gtk_entry_set_text(GTK_ENTRY(
d->title), str);
553 gtk_grid_attach(grid, GTK_WIDGET(
d->size), 0, ++line, 2, 1);
555 gtk_widget_set_tooltip_text(
d->size, _(
"paper size of the pdf\neither one from the list or "
556 "\"<width> [unit] x <height> <unit>\n"
557 "example: 210 mm x 2.97 cm"));
568 gtk_grid_attach(grid, GTK_WIDGET(
d->orientation), 0, ++line, 2, 1);
570 gtk_widget_set_tooltip_text(
d->orientation, _(
"paper orientation of the pdf"));
577 d->border = GTK_ENTRY(gtk_entry_new());
579 gtk_entry_set_width_chars(
d->border, 5);
581 gtk_entry_set_placeholder_text(
d->border,
"0 mm");
582 gtk_grid_attach(grid, GTK_WIDGET(
d->border), 1, line, 1, 1);
583 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->border), _(
"empty space around the pdf\n"
584 "format: size + unit\nexamples: 10 mm, 1 inch"));
588 gtk_entry_set_text(GTK_ENTRY(
d->border), str);
596 d->dpi = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(1, 5000, 1));
597 gtk_grid_attach(grid, GTK_WIDGET(
d->dpi), 1, line, 1, 1);
598 gtk_widget_set_tooltip_text(GTK_WIDGET(
d->dpi), _(
"dpi of the images inside the pdf"));
599 gtk_spin_button_set_value(
d->dpi,
dt_conf_get_float(
"plugins/imageio/format/pdf/dpi"));
608 gtk_grid_attach(grid, GTK_WIDGET(
d->rotate), 0, ++line, 2, 1);
610 gtk_widget_set_tooltip_text(
d->rotate, _(
"images can be rotated to match the pdf orientation "
611 "to waste less space when printing"));
623 gtk_widget_set_tooltip_text(
d->pages, _(
"what pages should be added to the pdf"));
625 gtk_widget_set_sensitive(
d->pages,
FALSE);
633 gtk_grid_attach(grid, GTK_WIDGET(
d->icc), 0, ++line, 2, 1);
635 gtk_widget_set_tooltip_text(
d->icc, _(
"images can be tagged with their icc profile"));
649 gtk_grid_attach(grid, GTK_WIDGET(
d->bpp), 0, ++line, 2, 1);
651 gtk_widget_set_tooltip_text(
d->bpp, _(
"bits per channel of the embedded images"));
660 gtk_grid_attach(grid, GTK_WIDGET(
d->compression), 0, ++line, 2, 1);
662 gtk_widget_set_tooltip_text(
d->compression, _(
"method used for image compression\n"
663 "uncompressed -- fast but big files\n"
664 "deflate -- smaller files but slower"));
674 gtk_grid_attach(grid, GTK_WIDGET(
d->mode), 0, ++line, 2, 1);
676 gtk_widget_set_tooltip_text(
d->mode, _(
"normal -- just put the images into the pdf\n"
677 "draft -- images are replaced with boxes\n"
678 "debug -- only show the outlines and bounding boxen"));
715 g_strlcpy(
d->params.title, text,
sizeof(
d->params.title));
718 g_strlcpy(
d->params.border, text,
sizeof(
d->params.border));
721 g_strlcpy(
d->params.size, text,
sizeof(
d->params.size));
724 d->params.compression =
dt_conf_get_int(
"plugins/imageio/format/pdf/compression");
728 d->params.orientation =
dt_conf_get_int(
"plugins/imageio/format/pdf/orientation");
748 if(
d->actual_filename)
750 g_unlink(
d->actual_filename);
755 d->icc_profiles = NULL;
759 d->actual_filename = NULL;
760 d->icc_profiles = NULL;
767 if(
size != self->params_size(self))
return 1;
777 gtk_entry_set_text(
g->title,
d->params.title);
778 gtk_entry_set_text(
g->border,
d->params.border);
780 gtk_spin_button_set_value(
g->dpi,
d->params.dpi);
791 dt_conf_set_int(
"plugins/imageio/format/pdf/compression",
d->params.compression);
795 dt_conf_set_int(
"plugins/imageio/format/pdf/orientation",
d->params.orientation);
void dt_bauhaus_combobox_set_editable(GtkWidget *widget, int editable)
const char * dt_bauhaus_combobox_get_entry(GtkWidget *widget, int pos)
int dt_bauhaus_combobox_get(GtkWidget *widget)
int dt_bauhaus_combobox_length(GtkWidget *widget)
const char * dt_bauhaus_combobox_get_text(GtkWidget *widget)
void dt_bauhaus_combobox_set(GtkWidget *widget, const int pos)
void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *label)
GtkWidget * dt_bauhaus_combobox_new(dt_bauhaus_t *bh, dt_gui_module_t *self)
void dt_bauhaus_combobox_add(GtkWidget *widget, const char *text)
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
const dt_colorspaces_color_profile_t * dt_colorspaces_get_output_profile(const int32_t imgid, dt_colorspaces_color_profile_type_t *over_type, const char *over_filename)
dt_colorspaces_color_profile_type_t
dt_pdf_page_t * dt_pdf_add_page(dt_pdf_t *pdf, dt_pdf_image_t **images, int n_images)
dt_pdf_image_t * dt_pdf_add_image(dt_pdf_t *pdf, const unsigned char *image, int width, int height, int bpp, int icc_id, float border)
int dt_pdf_parse_length(const char *str, float *length)
int dt_pdf_add_icc_from_data(dt_pdf_t *pdf, const unsigned char *data, size_t size)
int dt_pdf_parse_paper_size(const char *str, float *width, float *height)
void dt_pdf_finish(dt_pdf_t *pdf, dt_pdf_page_t **pages, int n_pages)
dt_pdf_t * dt_pdf_start(const char *filename, float width, float height, float dpi, dt_pdf_stream_encoder_t default_encoder)
void dt_conf_set_bool(const char *name, int val)
int dt_conf_get_bool(const char *name)
void dt_conf_set_float(const char *name, float val)
float dt_conf_get_float(const char *name)
gchar * dt_conf_get_string(const char *name)
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
void dt_conf_set_string(const char *name, const char *val)
const char * dt_conf_get_string_const(const char *name)
void dt_control_log(const char *msg,...)
#define dt_pixelpipe_cache_alloc_align_cache(size, id)
#define DT_MODULE(MODVER)
static void dt_free_gpointer(gpointer ptr)
#define dt_pixelpipe_cache_free_align(mem)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
void dt_accels_disconnect_on_text_input(GtkWidget *widget)
Disconnects accels when a text or search entry gets the focus, and reconnects them when it looses it....
#define DT_GUI_BOX_SPACING
static GtkWidget * dt_ui_label_new(const gchar *str)
@ FORMAT_FLAGS_NO_TMPFILE
dt_mipmap_buffer_dsc_flags flags
#define dt_pdf_point_to_pixel(pt, dpi)
static const int dt_pdf_paper_sizes_n
static const struct @11 dt_pdf_paper_sizes[]
@ DT_PDF_STREAM_ENCODER_FLATE
struct _GtkWidget GtkWidget
const dt_colorspaces_color_profile_t * profile
struct dt_bauhaus_t * bauhaus
dt_imageio_module_data_t global
dt_pdf_stream_encoder_t compression
_pdf_orientation_t orientation
dt_imageio_pdf_params_t params