Closed mzubairahmed closed 10 years ago
Hi there,
If you could post some example code, I may be able to suggest something.
Thanks, James
Hi! I don't know if @mzubairahmed was trying to make a PDF from HTML but this happens in the demo HTML Renderer example.
Trying with the other examples and its the same, for example drawing a recatngle bigger than the page.
Cheers, Andrés
Dears, sorry for posting a bit late. What i was trying to ask is very easy. you can also generate the code. Just create an HTML page and use the jsPDF script to convert that html page into PDF. it will convert it perfectly but try to provide a large html data that exceeds the PDF page. you will see the issue yoursefl. the jsPDF utility won't add the next pages for you. it will continue writing the text on the same PDF page and you'll find the text at the bottom of the single generated PDF page cutting out and then nothing displayed.
Thanks
+1 for this issue!
I found this lib very usefull. An ellegant solution for generating pdf on-demand (saves lots of clocks of my servers :)
It would be really nice if fromHTML()
could split across multiple pages automatically or by inserting specific tags/attribs into the DOM myself. For example, for a long table, one <tr>
could have a hint like <tr jspdf=split>
.
Does anyone have a workaround for this?
I'm also looking for a solution to this.
No one for a solution!!!!! badly need a solution ....
See #46
Thanks!
jspdf rendering a blank pdf if it has got more pages in it, ex:for 35+ pages its rendering blank pdf.. how to overcome this issue
doc.fromHTML($('#divReport').get(0), 15, 15, { 'width': 250, 'margin': 1, 'pagesplit': true, //This will work for multiple pages 'elementHandlers': specialElementHandlers });
pageSplit option will work for Splitting PDF into multiple pages
I am using 'pagesplit':true, as shown in below code but page split is not happening.
var doc = new jsPDF();
var elementHandler = {
'#render_me': function (element, renderer) {
return true;
}
};
doc.fromHTML($('#render_me').get(0), 15, 15, {
'width': 170,
'margin': 1,
'pagesplit': true,
'elementHandlers': elementHandler
});
doc.save('Test.pdf');
I am using jsPDF-0.9.0rc2/jspdf.plugin.from_html.js
same issue here, on a greasemonkey script using jsPDF
@foo123, @umeshd - perhaps you've used an older version of jsPDF
(i did until i realized cdnjs
is not updated with jsPDF
latest version)
thanks, @Jossef , wil try that even though i had downloaded latest version from github (to make sure)
Hi,
I am using JsPDF for generating webpage div content to PDF. I am able to generate pdf. it is not giving proper lay out design of the grid. I have 7 JqGrids in my web page. My question are
please help me regarding this issue. please find the below code.
var pdf = new jsPDF('l', 'pt', 'a4')
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
, source = $('#divid')[0]
// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
, specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#CreateTransSAccView': function (element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
}
margins = {
top: 80,
bottom: 60,
left: 40,
width:750
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source // HTML string or DOM elem ref.
, margins.left // x coord
, margins.top // y coord
, {
'width': margins.width // max width of content on PDF
, 'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Receipt of Confirmation Single Account.pdf');
},
margins
)
Did anyone get the "pagesplit" thing working?
@jossef: It seems to work only in plunker. When I try to copy the same code and reproduce it, it just bombs... :(
I had to use the version of jspdf in the plunker example to get it to work.
Anyone able to add page numbers using jspdf?
+1
Thank @jossef I was using the old version, which was not good for the image also. I am using the same code and it is working for me.
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
doc.fromHTML($('#products').html(), 15, 15, {
'width': 250,
'margin': 1,
'pagesplit': true,
'elementHandlers': specialElementHandlers
}, function() {
doc.save('Products.pdf');
});
@umeshd my code was like yours, I got console error to add callback funtion to fromHTML, then I added and doc.save() is inside that.
@ziaongit
Hello sir,
Had you problem solved ? From this process that you said in your last message it only gives us html not with css. Please help me out.
Please reply asap.
@agarwalsween sorry for late response. I did not solve that problem yet. I will update you when I fix it. Please update me also if you solve it.
pagesplit is not a real "option" because there was never any code handling an pageSplit Option.
I was checking the code and found only an error and fixed it with #1492 But I dont know, what your error is. Can you provide an example?
I am using this API and found it real faster PDF Converter. But i am facing an issue with this API that it does not intend or add pages itself if my text size is increased to one page. Is there any work around apart from adding the new page myself while in the loop? please suggest.
Thanks