parallax / jsPDF

Client-side JavaScript PDF generation for everyone.
https://parall.ax/products/jspdf
MIT License
29.3k stars 4.68k forks source link

Generated PDF page limitation #81

Closed mzubairahmed closed 10 years ago

mzubairahmed commented 11 years ago

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

MrRio commented 11 years ago

Hi there,

If you could post some example code, I may be able to suggest something.

Thanks, James

aemb87 commented 11 years ago

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

mzubairahmed commented 11 years ago

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

caruccio commented 11 years ago

+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?

joshleblanc commented 11 years ago

I'm also looking for a solution to this.

hiracse091 commented 10 years ago

No one for a solution!!!!! badly need a solution ....

diegocr commented 10 years ago

See #46

mzubairahmed commented 10 years ago

Thanks!

AnithaN commented 10 years ago

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

azamSE commented 10 years ago

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

umeshd commented 10 years ago

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

foo123 commented 10 years ago

same issue here, on a greasemonkey script using jsPDF

jossef commented 9 years ago

@foo123, @umeshd - perhaps you've used an older version of jsPDF (i did until i realized cdnjs is not updated with jsPDF latest version)

image

here's a plunker with the latest version (valid for 2014-12-11) working: http://plnkr.co/edit/5NonsdQ23nXwFchV01sB?p=preview

foo123 commented 9 years ago

thanks, @Jossef , wil try that even though i had downloaded latest version from github (to make sure)

PavanGali commented 9 years ago

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

  1. JsPDF supports JqGrid styles
  2. How to apply specific styles

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
                      )
pradeepkchandra commented 8 years ago

Did anyone get the "pagesplit" thing working?

pradeepkchandra commented 8 years ago

@jossef: It seems to work only in plunker. When I try to copy the same code and reproduce it, it just bombs... :(

pomegrn8 commented 8 years ago

I had to use the version of jspdf in the plunker example to get it to work.

THEMBOCHARLES commented 7 years ago
valimpact commented 7 years ago

Anyone able to add page numbers using jspdf?

shivamdawer commented 7 years ago

+1

ziaongit commented 7 years ago

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.

I added jsPDF version

agarwalsween commented 7 years ago

@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.

agarwalsween commented 7 years ago

Please reply asap.

ziaongit commented 7 years ago

@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.

Uzlopak commented 7 years ago

pagesplit is not a real "option" because there was never any code handling an pageSplit Option.

Uzlopak commented 7 years ago

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?