summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 976cb08)
raw | patch | inline | side by side (parent: 976cb08)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 12 Mar 2008 07:57:33 +0000 (07:57 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 12 Mar 2008 07:57:33 +0000 (07:57 +0000) |
src/extension/internal/cairo-pdf-out.cpp | patch | blob | history | |
src/extension/internal/pdf-cairo.cpp | patch | blob | history | |
src/main.cpp | patch | blob | history |
index ed710346ff3ebcb0b71aa938680c8c732600422a..455230dad6afc712721e0dbe448f5670fcc980b8 100644 (file)
context.module = mod;
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
- mod->base = SP_ITEM(sp_document_root(doc));
+ const gchar* exportId = mod->get_param_string("exportId");
+ bool exportDrawing = mod->get_param_bool("exportDrawing");
+ if (exportId && strcmp(exportId, "")) {
+ // we want to export the given item only, not page
+ mod->base = SP_ITEM(doc->getObjectById(exportId));
+ mod->set_param_bool("pageBoundingBox", FALSE);
+ } else {
+ // we want to export the entire document from root
+ mod->base = SP_ITEM(sp_document_root(doc));
+ if (exportDrawing)
+ mod->set_param_bool("pageBoundingBox", FALSE);
+ else
+ mod->set_param_bool("pageBoundingBox", TRUE);
+ }
mod->arena = NRArena::create();
mod->dkey = sp_item_display_key_new(1);
mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
@@ -117,7 +130,7 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
ext->set_param_bool("textToPath", new_textToPath);
}
catch(...) {
- g_warning("Parameter <textToPath> might not exists");
+ g_warning("Parameter <textToPath> might not exist");
}
bool old_blurToBitmap = FALSE;
@@ -128,7 +141,29 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
ext->set_param_bool("blurToBitmap", new_blurToBitmap);
}
catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
+ g_warning("Parameter <blurToBitmap> might not exist");
+ }
+
+ const gchar* old_exportId = NULL;
+ const gchar* new_exportId = NULL;
+ try {
+ old_exportId = ext->get_param_string("exportId");
+ new_exportId = mod->get_param_string("exportId");
+ ext->set_param_string("exportId", new_exportId);
+ }
+ catch(...) {
+ g_warning("Parameter <exportId> might not exist");
+ }
+
+ bool old_exportDrawing = NULL;
+ bool new_exportDrawing = NULL;
+ try {
+ old_exportDrawing = ext->get_param_bool("exportDrawing");
+ new_exportDrawing = mod->get_param_bool("exportDrawing");
+ ext->set_param_bool("exportDrawing", new_exportDrawing);
+ }
+ catch(...) {
+ g_warning("Parameter <exportDrawing> might not exist");
}
gchar * final_name;
@@ -140,13 +175,25 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
ext->set_param_bool("blurToBitmap", old_blurToBitmap);
}
catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
+ g_warning("Parameter <blurToBitmap> might not exist");
}
try {
ext->set_param_bool("textToPath", old_textToPath);
}
catch(...) {
- g_warning("Parameter <textToPath> might not exists");
+ g_warning("Parameter <textToPath> might not exist");
+ }
+ try {
+ ext->set_param_string("exportId", old_exportId);
+ }
+ catch(...) {
+ g_warning("Parameter <exportId> might not exist");
+ }
+ try {
+ ext->set_param_bool("exportDrawing", old_exportDrawing);
+ }
+ catch(...) {
+ g_warning("Parameter <exportDrawing> might not exist");
}
if (!ret)
"<id>org.inkscape.output.pdf.cairo</id>\n"
"<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version") "\" type=\"enum\" >\n"
"<item value='PDF14'>" N_("PDF 1.4") "</item>\n"
- "</param>\n"
+ "</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert blur effects to bitmaps") "\" type=\"boolean\">false</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Preferred resolution (DPI) of bitmaps") "\" type=\"int\" min=\"72\" max=\"2400\">90</param>\n"
- "<output>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Preferred resolution (DPI) of bitmaps") "\" type=\"int\" min=\"72\" max=\"2400\">90</param>\n"
+ "<param name=\"exportDrawing\" gui-text=\"" N_("Export drawing, not page") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
+ "<output>\n"
"<extension>.pdf</extension>\n"
"<mimetype>application/pdf</mimetype>\n"
"<filetypename>" N_("PDF via Cairo (*.pdf)") "</filetypename>\n"
index 620961d3bb5cdfc02493433cae6234b9c0480de1..f189d6b6b95b62af1978306e7929b477b6934db0 100644 (file)
d.x1 = _width;
d.y1 = _height;
} else {
- SPItem* doc_item = SP_ITEM(sp_document_root(doc));
- sp_item_invoke_bbox(doc_item, &d, sp_item_i2r_affine(doc_item), TRUE);
+ // if not page, use our base, which is either root or the item we want to export
+ SPItem* doc_item = SP_ITEM(mod->base);
+ sp_item_invoke_bbox(doc_item, &d, sp_item_i2root_affine(doc_item), TRUE);
// convert from px to pt
d.x0 *= PT_PER_PX;
d.x1 *= PT_PER_PX;
// printf("\n _width:%f _height:%f scale:%f\n", _width, _height, PT_PER_PX);
pdf_surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, d.x1-d.x0, d.y1-d.y0);
cr = cairo_create(pdf_surface);
+ // move to the origin
+ cairo_translate (cr, -d.x0, -d.y0);
if (!_bitmap) {
cairo_scale(cr, PT_PER_PX, PT_PER_PX);
"<param name=\"destination\" type=\"string\">| lp</param>\n"
"<param name=\"pageBoundingBox\" type=\"boolean\">TRUE</param>\n"
"<param name=\"textToPath\" type=\"boolean\">TRUE</param>\n"
+ "<param name=\"exportDrawing\" type=\"boolean\">FALSE</param>\n"
+ "<param name=\"exportId\" type=\"string\"></param>\n"
"<print/>\n"
"</inkscape-extension>", new PrintCairoPDF());
}
diff --git a/src/main.cpp b/src/main.cpp
index 4580b7271a4e1cef1f7e27ec3b66d82c785a5285..df62e8d0dbdf62d274d228d4d8ec40951e91dd8c 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
if (sp_global_printer) {
sp_print_document_to_file(doc, sp_global_printer);
}
- if (sp_export_png || sp_export_id || sp_export_area_drawing) {
+ if (sp_export_png) {
sp_do_export_png(doc);
}
if (sp_export_svg) {
if (i == o.end())
{
- g_warning ("Could not find an extension to export this file.");
+ g_warning ("Could not find an extension to export to MIME type %s.", mime);
return;
}
@@ -1181,10 +1181,27 @@ static void do_export_pdf(SPDocument* doc, gchar const* uri, char const* mime)
if (i == o.end())
{
- g_warning ("Could not find an extension to export this file.");
+ g_warning ("Could not find an extension to export to MIME type %s.", mime);
return;
}
+ if (sp_export_id) {
+ SPObject *o = doc->getObjectById(sp_export_id);
+ if (o == NULL) {
+ g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id);
+ return;
+ }
+ (*i)->set_param_string ("exportId", sp_export_id);
+ } else {
+ (*i)->set_param_string ("exportId", "");
+ }
+
+ if (sp_export_area_drawing) {
+ (*i)->set_param_bool ("exportDrawing", TRUE);
+ } else {
+ (*i)->set_param_bool ("exportDrawing", FALSE);
+ }
+
(*i)->save(doc, uri);
}
@@ -1208,7 +1225,7 @@ static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime)
if (i == o.end())
{
- g_warning ("Could not find an extension to export this file.");
+ g_warning ("Could not find an extension to export to MIME type %s.", mime);
return;
}