Giter Site home page Giter Site logo

PDF coming in two pages about ios-htmltopdf HOT 4 OPEN

iclems avatar iclems commented on July 18, 2024 1
PDF coming in two pages

from ios-htmltopdf.

Comments (4)

dfranc3373 avatar dfranc3373 commented on July 18, 2024 1

I have the same issue, HTML is as followed:

<html>

    <body style="font-family: arial;">

    <h1 align="right">Change Order</h1>

        <br />

        <hr style="width: 90%">

        <table align="center" style="width: 80%;">
        <tr>

            <td>Attention: <span id="attention"></span></td>
            <td>Company: <span id="company"></span></td>

        </tr>
        <tr>

            <td style="padding-top: 9px;">Date: <span id="date"></td>
            <td></span></td>

        </tr>
        <tr>

            <td style="padding-top: 9px;">Address: <span id="address"></span></td>
            <td></td>

        </tr>
        </table>

        <br />

        <hr style="width: 90%;">

        <div align="center">

            <h4 style="width: 80%; text-align: left;">Description of Charge</h4>

        </div>

        <table align="center" style="width: 80%; border: 1px solid;" id="main_data">
            <tr>
                <th style="width: 75%; text-align: left;">Description</th>
                <th style="width: 25%;">Cost</th>
            </tr>
        </table>

        <div align="center">

            <h4 style="width: 73%; text-align: right;">Tax: <span id="tax"></span> <br /> Total: <span id="total"></span></h4>

        </div>

        <table align="center" style="width: 80%;">
        <tr>

            <td style="width: 30%">Client Signature</td>
            <td valign="bottom"><hr style="margin-top: 22px;"/></td>

        </tr>
        <tr>

            <td style="padding-top: 9px;">Date:</td>
            <td></span></td>

        </tr>
        <tr>

            <td style="width: 30%">Contractor Signature</td>
            <td valign="bottom"><span id="signature"></span><br /><hr style="margin-top: 22px;"/></td>

        </tr>
        <tr>

            <td style="padding-top: 9px;">Date: <span id="date"></span></td>
            <td></span></td>

        </tr>
        </table>

    </body>

</html>

The code used to render is:


self.PDFCreator = [NDHTMLtoPDF createPDFWithHTML:@"<html> <body style='font-family: arial;'> <h1 align='right'>Change Order</h1> <br /> <hr style='width: 90%'> <table align='center' style='width: 80%;'> <tr> <td>Attention: <span id='attention'></span></td> <td>Company: <span id='company'></span></td> </tr> <tr> <td style='padding-top: 9px;'>Date: <span id='date'></td> <td></span></td> </tr> <tr> <td style='padding-top: 9px;'>Address: <span id='address'></span></td> <td></td> </tr> </table> <br /> <hr style='width: 90%;'> <div align='center'> <h4 style='width: 80%; text-align: left;'>Description of Charge</h4> </div> <table align='center' style='width: 80%; border: 1px solid;' id='main_data'> <tr> <th style='width: 75%; text-align: left;'>Description</th> <th style='width: 25%;'>Cost</th> </tr> </table> <div align='center'> <h4 style='width: 73%; text-align: right;'>Tax: <span id='tax'></span> <br /> Total: <span id='total'></span></h4> </div> <table align='center' style='width: 80%;'> <tr> <td style='width: 30%'>Client Signature</td> <td valign='bottom'><hr style='margin-top: 22px;'/></td> </tr> <tr> <td style='padding-top: 9px;'>Date:</td> <td></span></td> </tr> <tr> <td style='width: 30%'>Contractor Signature</td> <td valign='bottom'><span id='signature'></span><br /><hr style='margin-top: 22px;'/></td> </tr> <tr> <td style='padding-top: 9px;'>Date: <span id='date'></span></td> <td></span></td> </tr> </table> </body> </html>"
                                          pathForPDF:[@"~/Documents/delegateDemo.pdf" stringByExpandingTildeInPath]
                                           delegate:self
                                           pageSize:kPaperSizeA4
                                            margins:UIEdgeInsetsMake(10, 5, 10, 5)];

from ios-htmltopdf.

dwong-uw avatar dwong-uw commented on July 18, 2024 1

Having a similar issue as well, except the HTML being rendered onto the PDF is being prematurely cut off on the first page. It only seems to happen when one column in the table is particularly wide.

simulator screen shot sep 25 2015 3 22 19 pm

As you can see, where "SUBTOTAL" stars on the next page should actually be a part of the table above.

This is the HTML that's being rendered:

<html lang='en'>
    <head>
        <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'></meta>
        <meta charset='utf-8'></meta>
        <title>Example 1</title>
        <link rel='stylesheet' href='pro_monochrome_template.css' media='all'></link>
    </head>
    <body>
        <header class='clearfix'>
            <div id='logo'>
                <img src='logo_6A979AF8B0E90B7F405911F9512BE8C1.jpg'></img>
            </div>
            <h1 id='invoice_num'>Invoice INV0001</h1>
            <div id='company' class='clearfix'>
                <div id='company_company' class='company'>Test Company</div>
                <div id='company_name' class='name'>Anna Haro</div>
                <div id='company_address1' class='address'>1001  Leavenworth Street</div>
                <div id='company_address2' class='address'>Sausalito CA 94965</div>
                <div id='company_phone' class='phone'>555-522-8243</div>
                <div id='company_email' class='email'>[email protected]</div>
            </div>
            <div id='client'>
                <div id='client_name_container' class='client_container'>
                    <span id='client_name_label' class='client_table_label'>Name</span>
                    <span id='client_name' class='client_table_value'>Daniel Higgins</span>
                </div>
                <div id='client_phone_container' class='client_container'>
                    <span id='client_phone_label' class='client_table_label'>Phone</span>
                    <span id='client_phone' class='client_table_value'>555-478-7672</span>
                </div>
                <div id='client_effective_date_container' class='client_container'>
                    <span id='effective_date_label' class='client_table_label'>Date</span>
                    <span id='effective_date' class='client_table_value'>September 24, 2015</span>
                </div>
            </div>
        </header>
        <main>
            <table>
                <thead>
                    <tr id='item_header'>
                        <th id='item_header_desc' class='service'>Description</th>
                        <th id='item_header_total'>Total</th>
                    </tr>
                </thead>
                <tbody id='items'>
                    <tr>
                        <td class='item-desc'>
                            <h3 class='name'>Item 1</h3>
                            <span class='desc'>This is a very long description, and when there is a long description then the description table cell becomes very wide. When a table cell becomes very wide, the renderer starts to cut the table off early into the page.</span>
                        </td>
                        <td class='total'>$4.00</td>
                    </tr>
                    <tr>
                        <td class='item-desc'>
                            <h3 class='name'>Item&nbsp;2</h3>
                            <span class='desc'>Test here</span>
                        </td>
                        <td class='total'>$15.00</td>
                    </tr>
                    <tr id='subtotal' class='footer_row'>
                        <td id='subtotal_label'>Subtotal</td>
                        <td id='subtotal_amt' class='total'>$19.00</td>
                    </tr>
                    <tr id='total' class='footer_row'>
                        <td id='total_label' class='grand total'>Total</td>
                        <td id='total_amt' class='grand total'>$19.00</td>
                    </tr>
                    <tr id='paid' class='footer_row'>
                        <td id='paid_label'>Paid</td>
                        <td id='paid_amt' class='total'>$0.00</td>
                    </tr>
                    <tr id='due' class='footer_row'>
                        <td id='due_label' class='grand total'>Due</td>
                        <td id='due_amt' class='grand total'>$19.00</td>
                    </tr>
                </tbody>
            </table>
            <div id='notices'>
                <div id='notes' class='notice'></div>
            </div>
        </main>
    </body>
</html>

from ios-htmltopdf.

JackIsBack avatar JackIsBack commented on July 18, 2024

Did you guys, have fix your problems with that pdf cuttings issues ?

I had similar problem when using table. I replaced my table with inline block divs or flex, and fix the problem.

I had the same issue too using css: float and text-align.

Anyone has a workaround about all those problems ?

from ios-htmltopdf.

Cai333 avatar Cai333 commented on July 18, 2024

After a lot of searching it seems the problem (for me at least) was with my print CSS. Printing the HTML from a browser gave the same blank page at the end.

Simple fix—add this to the CSS:

html, body { height: auto; }

May not work for everyone but it fixed my problem.

from ios-htmltopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.