summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d898417)
raw | patch | inline | side by side (parent: d898417)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 16 Apr 2008 06:43:33 +0000 (06:43 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 16 Apr 2008 06:43:33 +0000 (06:43 +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 b6ae0b6b229e45193689965a01c9846bffd0580b..71e9eda171133127d3c0c1ca2e4baf44fba6bb9d 100644 (file)
/* Create new arena */
const gchar* exportId = mod->get_param_string("exportId");
bool exportDrawing = mod->get_param_bool("exportDrawing");
+ bool exportCanvas = mod->get_param_bool("exportCanvas");
if (exportId && strcmp(exportId, "")) {
- // we want to export the given item only, not page
+ // we want to export the given item only
mod->base = SP_ITEM(doc->getObjectById(exportId));
- mod->set_param_bool("pageBoundingBox", FALSE);
+ if (exportCanvas)
+ mod->set_param_bool("pageBoundingBox", TRUE);
+ else
+ mod->set_param_bool("pageBoundingBox", FALSE);
} else {
// we want to export the entire document from root
mod->base = SP_ITEM(sp_document_root(doc));
@@ -166,6 +170,17 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
g_warning("Parameter <exportDrawing> might not exist");
}
+ bool old_exportCanvas = false;
+ bool new_exportCanvas = false;
+ try {
+ old_exportCanvas = ext->get_param_bool("exportCanvas");
+ new_exportCanvas = mod->get_param_bool("exportCanvas");
+ ext->set_param_bool("exportCanvas", new_exportCanvas);
+ }
+ catch(...) {
+ g_warning("Parameter <exportCanvas> might not exist");
+ }
+
gchar * final_name;
final_name = g_strdup_printf("> %s", uri);
ret = pdf_print_document_to_file(doc, final_name, 0, new_textToPath, new_blurToBitmap);
@@ -195,6 +210,12 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
catch(...) {
g_warning("Parameter <exportDrawing> might not exist");
}
+ try {
+ ext->set_param_bool("exportCanvas", old_exportCanvas);
+ }
+ catch(...) {
+ g_warning("Parameter <exportCanvas> might not exist");
+ }
if (!ret)
throw Inkscape::Extension::Output::save_failed();
"<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"
"<param name=\"exportDrawing\" gui-text=\"" N_("Export drawing, not page") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"exportCanvas\" gui-text=\"" N_("Export canvas") "\" 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"
index 9d2608f22fabac7a433f3028521eb5c8f1cf66bf..f2a8483c27790e352fa5cfdfaedd6984c7e5dbe4 100644 (file)
_height = sp_document_height(doc) * PT_PER_PX;
NRRect d;
- bool pageBoundingBox;
- pageBoundingBox = mod->get_param_bool("pageBoundingBox");
+ bool pageBoundingBox = mod->get_param_bool("pageBoundingBox");
+ SPItem* doc_item = SP_ITEM(mod->base);
// printf("Page Bounding Box: %s\n", pageBoundingBox ? "TRUE" : "FALSE");
NR::Matrix t (NR::identity());
if (pageBoundingBox) {
d.y1 = _height;
} else {
// 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_i2doc_affine (doc_item), TRUE);
// convert from px to pt
d.x0 *= PT_PER_PX;
d.x1 *= PT_PER_PX;
d.y0 *= PT_PER_PX;
d.y1 *= PT_PER_PX;
+ }
- // When rendering a standalone object, we must set cairo's transform to the accumulated
- // ancestor transform of that item - e.g. it may be rotated or skewed by its parent group, and
- // we must reproduce that in the export even though we start traversing the tree from the
- // object itself, ignoring its ancestors
+ // When rendering a standalone object, we must set cairo's transform to the accumulated
+ // ancestor transform of that item - e.g. it may be rotated or skewed by its parent group, and
+ // we must reproduce that in the export even though we start traversing the tree from the
+ // object itself, ignoring its ancestors
- // complete transform, including doc_item's own transform
- t = sp_item_i2doc_affine (doc_item);
- // subreact doc_item's transform (comes first) from it
- t = NR::Matrix(doc_item->transform).inverse() * t;
- }
+ // complete transform, including doc_item's own transform
+ t = sp_item_i2doc_affine (doc_item);
+ // subreact doc_item's transform (comes first) from it
+ t = NR::Matrix(doc_item->transform).inverse() * t;
// create cairo context
pdf_surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, d.x1-d.x0, d.y1-d.y0);
"<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=\"exportCanvas\" 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 b5ed8305dabff9207613b40face5782c951411cc..bf1662c3121e06a047d35907be7f04307f9b2fde 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1255,6 +1255,12 @@ static void do_export_pdf(SPDocument* doc, gchar const* uri, char const* mime)
(*i)->set_param_bool ("exportDrawing", FALSE);
}
+ if (sp_export_area_canvas) {
+ (*i)->set_param_bool ("exportCanvas", TRUE);
+ } else {
+ (*i)->set_param_bool ("exportCanvas", FALSE);
+ }
+
(*i)->save(doc, uri);
}