Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ncphp
/
mcClasses
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 10f507e3
authored
Dec 20, 2013
by
sn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* mcInkscape
* mcCairo
1 parent
60e4bad7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
8 deletions
file/class_mcCairoSvg.inc.php
file/class_mcFile.inc.php
file/class_mcInkscape.inc.php
file/class_mcCairoSvg.inc.php
View file @
10f507e
...
...
@@ -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
);
}
}
?>
file/class_mcFile.inc.php
View file @
10f507e
...
...
@@ -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
;
}
}
?>
file/class_mcInkscape.inc.php
View file @
10f507e
...
...
@@ -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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment