parallax / jsPDF

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

JsPdf with JqGrid #455

Closed PavanGali closed 6 years ago

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 questions 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
                  )

my Cshtml code

Transaction-Receipt of Confirmation
@**@
```
: :
: :
: :
: :
: :
:
:   
























@*


*@



Transaction Revision History




Financial Planner / Unit Trust Consultant's Recommendation and Remarks




Attachments (please click on the file name(s) to download the files for your viewing)



Attached 'Proof Of Payment'




I declare that I have explained the points stated in Pre-Investment Form to the investors as required by Federation of Investment Managers Malaysia.



Units are priced based on the foraward pricing. if we receive your request online before the cut off time. the units would be based on the NAV per Unit at the end of the business Day on which the payment and request is received by us. if the payment and /request received after the Cut-off time, the units would be based on the NAV per Unit on the next Business Day. For selll transaction ,Indicative proceed is based on the last available NAV per Unit. Actual proceed shall depend on the NAV per unit at the end of the Business Day.


Nikhilgupta1891 commented 9 years ago

Same problem. Has anyone got the solution?

moisesline commented 9 years ago

Here, a possible solution: add col tag in the table and set the width parameter...

table style=" width:100%; border:0; padding:0; margin:0;" colgroup col width="20%" col width="15%" col width="15%" col width="15%" col width="15%" col width="10%" col width="10%" /colgroup and now, your table content....

You need to use a col tag for each colum you have. Try this, it worked with me... good luck!

Uzlopak commented 6 years ago

No reaction seems to mean, that this issue is dead.