HTML to PDF / DOCX / RTF Java converter library Forums PD4ML Forums Technical questions / Troubleshooting Wrong clipping using “box-sizing:border-box” in CSS

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38255

    The left-border in the table is cut-out by the parent div, but it should not since div and parent-div have same width.

    PD4ML v3 renders it correctly, but PD4ML v4 does not (it cuts out the border).

    The code follows. For the files, see attachments:
    – issue-1.html is the HTML source to be converted into PDF
    – issue-1-PDF4MLv3.pdf is the correct rendering made by version 3
    – issue-1-PDF4MLv4.pdf is the wrong rendering made by version 4

        public static void main(String[] args) throws Exception {
            PD4ML pd4ml = new PD4ML();
            pd4ml.applyLicense("...omissis...");
            
            pd4ml.setPageSize(new PageSize(595, 842));
            pd4ml.setPageMargins(new PageMargins(0, 0, 0, 0));
            pd4ml.setHtmlWidth(1190);
            pd4ml.generateForms(true, "sans-serif");
    
    
            String html = Files.readString(Paths.get("src/main/resources/sblend5.html"));
            ByteArrayInputStream bais = new ByteArrayInputStream(html.getBytes("UTF-8"));
            pd4ml.readHTML(bais, null, "utf-8");
    
            File pdf = File.createTempFile("result", ".pdf");
            FileOutputStream fos = new FileOutputStream(pdf);
            pd4ml.writePDF(fos);
    
            
            Desktop.getDesktop().open(pdf);
        }
    

    Attachments:
    You must be logged in to view attached files.
    #38259

    Since HTML file was rejected as attachment, here is the code:

    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            * {
                box-sizing:border-box;
                margin:0px;
                padding:0px;
            }
    
            body, td, div, b, th {
                font-family: Arial, Helvetica, sans-serif;
                font-size:19px;
                line-height:24px;
            }
    
            td {
                border: solid 1px #000000;
            }
    
            table {
                border-spacing: 0;
                border-collapse: collapse;
            }
    
            .fixed {
                height: 500px;
                overflow: hidden;
            }
    
            .page {
                padding: 95px;
            }
    
        </style>
    </head>
    <body>
        <div class="page">
            <table style="width:100%">
                <tr>
                    <td style="border:none">TEST STRING</td><td>TEST STRING</td>
                </tr>
                <tr>
                    <td>TEST STRING</td><td>TEST STRING</td>
                </tr>
            </table>
    
            <br>
    
            <div class="fixed">
                <table style="width:100%">
                    <tr>
                        <td style="border:none">TEST STRING</td><td>TEST STRING</td>
                    </tr>
                    <tr>
                        <td>TEST STRING</td><td>TEST STRING</td>
                    </tr>
                </table>
            </div>
        </div>
    </body>
    </html>
    
    

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.