parallax / jsPDF

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

jspdf css issues #302

Closed ajitparida closed 10 years ago

ajitparida commented 10 years ago

i am working with jspdf to convert HTML to pdf by fromHTML method of jspdf library. facing some issues :: 1) hr tag


not supported 2) i want two column view , so i used two 50% width div - (not working) 3) i want to use line divider , so i used div with top border - (not working)
4) text-decoration: underline - (not working)

is there any way to resolve these issues ??

code : http://jsfiddle.net/ajitparida/2pbzS/ thanks.

diegocr commented 10 years ago

The fromHTML plugin is kinda limited, take a look at #270 for a "workaround".

ravirajsonetta commented 7 years ago

I'm using 'html2pdf', in browser pdf seems working, but when I open pdf using Acrobat Reader DC (version 2015.023.20070), I'm getting this error: 'An error exists on this page. Acrobat may not display the page correctly'. Below is Javascript code: `function DownloadPDF() { var panel = document.getElementById("<%=pnlContents.ClientID %>") var pdf = new jsPDF('l', 'pt', 'letter'); var html = '' + panel.innerHTML + '';

        html2pdf(html, pdf, function (pdf) {
            pdf.save();
        });

        return false;

}; `

Below is html of #grPrintItems:

`

1
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <RowStyle HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                            <AlternatingRowStyle BackColor="White" HorizontalAlign="Center" BorderColor="#000000" BorderStyle="Solid" BorderWidth="1" />
                        </asp:GridView>`

Thanks in advance..

ajhalls commented 2 years ago

I figured out what was happening for me. I was using the following code to generate:

pdf.html($(".BuildBox")[0], {
            callback: function (pdf) {
                var iframe = document.createElement('iframe');
                iframe.setAttribute('style', 'position:absolute;top:0;right:0;height:100%; width:700px');
                document.body.appendChild(iframe);
                iframe.src = pdf.output('datauristring');
            }
        });

The issue was that the $(".BuildBox")[0] container wasn't large enough to hold all the text when the width got changed. When the text overflowed the container, while it would show up fine in the browser, Acrobat wouldn't be able to handle it.