summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 546e02a)
raw | patch | inline | side by side (parent: 546e02a)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 10:21:18 +0000 (11:21 +0100) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 10:21:18 +0000 (11:21 +0100) |
src/extension/internal/cairo-renderer-pdf-out.cpp | patch | blob | history | |
src/extension/internal/pdflatex-renderer.cpp | patch | blob | history |
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index f308f58ca82f601fa6f04c0416ad6bae283a3511..594389c60f7f83cf6e7dba105d5c7172c0f8f2bb 100644 (file)
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
gchar * tex_filename;
- tex_filename = g_strdup_printf("%s.tex", filename);
+ //strip filename of ".pdf", do not add ".tex" here.
+ gsize n = g_str_has_suffix(filename, ".pdf") ? strlen(filename)-4 : strlen(filename);
+ tex_filename = g_strndup(filename, n);
ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas);
g_free(tex_filename);
diff --git a/src/extension/internal/pdflatex-renderer.cpp b/src/extension/internal/pdflatex-renderer.cpp
index 60b960ddb86c7e953e7e8e4bf5bcefafe2b07ba3..0d2ffcc94e2a02956b0d3d7253defbcbfbe08894 100644 (file)
while (isspace(*filename)) filename += 1;
_filename = g_strdup(filename);
- Inkscape::IO::dump_fopen_call(filename, "K");
- FILE *osf = Inkscape::IO::fopen_utf8name(filename, "w+");
+
+ gchar *filename_ext = g_strdup_printf("%s.tex", filename);
+ Inkscape::IO::dump_fopen_call(filename_ext, "K");
+ FILE *osf = Inkscape::IO::fopen_utf8name(filename_ext, "w+");
if (!osf) {
fprintf(stderr, "inkscape: fopen(%s): %s\n",
- filename, strerror(errno));
+ filename_ext, strerror(errno));
return false;
}
_stream = osf;
+ g_free(filename_ext);
}
if (_stream) {
fprintf(_stream, "%%%% Creator: Inkscape %s, www.inkscape.org\n", PACKAGE_STRING);
fprintf(_stream, "%%%% PDF + LaTeX output extension by Johan Engelen, 2010\n");
+ fprintf(_stream, "%%%% Accompanies %s.pdf\n", _filename);
/* flush this to test output stream as early as possible */
if (fflush(_stream)) {
if (ferror(_stream)) {
{
fprintf(_stream, "%s", postamble1);
- // TODO: strip path from filename on Windows
- fprintf(_stream, " \\put(0,0){\\includegraphics{%s.pdf}}%%\n", _filename);
+ // strip pathname on windows, as it is probably desired. It is not possible to work without paths on windows yet. (bug)
+#ifdef WIN32
+ gchar *figurefile = g_path_get_basename(_filename);
+#else
+ gchar *figurefile = g_strdup(_filename);
+#endif
+ fprintf(_stream, " \\put(0,0){\\includegraphics{%s.pdf}}%%\n", figurefile);
+ g_free(figurefile);
fprintf(_stream, "%s", postamble2);
}