#257 SVG: add pattern support

open
nobody
None
5
2014-05-21
2012-08-10
No

I already posted the report about problems with patterns of SVG's at Feature Requests (https://sourceforge.net/tracker/?func=detail&aid=3537979&group_id=128076&atid=710535).

However, later I realized that problem with patterns is not kind of feature or absence of feature. Sometimes SVG which uses pattern could be drawn completely differently.

I have attached test PHP file and SVG image, that contains pattern, which actually should be never used, but in some strange cases displayed by TCPDF.

The example demonstrates how the same logo could be displayed with and without useless "Polka_Dot_Pattern". (Of course this pattern should not be displayed at all in all cases).

Discussion

  • Aleksey Kuznetsov

    I'm currently using kludge to process SVG before passing them to TCPDF:

    function is_svg($data) {
    return (strtolower(substr($data, 0, 5)) == '<?xml') && (stripos($data, '<svg')> 0); // also "<!DOCTYPE svg" ?
    }

    if (is_svg($svg_data))
      $svg_data = preg_replace('/<pattern(.*?)id="Polka_Dot_Pattern"([^>]*?)>(.*?)<\/pattern>/is', '', $svg_data); // kludge: strip useless "Polka_Dot_Pattern" pattern from SVG.
    
     
  • Nicola Asuni

    Nicola Asuni - 2012-08-11

    Unfortunately, SVG with patterns are not yet supported.

     
  • Aleksey Kuznetsov

    That's okay. I'm currently using the kludge code to strip patterns before TCPDF, but it would be really great if on day the feature will be implemented to TCPDF as native.

     
  • Nicola Asuni

    Nicola Asuni - 2012-08-12

    Printing the provided SVG on a TCPDF document seems OK. What problems are you facing?

     
  • Aleksey Kuznetsov

    Thanks for reponse! I didn't tried to print SVG with Polka_Dot_Pattern, because I saw odd image on PDF. However, even if it only displayed on view and will not be printed, some PDF documents distributed for electronical use, to let users read the content without printing.

    You can see the odd pattern in attached image or example code.

     
  • Nicola Asuni

    Nicola Asuni - 2012-08-13

    Sorry, I meant that the provided SVG is both displayed and printed correctly.

     
  • Aleksey Kuznetsov

    Yes. sometimes provided SVG displayed correctly. That's why I have attached example, which displays the same SVG twice. On the top of the PDF it displayed correctly, but when it alligned in center-middle of some area -- it displays odd pattern.

    I'm going to attach some more SVGs which contains that pattern (I don't know why some SVGs contains it)

     
  • Aleksey Kuznetsov

    I have added another example which demonstrates problem with pattern. Usually I just stripped patterns named "polka_dot_pattern", but the pattern in attached file has different name so I my script didn't detected it and displayed that odd orange square over the logo :(
    If TCPDF doesn't supports patterns anyway, maybe the best way is to simply not display the contents of the patterns at all?

     
  • Nicola Asuni

    Nicola Asuni - 2012-12-10
    • summary: Unused SVG pattern bug --> SVG: add pattern support
    • milestone: --> Next_Release_(example)
     
  • Anders Lisspers

    Anders Lisspers - 2014-05-21

    We just hit this problem with an SVG containing <pattern>, and first Google hit tells us about this open bug ticket. Could there be any hope on work to solve this?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks