view svg from canvas

cant move all object
mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.4 kB
2
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Live lync</title>
        <style>
        svg{
            border-radius: 15px;
        }
    </style>
</head>
<body>
    <input type="hidden" name="json" data-height="{{$table->template->size->height}}" data-width="{{$table->template->size->width}}" value='{!! $table->canvas !!}'>
    <div id="svg">
    </div>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
    <script src="http://dev.livelync.com/backend/assets/js/fabricjs/fabric.min.js"></script>
    <script>
        $(document).ready(function(){
            var canvas = new fabric.Canvas('canva-card');
            var json    = $("input[name='json']").val();
            var width   = $("input[name='json']").attr('data-width');
            var height  = $("input[name='json']").attr('data-height');

            canvas.setWidth(width);
            canvas.setHeight(height);

            canvas.loadFromJSON(json, function() {
                canvas.renderAll();
                var svg = canvas.toSVG();
                $("#svg").append(svg);
            });
        })

    </script>
</body>
</html>