0

私は、EJS テンプレートに基づいて PDF ドキュメントを生成し、一部のユーザーに電子メールで送信する API に取り組んでいます。ローカルで実行すると、すべてが期待どおりに機能しますが、API が heroku にプッシュされると、奇妙なフォーマット エラーで PDF が生成されます。そのページは本質的に垂直に真ん中を切り取られているようなものです.

誰かがこれの考えられる原因を知っていますか?

私はejsとhtml-pdfを使用しています

コードとテンプレートはこちら

ドキュメント生成機能

ejs.renderFile(path.join(__dirname, '../views/', "offer.ejs"), {offerData}, (err, data) => {
                if(err)
                    reject(err)
                else
                {
                    const options = {
                        "height": "11.25in",
                        "width": "8.5in",
                        "header": {
                            "height": "10mm"
                        },
                        "footer": {
                            "height": "10mm",
                        }                    
                    };
                    //creates the actual pdf doc for sending
                    pdf.create(data, options).toFile(`./offer_${inqID}.pdf`, function(err, res) {
                        if (err) 
                            reject(err)
                        else
                            resolve(res.filename)                        
                      });    
                }
            });

html pdf テンプレート

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Trade-in Disclosure Form</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/css/bootstrap.min.css" integrity="sha384-VCmXjywReHh4PwowAiWNagnWcLhlEJLA5buUprzK8rxFgeH0kww/aWY76TfkUoSX" crossorigin="anonymous">
    <style>
        body{
            font-family: 'Roboto', sans-serif !important;            
        }
        h1{
            text-decoration: underline !important;
        }
        table.center {
            margin-left:auto; 
            margin-right:auto;
          }
        td.rows{
            padding-bottom: 10px;
            text-align: left !important;
        }
        td.question{
            padding-right: 15px;
        }
        span{
            font-weight:bold !important;                        
        }
    </style>
</head>
<body style="border: solid black 2px; margin-left: 10px; margin-right:10px;">
    <header class="text-center">
        <h1 >The Auto Broker</h1>
        <h2> Trade-In Vehicle Disclosure Form</h2>
        <p style="margin-left: 6em; margin-right: 6em">
            This Form has been filled out by the customer requesting a quote. It contains some basic details to help inform your evaluation of the vehicle.
            If the customer provides false information you have the right to recind or adjust your offer to the customer; otherwise include the value of 
            this vehicle in your total value for the quote. Please ensure to carefully review all the data before providing a quote. Quotes are final and
            cannot be altered once submitted. 
        </p>
    </header>
    <div style="padding-top:20px;">
        <div class="form-container container">
            <div class="row" style="background-color: black;">
                <h3 style="color: aliceblue;" class="ml-2"> Vehicle History</h3>
            </div>
            <table class="center">
                <thead>
                    <tr>
                        <th style="padding-bottom: 20px;"> <h4>Question </h4></th>
                        <th style="padding-bottom: 20px;"> <h4>Response </h4></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td class="rows question">Has the Vehicle been in an accident?</td>
                        <td class="rows"> <%= questionnaire.inaccident %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Have any panels been repainted, repaired <br> or replaced?</td>
                        <td class="rows"> <%= questionnaire.panelrepairs %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Are you the original owner?</td>
                        <td class="rows"> <%= questionnaire.originalowner %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Is this an American Vehicle?</td>
                        <td class="rows"> <%= questionnaire.usvehicle %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Has the Vehicle been registered in any other <br> Province/State?</td>
                        <td class="rows"> <%= questionnaire.outofprovreg %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Is the Odometer faulty, replaced or rolled back? </td>
                        <td class="rows"> <%= questionnaire.faultyodometer %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Does the vehicle have any lights on the dashboard?</td>
                        <td class="rows"> <%= questionnaire.dashlights %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Does the vehicle have any factory warranty?</td>
                        <td class="rows"> <%= questionnaire.factorywarranty %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Does the vehicle have extended warranty?</td>
                        <td class="rows"> <%= questionnaire.extwarrenty %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Was the vehicle ever used as a daily rental,  <br> police vehicle, or taxi/limousine?</td>
                        <td class="rows"> 
                           <% if (questionnaire.rental) { %>
                             Rental <br>
                            <% } %> 
                           
                           <% if (questionnaire.taxilimo) { %>
                            Taxi / Limo <br>
                           <% } %> 
                          
                          <% if (questionnaire.policecar){ %>
                            Police Vehicle <br>
                           <% } %> 
                                        
                         </td>
                    </tr>
                    <tr>
                        <td class="rows question">Does the vehicle require repairs to the following: <br>
                            <span style="margin-left: 10px;">Engine </span> <br> 
                            <span style="margin-left: 10px;">Transmission/Powertrain</span> <br>
                            <span style="margin-left: 10px;">Electrical System </span> <br>
                            <span style="margin-left: 10px;">Air Conditioning System</span>
                        </td>
                        <td class="rows">
                             <%= questionnaire.enginerepair %> <br>
                             <%= questionnaire.transrepair %> <br>
                             <%= questionnaire.electricalrepair %> <br>
                             <%= questionnaire.acrepairs %> <br>
                        </td>
                    </tr>
                    <tr>
                        <td class="rows question">Additional Repair Details</td>
                        <td class="rows"> <%= questionnaire.repairdetails %> </td>
                    </tr>
                    <tr>
                        <td class="rows question">Outstanding Balance</td>
                        <td class="rows"> 
                            <% if (questionnaire.outstandingbalance){ %>
                            <%= questionnaire.outstandingbalance  %>
                           <% } %>  
                        </td>
                    </tr>
                    <tr>
                        <td class="rows question">Total Current Milage</td>
                        <td class="rows"> <%= questionnaire.milage %> K.M </td>
                    </tr>
                    <tr>
                        <td class="rows question">V.I.N</td>
                        <td class="rows"> <%= questionnaire.vin %> </td>
                    </tr>                
                </tbody>
            </table>
        </div>
    </div>
</body>

</html>

適切な Img 適切なビュー 壊れた Img 壊れたバージョン

4

2 に答える 2