Untitled

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>Card Preview</title>

</head>
<body>
    <div id="svg" class="svg" style="border-radius: 15px;">
    </div>
    <input type="hidden" name="json" value='{{$table->canvas}}'>
    <input type="hidden" name="width" value="{{$table->size->width}}">
    <input type="hidden" name="height" value="{{$table->size->height}}">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.1/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='width']").val();
            var height  = $("input[name='height']").val();

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

            canvas.loadFromJSON(json, function() {

                canvas.renderAll();

                var svg = canvas.toSVG();
                $("#svg").append(svg);
            });
        })

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