cairo-renderer-pdf-out.cpp revision 57e8d5fd57a890842b51a13207e222fcf953816c
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * A quick hack to use the Cairo renderer to write out a file. This
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * then makes 'save as...' PDF.
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz * Ted Gould <ted@gould.cx>
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Ulf Erikson <ulferikson@users.sf.net>
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Johan Engelen <goejendaagh@zonnet.nl>
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Copyright (C) 2004-2010 Authors
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh * Released under GNU GPL, read the file 'COPYING' for more information
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshCairoRendererPdfOutput::check (Inkscape::Extension::Extension * module)
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh if (NULL == Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer"))
3711b3e25395437ee0a09dbbb2a76d999c4ef322mikloshpdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level,
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh bool texttopath, bool omittext, bool filtertobitmap, int resolution,
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh const gchar * const exportId, bool exportDrawing, bool exportCanvas)
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh // we want to export the given item only
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh // we want to export the entire document from root
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh return false;
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh /* Create new arena */
1cda9431ef400135f5e1bd899a94b921bdad0eafmiklosh sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
68664e00e2372534b4df2fdc5f54f836bafece18miklosh /* Create renderer and context */
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz CairoRenderContext *ctx = renderer->createContext();
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh /* Render document */
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
cb814cb0df20053ca3ef16ce55da474435daf045miklosh /* Release arena */
1667116521643e2475184b048e0abb77a2aa9735miklosh \brief This function calls the output module with the filename
1667116521643e2475184b048e0abb77a2aa9735miklosh \param mod unused
1667116521643e2475184b048e0abb77a2aa9735miklosh \param doc Document to be saved
1667116521643e2475184b048e0abb77a2aa9735miklosh \param filename Filename to save to (probably will end in .pdf)
75b857d473541532819bd791105cb352c9a43214buliabyak The most interesting thing that this function does is just attach
75b857d473541532819bd791105cb352c9a43214buliabyak an '>' on the front of the filename. This is the syntax used to
75b857d473541532819bd791105cb352c9a43214buliabyak tell the printing system to save to file.
84d6d1f7365e49f2936df9df890ce49d2c000ce2KrisCairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
75b857d473541532819bd791105cb352c9a43214buliabyak unsigned int ret;
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh ext = Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer");
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh// if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.x", new_level) == 0))
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh// level = 1;
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh catch(...) {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh// g_warning("Parameter <PDFversion> might not exist");
68664e00e2372534b4df2fdc5f54f836bafece18miklosh catch(...) {
68664e00e2372534b4df2fdc5f54f836bafece18miklosh g_warning("Parameter <textToPath> might not exist");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh new_textToLaTeX = mod->get_param_bool("textToLaTeX");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh catch(...) {
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh g_warning("Parameter <textToLaTeX> might not exist");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh new_blurToBitmap = mod->get_param_bool("blurToBitmap");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh catch(...) {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh g_warning("Parameter <blurToBitmap> might not exist");
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh new_bitmapResolution = mod->get_param_int("resolution");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh catch(...) {
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh g_warning("Parameter <resolution> might not exist");
1667116521643e2475184b048e0abb77a2aa9735miklosh catch(...) {
1667116521643e2475184b048e0abb77a2aa9735miklosh new_exportDrawing = mod->get_param_bool("areaDrawing");
1667116521643e2475184b048e0abb77a2aa9735miklosh catch(...) {
1667116521643e2475184b048e0abb77a2aa9735miklosh g_warning("Parameter <areaDrawing> might not exist");
1667116521643e2475184b048e0abb77a2aa9735miklosh catch(...) {
1667116521643e2475184b048e0abb77a2aa9735miklosh g_warning("Parameter <exportCanvas> might not exist");
c53f16f52840e8c0f2be9c1cc3af633c0ba1552emiklosh // Create PDF file
68664e00e2372534b4df2fdc5f54f836bafece18miklosh ret = pdf_render_document_to_file(doc, final_name, level,
68664e00e2372534b4df2fdc5f54f836bafece18miklosh new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution,
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh // Create LaTeX file (if requested)
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh \brief A function allocate a copy of this function.
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh This is the definition of Cairo PDF out. This function just
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh calls the extension system with the memory allocated XML that
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh describes the data.
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5johanengelen "<name>Portable Document Format</name>\n"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "</param>\n"
d27f5758e12c3107ee69e66702043931e0756f6bmiklosh "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
d27f5758e12c3107ee69e66702043931e0756f6bmiklosh "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
d27f5758e12c3107ee69e66702043931e0756f6bmiklosh "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">false</param>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">false</param>\n"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
b5b35fce2e3df933e5223ef6645d814eacf51cfamiklosh "<output>\n"
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen "<extension>.pdf</extension>\n"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh "<mimetype>application/pdf</mimetype>\n"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh "<filetypename>Portable Document Format (*.pdf)</filetypename>\n"
3711b3e25395437ee0a09dbbb2a76d999c4ef322miklosh "<filetypetooltip>PDF File</filetypetooltip>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "</output>\n"
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh "</inkscape-extension>", new CairoRendererPdfOutput());
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh} } } /* namespace Inkscape, Extension, Internal */
7a7fa095a483e8b652af9f00e5169f62c84f09b9miklosh#endif /* HAVE_CAIRO_PDF */