diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-01-13 08:24:56 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-01-13 08:24:56 +0000 |
commit | 54c54c6d0b45446d5def44645ee8f47c93f2f5e1 (patch) | |
tree | 5788a8c6ef63748b55f64444889ae56cb09ef983 /Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp | |
parent | d3850f75a016d3610f0170c7374a74ecad621851 (diff) |
dvisvgm 1.5.2
git-svn-id: svn://tug.org/texlive/trunk@32649 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp new file mode 100644 index 00000000000..cfe02f78deb --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.5.2/src/EPSToSVG.cpp @@ -0,0 +1,76 @@ +/************************************************************************* +** EPSToSVG.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> ** +** ** +** This program is free software; you can redistribute it and/or ** +** modify it under the terms of the GNU General Public License as ** +** published by the Free Software Foundation; either version 3 of ** +** the License, or (at your option) any later version. ** +** ** +** This program is distributed in the hope that it will be useful, but ** +** WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** +** GNU General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program; if not, see <http://www.gnu.org/licenses/>. ** +*************************************************************************/ + +#include <config.h> +#include <fstream> +#include <istream> +#include <sstream> +#include "EPSFile.h" +#include "EPSToSVG.h" +#include "Message.h" +#include "MessageException.h" +#include "PsSpecialHandler.h" +#include "SVGOutputBase.h" + +#ifdef TARGET_SYSTEM + #define VERSION_STR VERSION " (" TARGET_SYSTEM ")" +#else + #define VERSION_STR VERSION +#endif + + +using namespace std; + + +void EPSToSVG::convert () { + if (!Ghostscript().available()) + throw MessageException("Ghostscript is required to process the EPS file"); + EPSFile epsfile(_fname); + if (!epsfile.hasValidHeader()) + throw PSException("invalid EPS file"); + + BoundingBox bbox; + epsfile.bbox(bbox); + if (bbox.width() == 0 || bbox.height() == 0) + Message::wstream(true) << "bounding box of file " << _fname << " is empty\n"; + Message::mstream(false, Message::MC_PAGE_NUMBER) << "processing file " << _fname << '\n'; + Message::mstream().indent(1); + _svg.newPage(1); + // create a psfile special and forward it to the PsSpecialHandler + stringstream ss; + ss << "\"" << _fname << "\" " + "llx=" << bbox.minX() << " " + "lly=" << bbox.minY() << " " + "urx=" << bbox.maxX() << " " + "ury=" << bbox.maxY(); + PsSpecialHandler pshandler; + pshandler.process("psfile=", ss, this); + // output SVG file + _svg.setBBox(_bbox); + _svg.appendToDoc(new XMLCommentNode(" This file was generated by dvisvgm " VERSION_STR " ")); + _svg.write(_out.getPageStream(1, 1)); + string svgfname = _out.filename(1, 1); + Message::mstream(false, Message::MC_PAGE_SIZE) << "graphic size: " << XMLString(bbox.width()) << "pt" + " x " << XMLString(bbox.height()) << "pt" + " (" << XMLString(bbox.width()/72.27*25.4) << "mm" + " x " << XMLString(bbox.height()/72.27*25.4) << "mm)\n"; + Message::mstream(false, Message::MC_PAGE_WRITTEN) << "graphic written to " << (svgfname.empty() ? "<stdout>" : svgfname) << '\n'; +} + |