Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hilmi's avatar
Level 1

How to Get Full Content using Tinymce getContent() API method

form tinymce

I have a form that uses tinymce and has content like the image above. Then, I want to preview that content to PDF page using getContent() API method with code like below.

<script nonce="{{ csp_nonce() }}">
    var options = {
        selector: "#body_sp3d",
        menubar: 'file edit view insert format tools table help',
        plugins: [
            "advlist autolink autosave lists link image charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars code fullscreen",
            "insertdatetime nonbreaking save table directionality",
            "template paste textpattern"
        ],
        toolbar: "fullscreen restoredraft insertfile undo redo toc | styleselect fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify codesample | bullist numlist outdent indent toc",
    };
    tinymce.init(options);
</script>
<script>
    $(document).ready(function() {
        $('#previewSp3d').on('click', function() {
            //get content from tinyMCE editor and set to #content_sp3d
            var body_sp3d        = tinymce.get('body_sp3d').getContent();
            var no_sp3d          = $('#no_sp3d').val();
            var penerima_sp3d    = $('#penerima_sp3d').val();
            var klasifikasi_sp3d = $('#klasifikasi_sp3d').val();
            var url              = "{{ route('preview.sp3d')}}";
            var full_url         = url + '?no_sp3d=' + no_sp3d + '&penerima_sp3d=' + penerima_sp3d + '&body_sp3d=' + body_sp3d + '&klasifikasi_sp3d=' + klasifikasi_sp3d;

            $('#previewSp3d').attr('href', full_url);
        });
    });
</script>

get content

But, only part of the content is previewed, not all content can be displayed on the PDF page. How do I get all the content in the form to be displayed on the PDF page? Thanks

0 likes
0 replies

Please or to participate in this conversation.