How can export DIV field content from an HTML page to PDF ?.
Is it possible without using third-party tools, Javascript?
Please suggest
That's what I get when I great-wizard I ask -Google is able to first link I clicked Jespeedif plugins to make it able to print HTML, you'll need to add some plugins and so must do the following: Go to the latest version and download it. Include the following script in your project: If you can if you want to ignore some elements, you must mark them with the ID, which you ignore a particular element handler Jespeedif. That's why your HTML should look like this: You can then use the following JavaScript code to open a PDF created in a popup: For me this is a nice and clean PDF that only created the 'PDF Print to It' included. Please note that special element operators only deal with IDs in the current version, which is also said in a Geithb issue. It has been said: Since the node tree is matched with each element, my wish was to make it as soon as possible. In that case, it means "only element ID is matched" element ID is still done in the "#ID" jQuery style, but that does not mean that all jQuery selectors are supported. So instead of '#' Ignr PDF 'was such a class does not work for me "ignore PDF' with selectors instead each and every element that you want to ignore you like The same handler must be added: is a very important thing that you lose all your style information (CSS). Fortunately, JSPDF is capable of formatting H1, H2, H3 etc. well, which was enough for my purposes. In addition, it will print the text within the text nodes, which means that it will not print the values of textures. Example: No more, you can not print without third-party tools
jspdf.js jspdf.plugin.from_html.js jspdf.plugin.split_text_to_size.js jspdf.plugin.standard_fonts_metrics.js
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; P id = "undefined pdf" & gt; Do not print it in PDF & lt; / P & gt; & Lt; Div & gt; & Lt; P & gt; & Lt; Font size = "3" color = "red" & gt; Print it to PDF & lt; / Font & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
var doc = new jsPDF (); Var elementHandler = {'#ignorePDF': function (element, renderer) {back true; }}; Var source = window.document.getElementsByTagName ("body") [0]; Doc.fromHTML (source, 15, 15, {'width': 180, 'elementhands': elementhandler}); Doc.output ("dataurlnewwindow");
at elementHandler = {'#ignoreElement': function (element, renderer) {true return; }, '#other IT trigonard': function (element, renderer) {return true; }}; Adding
& lt; Body & gt; & Lt; Ul & gt; & Lt ;! - is printed in this form because the element has a text node - & gt; & Lt; Li & gt; Print me! & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Div & gt; & Lt ;! - It is not print because JSPDF does not deal with value attributes - & gt; & Lt; Input type = "textarea" value = "please print me, too!" & Gt; & Lt; / Div & gt; & Lt; / Body & gt;
Comments
Post a Comment