Convert basic SWF Shapes to SVG - php

I would export programmatically (in PHP) the content of a SWF file to a SVG format. So, I tried first to export each shapes composing my file to be abble to create the static sprites later.
For that, I use the IO_SWF library to read the content of the swf file.
FillStyles:
[1] solid fill: #d9d2c5(ff)
[2] solid fill: #8e7e66(ff)
[3] solid fill: #b9ae9a(ff)
[4] solid fill: #716044(ff)
LineStyles:
(none)
ShapeRecords:
ChangeStyle: MoveTo: (6.95, -10) FillStyle: 0|2 LineStyle: 0
StraightEdge: MoveTo: (7, -9.95)
StraightEdge: MoveTo: (7.2, -9.65)
StraightEdge: MoveTo: (7.1, -9.45)
StraightEdge: MoveTo: (6.85, -9)
ChangeStyle: MoveTo: (6.85, -9) FillStyle: 0|3 LineStyle: 0
CurvedEdge: MoveTo: Control(6.8, -7.95) Anchor(6.9, -7.15)
StraightEdge: MoveTo: (6.95, -6.25)
StraightEdge: MoveTo: (6.95, -6.15)
StraightEdge: MoveTo: (7, -6.15)
ChangeStyle: MoveTo: (7, -6.15) FillStyle: 0|1 LineStyle: 0
StraightEdge: MoveTo: (6.95, -5.85)
ChangeStyle: MoveTo: (6.95, -5.85) FillStyle: 0|2 LineStyle: 0
StraightEdge: MoveTo: (6.5, -5.2)
StraightEdge: MoveTo: (4.15, -2.3)
StraightEdge: MoveTo: (3.55, -2.15)
ChangeStyle: MoveTo: (3.55, -2.15) FillStyle: 0|4 LineStyle: 0
CurvedEdge: MoveTo: Control(3.7, -3.9) Anchor(5.35, -8.85)
StraightEdge: MoveTo: (6.45, -10.85)
CurvedEdge: MoveTo: Control(6.55, -10.45) Anchor(6.95, -10)
ChangeStyle: MoveTo: (6.95, -10) FillStyle: 2|4 LineStyle: 0
StraightEdge: MoveTo: (6.2, -8.9)
ChangeStyle: MoveTo: (6.2, -8.9) FillStyle: 2|3 LineStyle: 0
StraightEdge: MoveTo: (6.85, -9)
ChangeStyle: MoveTo: (6.2, -8.9) FillStyle: 3|4 LineStyle: 0
StraightEdge: MoveTo: (6.15, -7.85)
StraightEdge: MoveTo: (6.15, -7.7)
StraightEdge: MoveTo: (6.2, -7.55)
StraightEdge: MoveTo: (6.2, -6.9)
StraightEdge: MoveTo: (6.25, -6.75)
ChangeStyle: MoveTo: (6.25, -6.75) FillStyle: 3|1 LineStyle: 0
StraightEdge: MoveTo: (6.35, -6.2)
CurvedEdge: MoveTo: Control(6.4, -6) Anchor(6.7, -5.95)
StraightEdge: MoveTo: (7, -6.15)
ChangeStyle: MoveTo: (4.4, -3.2) FillStyle: 2|4 LineStyle: 0
StraightEdge: MoveTo: (4.15, -2.95)
StraightEdge: MoveTo: (3.55, -2.15)
ChangeStyle: MoveTo: (6.95, -5.85) FillStyle: 2|1 LineStyle: 0
StraightEdge: MoveTo: (6.95, -5.9)
StraightEdge: MoveTo: (6.8, -5.95)
StraightEdge: MoveTo: (6.7, -5.95)
StraightEdge: MoveTo: (6.5, -5.9)
StraightEdge: MoveTo: (6.3, -5.8)
StraightEdge: MoveTo: (4.4, -3.2)
ChangeStyle: MoveTo: (4.4, -3.2) FillStyle: 4|1 LineStyle: 0
StraightEdge: MoveTo: (6.15, -5.85)
StraightEdge: MoveTo: (6.25, -6.75)
ChangeStyle: MoveTo: (0, 0) FillStyle: 0|0 LineStyle: 0
After some research, I understood how to build a svg (composed by path tags) from these data.
ChangeStyle => start a new path => M x,y
StraightEdge => line => L x,y
CurvedEdge => curve => Q cx,cy,ax,ay
And for each path:
FillStyle: {FillStyle0} | {FillStyle1} (0 => no fill style)
The index is related to the FillStyles array
LineStyle: {LineStyle} (0 => line style)
The index is related to the LineStyles array
But this is not the correct way to browse the structure.
Using JPEXS Decompiler to manually export the previous sample shape, I get a perfect traced SVG.
Here is a comparative:
My result vs what is expected
My resulting svg:
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -10 L 7 -9.95 L 7.2 -9.65 L 7.1 -9.45 L 6.85 -9 L 6.95 -10" />
<path fill="rgba(217, 210, 197, 1)" fill-rule="evenodd" stroke="none" d="M 6.85 -9 Q 6.8 -7.95 6.9 -7.15 L 6.95 -6.25 L 6.95 -6.15 L 7 -6.15 L 6.85 -9" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 7 -6.15 L 6.95 -5.85 L 7 -6.15" />
<path fill="rgba(113, 96, 68, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -5.85 L 6.5 -5.2 L 4.15 -2.3 L 3.55 -2.15 L 6.95 -5.85" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 3.55 -2.15 Q 3.7 -3.9 5.35 -8.85 L 6.45 -10.85 Q 6.55 -10.45 6.95 -10 L 3.55 -2.15" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -10 L 6.2 -8.9 L 6.95 -10" />
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.2 -8.9 L 6.85 -9 L 6.2 -8.9" />
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.2 -8.9 L 6.15 -7.85 L 6.15 -7.7 L 6.2 -7.55 L 6.2 -6.9 L 6.25 -6.75 L 6.2 -8.9" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 6.25 -6.75 L 6.35 -6.2 Q 6.4 -6 6.7 -5.95 L 7 -6.15 L 6.25 -6.75" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 4.4 -3.2 L 4.15 -2.95 L 3.55 -2.15 L 4.4 -3.2" />
<path fill="rgba(113, 96, 68, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -5.85 L 6.95 -5.9 L 6.8 -5.95 L 6.7 -5.95 L 6.5 -5.9 L 6.3 -5.8 L 4.4 -3.2 L 6.95 -5.85" />
And the JPEXS result:
<path d="M7.0 -6.15 L6.95 -5.85 6.95 -5.9 6.8 -5.95 6.7 -5.95 6.5 -5.9 6.3 -5.8 4.4 -3.2 6.15 -5.85 6.25 -6.75 6.35 -6.2 Q6.4 -6.0 6.7 -5.95 L7.0 -6.15" fill="#d9d2c5" fill-rule="evenodd" stroke="none" />
<path d="M6.95 -10.0 L7.0 -9.95 7.2 -9.65 7.1 -9.45 6.85 -9.0 6.2 -8.9 6.95 -10.0 M6.95 -5.85 L6.5 -5.2 4.15 -2.3 3.55 -2.15 4.15 -2.95 4.4 -3.2 6.3 -5.8 6.5 -5.9 6.7 -5.95 6.8 -5.95 6.95 -5.9 6.95 -5.85" fill="#8e7e66" fill-rule="evenodd" stroke="none" />
<path d="M6.85 -9.0 Q6.8 -7.95 6.9 -7.15 L6.95 -6.25 6.95 -6.15 7.0 -6.15 6.7 -5.95 Q6.4 -6.0 6.35 -6.2 L6.25 -6.75 6.2 -6.9 6.2 -7.55 6.15 -7.7 6.15 -7.85 6.2 -8.9 6.85 -9.0" fill="#b9ae9a" fill-rule="evenodd" stroke="none" />
<path d="M3.55 -2.15 Q3.7 -3.9 5.35 -8.85 L6.45 -10.85 Q6.55 -10.45 6.95 -10.0 L6.2 -8.9 6.15 -7.85 6.15 -7.7 6.2 -7.55 6.2 -6.9 6.25 -6.75 6.15 -5.85 4.4 -3.2 4.15 -2.95 3.55 -2.15" fill="#716044" fill-rule="evenodd" stroke="none" />
All in all, how could I obtain the same well formed SVG from my data structure? I'm pretty sure there's a subtility with FillStyle0 and FillStyle1, but which?
Thanks for your help.

Related

php imagick error - must specify image size

I have a problem. I have svg code. I need to convert it to png. I get an error when converting it. On the product server it works fine (no docker there). Now I'm trying to do it all through docker.
Error
must specify image size `/tmp/magick-pvKVqqZOgZLEImdlmik0Tl8aUFPkNFlM' # error/mvg.c/ReadMVGImage/186
Code
$imagick = new Imagick();
$imagick->readImageBlob($svg);
Dockerfile
FROM composer:2.1 AS composer
FROM php:7.3-fpm as base
RUN apt update && apt install -y --no-install-recommends \
git \
openssh-client \
libzip-dev \
libpq-dev \
unzip \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libmagickwand-dev \
ffmpeg && \
rm -r /var/lib/apt/lists/*
# PHP extensions
RUN pecl install pcov
COPY php.ini /usr/local/etc/php/conf.d/40-custom.ini
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd && \
docker-php-ext-configure opcache --enable-opcache && \
docker-php-ext-install zip pdo_pgsql pdo_mysql mysqli bcmath opcache gd exif && \
docker-php-ext-enable zip pdo_mysql mysqli opcache gd pdo_pgsql pcov
WORKDIR /var/www/laravel9
ENV PATH="$PATH:/src/vendor/bin"
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY composer.* ./
RUN pecl install imagick && docker-php-ext-enable imagick
FROM base as prod
COPY . ./
RUN chgrp -R www-data storage bootstrap/cache && chmod -R ug+rwx storage bootstrap/cache \
&& composer dump-autoload --optimize
FROM base as dev
RUN composer install --no-scripts --no-autoloader --no-interaction --dev
COPY . ./
RUN chgrp -R www-data storage bootstrap/cache && chmod -R ug+rwx storage bootstrap/cache \
&& composer dump-autoload --optimize
svg
<svg xmlns="http://www.w3.org/2000/svg" border="0" data-ac-wrapper-id="1" width="100%" height="100%" class="anychart-ui-support" ac-id="ac_stage_0" style="display: block;"><defs></defs><g data-ac-wrapper-id="2" id="ac_layer_1"><g data-ac-wrapper-id="39" id="ac_layer_12"><path data-ac-wrapper-id="42" id="ac_path_15" fill="none" stroke="black" d="M 45.844 20 L 100.578 20 A 3 3 0 0 1 103.578 23 L 103.578 65 A 5 5 0 0 1 98.578 70 L 47.844 70 A 5 5 0 0 1 42.844 65 L 42.844 23 A 3 3 0 0 1 45.844 20 Z"></path><text data-ac-wrapper-id="43" font-family="Arial, Helvetica, sans-serif" font-size="14px" fill="#000" direction="ltr" text-anchor="start" x="52.58990625" y="50.75" id="ac_text_16" style="opacity: 1;"><tspan x="52.58990625" dy="0">П20лв</tspan></text><path data-ac-wrapper-id="44" id="ac_path_17" fill="none" stroke="black" d="M 42.844 56 L 103.578 56"></path><text data-ac-wrapper-id="45" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="69.539625" y="66.75" id="ac_text_18" style="opacity: 1; cursor: pointer;"><tspan x="69.539625" dy="0">X</tspan></text><text data-ac-wrapper-id="46" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="90.24165625" y="66.75" id="ac_text_19" style="opacity: 1; cursor: pointer;"><tspan x="90.24165625" dy="0">></tspan></text><path data-ac-wrapper-id="47" id="ac_path_1a" fill="none" stroke="black" d="M 52.514 90 L 73.211 70"></path><path data-ac-wrapper-id="50" id="ac_path_1d" fill="none" stroke="black" d="M 149.422 20 L 204.156 20 A 3 3 0 0 1 207.156 23 L 207.156 65 A 5 5 0 0 1 202.156 70 L 151.422 70 A 5 5 0 0 1 146.422 65 L 146.422 23 A 3 3 0 0 1 149.422 20 Z"></path><text data-ac-wrapper-id="51" font-family="Arial, Helvetica, sans-serif" font-size="14px" fill="#000" direction="ltr" text-anchor="start" x="151.62103125" y="50.75" id="ac_text_1e" style="opacity: 1;"><tspan x="151.62103125" dy="0">ДКР160</tspan></text><path data-ac-wrapper-id="52" id="ac_path_1f" fill="none" stroke="black" d="M 146.422 56 L 207.156 56"></path><text data-ac-wrapper-id="53" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="153.32965625" y="66.75" id="ac_text_1g" style="opacity: 1; cursor: pointer;"><tspan x="153.32965625" dy="0"><</tspan></text><text data-ac-wrapper-id="54" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="173.117625" y="66.75" id="ac_text_1h" style="opacity: 1; cursor: pointer;"><tspan x="173.117625" dy="0">X</tspan></text><path data-ac-wrapper-id="55" id="ac_path_1i" fill="none" stroke="black" d="M 142.514 90 L 176.789 70"></path><text data-ac-wrapper-id="57" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="red" direction="ltr" text-anchor="start" x="56.38678125" y="31.75" id="ac_text_1k" style="opacity: 1;"><tspan x="56.38678125" dy="0">14 690</tspan></text><text data-ac-wrapper-id="58" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="red" direction="ltr" text-anchor="start" x="156.9061875" y="31.75" id="ac_text_1l" style="opacity: 1;"><tspan x="156.9061875" dy="0">139 610</tspan></text></g><g data-ac-wrapper-id="40" id="ac_layer_13" transform="matrix(1,0,0,1,42.514,90)"><path data-ac-wrapper-id="41" id="ac_path_14" fill="none" stroke="black" d="M 8 0 L 12 0 A 8 8 0 0 1 20 8 L 20 102 A 8 8 0 0 1 12 110 L 8 110 A 8 8 0 0 1 -8.881784197001252e-16 102 L 0 8 A 8 8 0 0 1 8 1.7763568394002505e-15 Z"></path><path data-ac-wrapper-id="48" id="ac_path_1b" fill="none" stroke="black" d="M 28 0 L 172 0 A 8 8 0 0 1 180 8 L 180 27 A 8 8 0 0 1 172 35 L 28 35 A 8 8 0 0 1 20 27 L 20 8 A 8 8 0 0 1 28 1.7763568394002505e-15 Z"></path><path data-ac-wrapper-id="49" id="ac_path_1c" fill="none" stroke="black" d="M 28 35 L 172 35 A 8 8 0 0 1 180 43 L 180 107 A 8 8 0 0 1 172 115 L 28 115 A 8 8 0 0 1 20 107 L 20 43 A 8 8 0 0 1 28 35 Z"></path></g><g data-ac-wrapper-id="56" id="ac_layer_1j"></g></g></svg>

find variance of data array using php

I want to find variance of the values but i'm not able to find mean correctly. I added explode because while taking array_sum it was showing error that array_sum() expects parameter 1 to be array, string given.
<html><body>
<?php
$ap = '36.222.198.197.166.140';
$counte =0;$sum=0;
$file_handle = fopen("results.csv", "r");
while ( $line_of_text = fgetcsv($file_handle)){
if ($line_of_text[2] == $ap) {
$counte++;
$van = explode(" ",$line_of_text[3]);
$fMean = array_sum($van) / count($van);
print_r ($van);
}
}
fclose($file_handle);
?>
</body></html>
Here is csv format-
time1, time2, mac, 2.4ghz, 5ghz
1485874798, 1485878398, 36.222.198.197.166.140, -73, -72
1485874798, 1485878398, 148.180.15.200.220.114, -69, -65
1485874798, 1485878398, 148.180.15.194.95.70, -74, 0
1485874798, 1485878398, 0.36.108.195.38.227 0, -63
1485874798, 1485878398, 36.222.198.197.171.88, -73, -69
1485874798, 1485878398, 24.100.114.205.236.242, 0, 0
1485874798, 1485878398, 0.36.108.195.34.153 0, 0
1485874798, 1485878398, 148.180.15.200.220.118, -74, -64
1485874798, 1485878398, 0.36.108.195.38.220 0, -74
1485874798, 1485878398, 216.199.200.202.199.48, 0, -67
1485874798, 1485878398, 148.180.15.193.105.60, -62, -66
1485874798, 1485878398, 156.28.18.195.202.230, -74, -74
1485874798, 1485878398, 148.180.15.200.220.126, -73, -71
1485874798, 1485878398, 0.36.108.195.38.219 0, -60
1485874798, 1485878398, 0.36.108.195.38.217, -45, -63
1485874798, 1485878398, 0.36.108.195.38.218, -71, -73
1485874798, 1485878398, 0.36.108.195.38.216, 0, -74
1485874798, 1485878398, 0.36.108.195.33.193, 0, 0
1485874798, 1485878398, 148.180.15.200.220.190, -74, 0
1485874798, 1485878398, 36.222.198.197.166.138, -74, -68
1485874798, 1485878398, 0.36.108.195.33.197, 0, -72
1485874798, 1485878398, 36.222.198.197.171.18, -74, -74
1485874798, 1485878398, 0.36.108.195.33.58, 0, 0
1485874798, 1485878398, 0.36.108.195.33.199, -74, 0
1485874798, 1485878398, 0.36.108.195.31.214, -63, -69
1485874798, 1485878398, 148.180.15.200.220.198, 0, -69
1485874798, 1485878398, 0.36.108.195.31.218 -74, 0
1485874798, 1485878398, 0.36.108.195.35.135, 0, 0
1485874798, 1485878398, 36.222.198.197.171.68, -74, -67
1485874798, 1485878398, 148.180.15.194.97.50, -74, 0
1485874798, 1485878398, 216.199.200.202.200.152, -74, -74
1485874798, 1485878398, 148.180.15.193.134.238, -70, 0
1485874798, 1485878398, 0.36.108.195.35.131, 0, -42
1485874798, 1485878398, 36.222.198.197.170.202, -73, -73
1485874798, 1485878398, 148.180.15.200.220.78, -74, -70
1485874798, 1485878398, 36.222.198.197.170.100, -73, -66
1485874798, 1485878398, 0.36.108.195.30.123, -74, -66
You have inconsistencies in your data:
The first two lines have commas as separators, while the other lines have not.
The second line has an IP address that ends with a dot.
The expression explode(" ",$line_of_text[3]); makes no sense, as $line_of_text[3] is a number, not something with spaces. It also does not make sense to use count on this result, as you want to count rows, not something in one of the fields.
Here is a corrected version:
$ap = '36.222.198.197.166.140';
$file_handle = fopen("results.csv", "r");
while ( $line_of_text = fgetcsv($file_handle)){
if ($line_of_text[2] == $ap) $van[] = $line_of_text[3];
}
fclose($file_handle);
$fMean = array_sum($van) / count($van);
The variance is then calculated like this:
$variance = array_sum(array_map(function ($x) use ($fMean) {
return pow($x - $fMean, 2);
}, $van)) / count($van);

php - get specific column from txt file - columns separated irregularly

I'm trying to read data to php from a txt file, I already was able to do this, but now it's kind of different.
the data file consists of rows looking like this:
10.09.16 0:05 16.7 16.8 16.7 70 11.2 3.2 ENE 0.27 6.4 ENE 16.7 16.4 16.4 --- 946.9 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000 19.8 44 7.2 18.7 8.35 1.1146 15.6 0.00 112 2 100.0 5
10.09.16 0:10 16.7 16.8 16.7 70 11.2 4.8 E 0.40 6.4 E 16.7 16.4 16.4 --- 946.8 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000 19.7 43 6.8 18.6 8.25 1.1151 15.6 0.00 115 2 100.0 5
as you see, the sepparation between the columns is not always the same, not for every column, and not even between rows.
now I have to get data from some specific columns.
can someone help me with this?
thanks!
You can read the file line by line, and then replace all the space by just one space (or other separator).
Then explode the line with the separator to get an array with each column.
Resource you could use:
Read file: check this answer
Replace space using str-replace
Explode in array using explode
Also, you could replace the space by some ; and use fgetcsv
Regular expressions are very powerful when it comes to matching and separating text sequences:
Simple approach if you don't know the number of columns in advance:
<?php
$input = <<<EOT
10.09.16 0:05 16.7 16.8 16.7 70 11.2 3.2 ENE 0.27 6.4 ENE 16.7 16.4 16.4 --- 946.9 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000
10.09.16 0:10 16.7 16.8 16.7 70 11.2 4.8 E 0.40 6.4 E 16.7 16.4 16.4 --- 946.8 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000
EOT;
$output = [];
foreach(explode("\n", $input) as $subject) {
if (trim($subject)) {
preg_match_all('/(?:([^\s]+)\s+)+/uU', $subject, $tokens);
$output[] = $tokens[1];
}
}
var_dump($output);
Much more elegant approach if you do know the number of columns in advance:
<?php
$input = <<<EOT
10.09.16 0:05 16.7 16.8 16.7 70 11.2 3.2 ENE 0.27 6.4 ENE 16.7 16.4 16.4 --- 946.9 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000
10.09.16 0:10 16.7 16.8 16.7 70 11.2 4.8 E 0.40 6.4 E 16.7 16.4 16.4 --- 946.8 0.00 0.0 0 0.00 0 0.0 0.00 0.0 0.006 0.000
EOT;
preg_match_all('/(?:([^\s]+)\s+)+/uUm', $input, $output);
$output = array_chunk($output[1], 39);
var_dump($output);
I declared the input text inline to reduce complexity, you can read it from a file instead.
Both approaches will produce an identical output alone these lines:
array(2) {
[0] =>
array(39) {
[0] =>
string(8) "10.09.16"
[1] =>
string(4) "0:05"
[2] =>
...
[37] =>
string(5) "100.0"
[38] =>
string(1) "5"
}
[1] =>
array(39) {
[0] =>
string(8) "10.09.16"
[1] =>
string(4) "0:10"
[2] =>
...
[37] =>
string(5) "100.0"
[38] =>
string(1) "5"
}
}

symfony 2 & sonata admin debug toolbar broken, failed, and display blank

Sometimes I click the (symfony2 & the back-end I use sonata admin) debug toolbar button it display blank:
display nothing(check the image here)
Here is source of Firefox , it's broken here(in a svg tag):
</div>
<div id="content">
<div id="header" class="clear-fix">
<h1>
<svg width="275" height="62" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 275 62" enable-background="new 0 0 275 62" xml:space="preserve"><path fill="#010202" d="M31 0C13.9 0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2.4 4.8-4.1 7.9-4.2c3.1-0.1 5.5 1.3 5.6 3.6C50.2 16 49.6 17.9 47.7 17.9z"/><g><g><path fill="#010202" d="M142.8 25c4.5 0 7.5 3.3 7.5 7.8c0 4.2-3.1 7.8-7.5 7.8c-4.5 0-7.6-3.5-7.6-7.8 C135.2 28.3 138.2 25 142.8 25z M142.8 38.3c3.2 0 4.6-2.9 4.6-5.6c0-2.8-1.7-5.6-4.6-5.6c-2.9 0-4.7 2.7-4.7 5.6 C138.1 35.4 139.6 38.3 142.8 38.3z"/></g><path fill="#010202" d="M134.8 26.4v-1h-3.9v-1.4c0-2 0.3-3.5 2.6-3.5c0 0 0.1 0 0.1 0c0 0 0 0 0 0c0.7 0 1.2-0.5 1.2-1.1l0-0.9 c-0.6-0.1-1.1-0.2-1.8-0.2c-4 0-5 2.4-5 6v1.2h-3.5v1.2c0.1 0.6 0.6 1.1 1.2 1.1c0 0 0 0 0 0h2.3v12.6h1.5c0 0 0 0 0 0 c0.6 0 1.1-0.5 1.2-1.1V27.6h2.7C134.3 27.5 134.8 27 134.8 26.4z"/><path fill="#010202" d="M98.4 25.4C98.4 25.4 98.4 25.4 98.4 25.4c-0.6 0-1.1 0.4-1.4 0.9l-3.8 11.3h-0.1l-3.7-11.3 c-0.2-0.5-0.8-0.9-1.4-0.9c0 0 0 0 0 0h-1.9l5 13.8c0.2 0.5 0.5 1.3 0.5 1.6c0 0.3-0.8 3.7-3.3 3.7c-0.1 0-0.1 0-0.2 0 c-0.6 0-1.1 0.4-1.2 1.1l-0.1 0.9c0.5 0.1 1 0.2 1.9 0.2c3.6 0 4.7-3.3 5.7-6.1l5.5-15.2L98.4 25.4L98.4 25.4z"/><path fill="#010202" d="M81.1 28.4c-2.3-1.2-4.7-1.9-4.8-4.3c0-2.5 2.3-3.1 4-3.1c0 0 0 0 0 0c0.8 0 1.4 0.1 2 0.2c0 0 0 0 0 0 c0.6 0 1.2-0.4 1.2-1.1l0-0.9c-1.1-0.3-2.3-0.4-3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1.4 0.9l-3.8 11.3h-0.1l-3.7-11.3 c-0.2-0.5-0.8-0.9-1.4-0.9c0 0 0 0 0 0h-1.9l5 13.8c0.2 0.5 0.5 1.3 0.5 1.6c0 0.3-0.8 3.7-3.3 3.7c-0.1 0-0.1 0-0.2 0 c-0.6 0-1.1 0.4-1.2 1.1l-0.1 0.9c0.5 0.1 1 0.2 1.9 0.2c3.6 0 4.7-3.3 5.7-6.1l5.5-15.2L179.4 25.4L179.4 25.4z"/></g><g><path fill="#ADADAD" d="M185.7 46.4V25.1h2.4v2c0.6-0.8 1.2-1.4 1.9-1.8c0.7-0.4 1.6-0.6 2.6-0.6c1.3 0 2.5 0.3 3.5 1 c1 0.7 1.8 1.6 2.3 2.9c0.5 1.2 0.8 2.6 0.8 4.1c0 1.6-0.3 3-0.8 4.3c-0.6 1.3-1.4 2.2-2.5 2.9c-1.1 0.7-2.2 1-3.4 1 c-0.9 0-1.7-0.2-2.3-0.6c-0.7-0.4-1.3-0.8-1.7-1.4v7.5H185.7z M188.1 32.8c0 2 0.4 3.4 1.2 4.4s1.8 1.4 2.9 1.4 c1.2 0 2.2-0.5 3-1.5c0.8-1 1.2-2.5 1.2-4.6c0-2-0.4-3.4-1.2-4.4c-0.8-1-1.8-1.5-2.9-1.5c-1.1 0-2.1 0.5-3 1.6 C188.5 29.4 188.1 30.9 188.1 32.8z"/><path fill="#ADADAD" d="M202.2 40.5V25.1h2.4v2.3c0.6-1.1 1.2-1.8 1.7-2.2c0.5-0.3 1.1-0.5 1.7-0.5c0.9 0 1.8 0.3 2.7 0.8l-0.9 2.4 c-0.6-0.4-1.3-0.6-1.9-0.6c-0.6 0-1.1 0.2-1.5 0.5c-0.5 0.3
In a svg tag(check the image here)
It's make me confused for a long time. Who can tell me why?

save generate pdf to server

I am developing an application and I need to create pdf files. using pdfbundle
public function helloAction($id)
{
$format = $this->get('request')->get('_format');
$venta = $this->getDoctrine()->getRepository('miomioBundle:Venta')->find($id);
$lineas = $venta->getLineas();
$cliente = $venta->getCliente();
$empleado = $venta->getEmpleado();
//return new Response ($cliente->getNombre());
$pdf = $this->render(sprintf('miomioBundle:Venta:helloAction.%s.twig', $format), array('cliente' => $cliente,'empleado' => $empleado,
'venta' => $venta,
'lineas' => $lineas
));
$hi = "hiii";
//file_put_contents('holajiji.pdf', $pdf);
file_put_contents( 'hi.txt', $hi);
return $pdf;
}
The function generates the txt file correctly but when I try to do the same with the pdf I displayed a lot of other odd characters.
%PDF-1.4 %���� 1 0 obj <> endobj 2 0 obj <> endobj 3 0 obj <> endobj 4 0 obj [] endobj 5 0 obj <> endobj 6 0 obj <> endobj 7 0 obj <> /XObject <> >> /MediaBox [0 0 595 842 ] /Contents [8 0 R ] /Parent 2 0 R >> endobj 8 0 obj <> stream /F1 9 Tf 0 g 0 G q 0.69 0.878 0.9020000000000000 RG 0.69 0.878 0.9020000000000000 rg 39 586 m 93.25 586 l 93.25 570 l 39 570 l 39 586 l h f Q q 1 0.753 0.796 RG 1 0.753 0.796 rg 447.5 586 m 501.75 586 l 501.75 570 l 447.5 570 l 447.5 586 l h f Q q 0.69 0.878 0.9020000000000000 RG 0.69 0.878 0.9020000000000000 rg 501.75 586 m 556 586 l 556 570 l 501.75 570 l 501.75 586 l h f Q q 0.9020000000000000 0.9020000000000000 0.98 RG 0.9020000000000000 0.9020000000000000 0.98 rg 39 432 m 142.4 432 l 142.4 416 l 39 416 l 39 432 l h f Q q 0.9020000000000000 0.9020000000000000 0.98 RG
if open witch text editor the archive generate :
HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Type: text/html; charset=UTF-8
Date: Tue, 06 Nov 2012 12:59:43 GMT
<pdf>
<page document-template="holita.pdf">
<img src="/var/www/Symfony/src/mio/mioBundle/Resources/public/images/optinet.png" float="left" height="100px" width="300px" />
<h1 float="right" text-decoration="underline">Factura Número: 4</h1>
<p><h1 float="right">Fecha: 06/11/2012 </h1></p>
<table text-align="left" margin-bottom="30%">
<tr>
thanks.
Try to output headers to let browser know that you are outputting PDF file:
Header('Content-Type: application/pdf');
solved the problem witch section in github psliwa thanks

Categories