Ok, so i have this idea of project in which I want to write a project in an order different of the order that is going to be printed. For example: writing in 3,1,2 order, but printing in 1,2,3. The idea is to write scientific projects and articles in a meaningful order, to make it easier to write. I've created a form using HTML and TinyMCE text area.
This is the code I'm using:
<script src="https://cdn.tiny.cloud/1/b9w5wbhhiy67clv3p6t1cmtyjia9h9g3b2ggjq3vil7ge215/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
setup: function(editor) {
editor.on('init', function() {
this.setContent('The init function knows on which editor its called - this is for ' + editor.id);
});
}
});
</script>
<body>
<form method="post">
<textarea class='tiny-mce' id='editor1'></textarea>
<textarea class='tiny-mce' id='editor2'></textarea>
</form>
<input type="button" id="button" value="Gerar Projeto em PDF" />
</body>
This creates two (of many) textareas with rich formatting, however, I just can not extract the content of the textareas and put them into the PDF, that is printed empty.
This is the JS code for one textarea:
<script>
$('#button').click(function() {
var doc = new jsPDF('p', 'pt', 'a4');
var obj_g = $('#editor1').val();
doc.setFontSize(12);
doc.setTextColor(92, 92, 92);
doc.text(23, 41, obj_g);
doc.save('projeto.pdf');
});
</script>
How can I extract the content of the textareas in TinyMCE and print them in the PDF?
Thanks in advance
The init function knows on which editor its called - this is for editor1
` How can I keep the formatting made in the tinyMCE box and create margins for the PDF document? Thanks again! – Antonio Carlos Filho Apr 13 '20 at 14:30