Commit 10f507e3 by sn

* mcInkscape

* mcCairo
1 parent 60e4bad7
......@@ -5,20 +5,31 @@ class mcCairoSvg {
*
* @param string $param_svgFileString
*/
public static function svgToPdf($param_in_svg, $param_out_pdf=false) {
public static function svgToPdf($param_in_svg, $param_out_dir=false, $param_out_pdf=false) {
if($param_out_pdf === false) {
$param_out_pdf = tempnam("/tmp", "mcInkscape_");
$tmp_png = $param_out_pdf.'.pdf';
mcFile::rename($param_out_pdf, $tmp_png);
$param_out_pdf = $tmp_png;
// $param_out_pdf = tempnam("/tmp", "mcInkscape_");
// $tmp_png = $param_out_pdf.'.pdf';
// mcFile::rename($param_out_pdf, $tmp_png);
// $param_out_pdf = $tmp_png;
$param_out_pdf = mcFile::createTmpFile('.pdf', 'mcCairo_', $param_out_dir);
}
$inkscape_order = "cairosvg.sh $param_in_svg $param_out_pdf";
$shell_exec = shell_exec($inkscape_order);
D::show($shell_exec, $inkscape_order);
// $inkscape_order = "cairosvg.sh $param_in_svg $param_out_pdf";
$inkscape_order = "python /home/dev/CairoSVG//cairosvg.py '".$param_in_svg."' -d 90 --output='".$param_out_pdf."' ";
// $shell_exec = shell_exec($inkscape_order);
$shell_exec = exec($inkscape_order, $ausgabe, $return_var);
D::show(array('$shell_exec' => $shell_exec, '$ausgabe'=>$ausgabe, '$return_var' => $return_var), $inkscape_order);
return $param_out_pdf;
}
public static function inkscapeSvgToPdf($param_in_svg, $param_out_dir=false, $param_out_pdf=false) {
$normalsvg_filename =mcInkscape::inkscapeSvgToNormalSvg($param_in_svg);
return mcCairoSvg::svgToPdf($normalsvg_filename, $param_out_dir, $param_out_pdf);
}
}
?>
......@@ -88,6 +88,21 @@ class mcFile {
}
}
/**
*
* @param string $param_filepostfix exampe: .pdf, .txt, .csv
* @param string $param_prefix
* @return string
*/
public static function createTmpFile($param_filepostfix='.tmp', $param_prefix='tmp_', $param_dir='/tmp/') {
$param_file = tempnam($param_dir, $param_prefix);
if($param_filepostfix) {
$tmp_filename = $param_file.$param_filepostfix;
// @todo tempfile auch noch mal überprüfen, das es nicht existiert
mcFile::rename($param_file, $tmp_filename);
}
return $tmp_filename;
}
}
?>
......@@ -47,6 +47,19 @@ class mcInkscape {
return mcImage::pngToJpg($new_png, $param_out_jpg, $param_quality);
}
public static function inkscapeSvgToNormalSvg($param_in_svg, $param_out_dir=false, $param_out_filename=false, $param_filenamePrefix='normalSvg_') {
if($param_out_filename === false) {
$param_out_filename = mcFile::createTmpFile('.svg', $param_filenamePrefix, $param_out_dir);
}
$inkscape_order = "inkscape -T $param_in_svg -l $param_out_filename";
$shell_exec = shell_exec($inkscape_order);
D::show($shell_exec, $inkscape_order);
return $param_out_filename;
}
}
?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!