Is there a way to generate a PDF file in JavaScript out of a given rendered and styled element of a webpage and its content? Is there already a library for this?
I've never put it to use, but could https://github.com/thebluber/htmlToPdf be what you're looking for?
There is a library called jsPDF. It provides basic functionality to create PDF documents. It even comes with a plugin to add elements from basic HTML.
Related
I wrote a chrome extension, that allows me to copy the DOM of a webite and upload it to a server for analysis (dont worry, nothing illegal). Doing so does not provide the images or css scripts of the page.
Is there an "easy way" to get transfer the images and scripts that are used in the DOM as well? Currently I am using document.all[0].outerHTML for reading the HTML itself.
I found a quite nice way to upload the images in one package with the HTML / DOM:
Using this post, I had a very easy way to convert almost any image in Base64. I replaced the src attribute of the img tag using jQuery and uploaded the complete DOM. Like that all the images are already implemented.
i have designed a page in html. i need to find a way to save the html body section as pdf. can some one suggest me a jquery plugin where i can get this work done?
am using C# as my back end coding.
The system I am working on has a questionnaire in it and then shows the responses to the admin in a nice report on screen. I need to create functionality that turns the on screen report into a pdf, similar to how the browser generates a pdf of the page when you select print. Although I need to only turn a section of the page into pdf. And it would be ideal to be able to alter the HTML so that the pdf page breaks don't interfere with the presentation of the report.
You can download a pdf of how the report looks, generated by the browser functionality. This is just an example, I need the pdf to be generated by a link or button and not include the whole page (the top part in this case).
I have tried some php HTML to pdf generators, but it's difficult because the HTML is dynamically generated so I'm not sure how to send all the HTML, once rendered, to the page that creates the pdf.
To overcome the page breaks, I've considered using javascript or jquery to read the height of the div of each question within the report and then write a simple script to calculate if the next div will fit on the page and if not add a margin on top of that div so that it starts on a new page.
What software can I use to generate the pdf, given these requirements? Either php or javascript. Appreciate the help.
Have you considered Snappy for PHP? It makes use of wkhtmltopdf behind the curtains to convert any HTML document into PDF.
We are using it and it works great.
https://github.com/KnpLabs/snappy
You could try mpdf and use the page-break-inside: avoid property which is actually a CSS property. I have not used this, but it might be what you're looking for.
Looks like you can add this property to the <div> and <table> tags (mPDF Supported CSS).
I need to create image chart dynamically as shown bellow,
First I tried with php ImageCreate but it is hard to manage the space with that.
Then I tried the html5 canvas and that is also having a same issue. What I need to know is whether there is an easy way to do html to image conversion. Then I can manage the space easy with other styles.
Thanks in advance.
With wkhtmltoimage you can convert HTML to an images. You would need a VPS to run it on though. You can then create the HTML and call wkhtml2image via PHP to convert the given HTML to an image.
I am creating dynamic image with php with `GDLibrary. Here is the script of creating dynamic image.
I'd like to use CKEditor's Image plug-in separately from the rest of CKEditor.
Basically I'm creating a simple tool to edit webpages. Some parts of the webpage will be HTML and thus require the full CKEditor. But some parts will be images, and I don't need the full HTML editor, just the Image plug-in.
Is this possible to do, and what would be the "cleanest" way to do so?
CKEditor doesn't provide an image browser by itself, so you must research how to use the file browser component that you have picked by itself.
If you're using CKFinder look at the standalone.html sample, like shown in the "enhancing html forms" here: http://ckfinder.com/demo