Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm not able to send SVGGraph by email. there are showing a error invalid Xml. How can we save SVGGraph to PDF? #76

Open
ajaydazos opened this issue Apr 14, 2023 · 7 comments

Comments

@ajaydazos
Copy link

No description provided.

@ajaydazos ajaydazos changed the title Hi, I'm not able to send SVGGraph by email. there are showing a error invalid Xml. How can we save SVGGraph to PDF? Apr 14, 2023
@ajaydazos ajaydazos reopened this Apr 14, 2023
@ajaydazos
Copy link
Author

image

I want to send this Graph in mail.

@goat1000
Copy link
Owner

I presume you have your own graph you want to send, not the example graph. I would try turning off the tooltips using "show_tooltips" = false to see if that helps.

If it does not help, I would convert the SVG to a PNG or GIF and send that instead.

@ajaydazos
Copy link
Author

image
I tried with this ["show_tooltips" = false]
but it's not working

@goat1000
Copy link
Owner

This doesn't look like a PHP error, where is it coming from?

@ajaydazos
Copy link
Author

This doesn't look like a PHP error, where is it coming from?

I'm working on Vtiger CRM.
and I want to send a pie chart graph by mail with attachment (.pdf, image)

@goat1000
Copy link
Owner

I use the ImageMagick convert command to convert from SVG to PNG because it is very good at it.

This is the function I use from my testing class:

  private function get_image($content)
  {
    $desc = array(
      0 => array('pipe', 'r'),
      1 => array('pipe', 'w'),
      2 => array('pipe', 'w')
    );

    $process = proc_open('/usr/local/bin/convert svg:- png:-', $desc, $pipes);

    if(is_resource($process)) {
      fwrite($pipes[0], $content);
      fclose($pipes[0]);

      $png = stream_get_contents($pipes[1]);
      $this->error = stream_get_contents($pipes[2]);
      fclose($pipes[1]);
      fclose($pipes[2]);
      proc_close($process);
      return $png;
    }
    return NULL;
  }

@markkimsal
Copy link

maybe try base64 encoding the SVG?

return '<img width="100%" src="data:image/svg+xml;base64,' . base64_encode( $svgContent ).'"/>';

This is how you have to embed SVGs for DOMPdf, and I tend to do it for all embedding SVGs in HTML (for printing to pdf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants