IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

HTML Discussion :

Ajuster un template de facture HTML/CSS pour impression A4 avec marge d’en-tête de 10 cm


Sujet :

HTML

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    gestionnaire comptable
    Inscrit en
    Septembre 2019
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Cameroun

    Informations professionnelles :
    Activité : gestionnaire comptable
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2019
    Messages : 21
    Par défaut Ajuster un template de facture HTML/CSS pour impression A4 avec marge d’en-tête de 10 cm
    Salut tout le monde,

    J’essaie d'ajuster mon template pour que ça tienne sur un a4 et laisser 10 cm d'espace pour mon papier entête . je vous envoi mon code. je serai heureux que vous me disiez ce qui cloche.
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    <!DOCTYPE html>
    <html lang="fr">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Facture N° {{ facture.numero_facture }}</title>
        <scriptsrc="https://cdn.tailwindcss.com"></script>
     
        <style>
    /* 🚨 MARGES FINALES 10CM HAUT / 5CM BAS GÉRÉES PAR LE NAVIGATEUR/PDF 🚨 */
    @page { 
    size: A4; 
    margin-top: 100mm;   /* 100 mm (10 cm) pour l'en-tête papier */
    margin-bottom: 50mm; /* 50 mm (5 cm) pour le pied de page/signature */
    margin-left: 15mm; 
    margin-right: 15mm; 
            } 
     
    html, body { 
    height: 100%; 
    font-family: 'Inter', sans-serif; 
    font-size: 8pt; /* Police de base réduite pour compenser les 10cm perdus */
    background-color: white; 
    margin: 0;
    -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
    .invoice-container { 
    width: 180mm; /* Largeur réduite pour plus de marges latérales */
    margin: 0auto; 
    padding: 0; 
    background-color: white;
    overflow: hidden; 
            }
     
    .client-box { border: 1pxsolid#ddd; padding: 5px; border-radius: 4px; font-size: 8pt; }
     
    table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 8px; 
    border-radius: 4px; 
    overflow: hidden; 
            }
    th, td { 
    border: 1pxsolid#e0e0e0; 
    padding: 3px6px; 
    vertical-align: top;
    text-align: left; 
            }
    th { 
    background-color: #f2f2f2; 
    text-transform: uppercase; 
    font-size: 8pt;
    text-align: center;
            }
    .col-designation { width: 55%; text-align: left; }
    .col-base { width: 20%; text-align: right; }
    .col-montant { width: 25%; text-align: right; }
    .total-line { font-weight: bold; background-color: #e0f7fa; }
     
    /* Surbrillance pour TOTAL INTERVENTION HT */
    .highlight-total { 
    background-color: #fff3cd; /* Jaune très clair */
    font-weight: bold; 
    border-top: 2pxsolid#333; 
    border-bottom: 2pxsolid#333; 
            }
     
    .totals-summary { 
    width: 100%; 
    max-width: 300px; 
    float: right; 
    margin-top: 8px; 
            }
    .totals-summaryth, .totals-summarytd { border: none; padding: 4px8px; }
    .final-net-payer { font-size: 9pt; font-weight: bold; background-color: #333; color: white; }
     
    #montant-en-lettres-display { font-size: 8pt; line-height: 1.2; }
     
    @mediaprint {
    /* Garantir que les lignes de tableau ne soient pas coupées (si l'espace le permet) */
    tr { page-break-inside: avoid!important; } 
    .print-controls { display: none!important; }
            }
    .clear-both { clear: both; }
    .currency { text-align: right; }
     
    /* Ajustements pour les tables imbriquées des débours pour la densité */
    .invoice-body-inner { font-size: 7pt; }
    .invoice-body-innertd { padding: 2px4px; }
    </style>
    </head>
    <body>
     
    <!-- Print control (on-screen only; hidden in print by .print-controls) -->
    <div class="print-controls" style="text-align:right; margin:8px 0;">
        <button type="button" onclick="window.print()" style="padding:6px 10px; font-size:9pt; cursor:pointer;">Imprimer</button>
    </div>
     
    <div class="invoice-container">
     
        <div class="grid grid-cols-1 md:grid-cols-2 gap-3 mb-3" style="font-size: 9pt;">
            <div>
                <p class="mb-0"><strong>Facture N° : {{ facture.numero_facture }}</strong></p>
                <p class="mb-0"><strong>Dossier : {{ dossier.numero_dossier }}</strong></p>
                {% if dossier.nature_marchandise %}
                <p class="mb-0"><strong>NATURE.</strong> {{ dossier.nature_marchandise|truncatechars:60 }}</p>
                {% endif %}
            </div>
     
            <div style="text-align:right;">
                <p class="mt-0 mb-2">Douala, le {{ facture.date_facturation|date:"d F Y" }}</p>
                <div class="client-box" style="display:inline-block; text-align:left;">
                    <p style="margin:0; font-weight:bold;">Doit :</p>
                    <div style="font-weight:bold;">{{ dossier.client }}</div>
                    {% if dossier.bp %}<div>BP : {{ dossier.bp }}</div>{% endif %}
                    {% if dossier.rccm %}<div>RC. {{ dossier.rccm }}</div>{% endif %}
                    {% if dossier.niu %}<div>N° Contribuable : {{ dossier.niu }}</div>{% endif %}
                </div>
            </div>
        </div>
     
        <div class="bg-gray-100 p-2 rounded-lg mb-4" style="font-size: 8pt; line-height: 1.3;">
            <div class="grid grid-cols-2 md:grid-cols-3 gap-2">
                <span><strong>Type Conteneur:</strong> {{ dossier.type_conteneur }}</span>
                <span><strong>Navire ou Vol:</strong> {{ dossier.navire_ou_vol }}</span>
                <span><strong>Poids:</strong> {{ dossier.poids }} KGS</span>
     
                <span><strong>Valeur Imposable:</strong> {{ dossier.valeur_imposable|floatformat:2 }} XOF</span>
                <span><strong>Connaissement/LTA:</strong> {{ dossier.connaissement_ou_lta }}</span>
                <span><strong>N° Déclaration:</strong> {{ dossier.numero_declaration }}</span>
            </div>
        </div>
     
        <table>
            <thead>
                <tr>
                    <th class="col-designation">DÉSIGNATION</th>
                    <th class="col-base">BASE</th>
                    <th class="col-montant">MONTANT</th>
                </tr>
            </thead>
            <tbody id="invoice-body">
                <tr class="bg-gray-50">
                    <td colspan="3" class="font-bold" style="padding: 3px 6px;">1. DÉBOURS</td>
                </tr>
     
                <tr>
                    <td colspan="3" style="padding:0; border:none;">
                        <table class="invoice-body-inner" style="width:100%; border-collapse:collapse; margin:0;">
                            {% for d in debours_list %}
                            <tr>
                                <td style="border:1px solid #e0e0e0; width:55%;">{{ d.description }}</td>
                                <td style="border:1px solid #e0e0e0; width:20%; text-align:right;">-</td>
                                <td style="border:1px solid #e0e0e0; width:25%; text-align:right;">{{ d.montant_ht|floatformat:2 }}</td>
                            </tr>
                            {% endfor %}
                        </table>
                    </td>
                </tr>
     
                <tr class="total-line">
                    <td class="col-designation">TOTAL DÉBOURS</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ total_debours|floatformat:2 }}</td>
                </tr>
     
                <tr class="bg-gray-50">
                    <td colspan="3" class="font-bold" style="padding: 3px 6px;">2. INTERVENTIONS</td>
                </tr>
     
                <tr>
                    <td class="col-designation">COMMISSIONS SUR DÉBOURS {{ taux_commission_debours }}%</td>
                    <td class="col-base currency">{{ total_debours|floatformat:2 }}</td>
                    <td class="col-montant currency">{{ commission_debours|floatformat:2 }}</td>
                </tr>
                {% if arrondis > 0 %}
                <tr>
                    <td class="col-designation">ARRONDIS</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ arrondis|floatformat:2 }}</td> 
                </tr>
                {% endif %}
                <tr>
                    <td class="col-designation">FRAIS FIXE DE DOSSIER</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ frais_fixe_dossier|floatformat:2 }}</td> 
                </tr>
                {% if commission_transit > 0 %}
                <tr>
                    <td class="col-designation">COMMISSIONS SUR TRANSIT</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ commission_transit|floatformat:2 }}</td> 
                </tr>
                {% endif %}
                <tr>
                    <td class="col-designation">HONORAIRE AGRÉER EN DOUANE (HAD)</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ honoraire_had|floatformat:2 }}</td> 
                </tr>
     
                <tr class="highlight-total">
                    <td class="col-designation">TOTAL INTERVENTION HT</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ total_interventions_ht|floatformat:2 }}</td> 
                </tr>
     
                <tr>
                    <td class="col-designation">TVA {{ taux_tva|floatformat:2 }}% SUR INTERVENTION (hors HAD)</td>
                    <td class="col-base currency">{{ base_tva_interventions_hors_had|floatformat:2 }}</td> 
                    <td class="col-montant currency">{{ tva_interventions_hors_had|floatformat:2 }}</td> 
                </tr>
                <tr>
                    <td class="col-designation">TVA {{ taux_tva|floatformat:2 }}% SUR HAD</td>
                    <td class="col-base currency">{{ honoraire_had|floatformat:2 }}</td> 
                    <td class="col-montant currency">{{ tva_had|floatformat:2 }}</td> 
                </tr>
     
                <tr class="total-line">
                    <td class="col-designation">TOTAL INTERVENTION TTC</td>
                    <td class="col-base">-</td>
                    <td class="col-montant currency">{{ total_interventions_ttc|floatformat:2 }}</td> 
                </tr>
            </tbody>
        </table>
     
        <div class="totals-summary">
            <table class="w-full">
                <tbody>
     
                    <tr><td>TOTAL TTC (DÉBOURS + INTERVENTIONS)</td>
                        <td class="text-right" id="montant-ttc">{{ montant_ttc|floatformat:2 }}</td>
                    </tr>
     
                    {% if avance_had > 0 %}
                    <tr><td>(-) AVANCE HAD</td> <td class="text-right text-red-600">({{ avance_had|floatformat:2 }})</td> </tr>
                    {% endif %}
     
                    {% if avance_debours > 0 %}
                    <tr><td>(-) AVANCE DÉBOURS</td> 
                        <td class="text-right text-red-600">
                            ({{ avance_debours|floatformat:2 }})
                        </td> 
                    </tr>
                    {% endif %}
     
                    {% if tva_had_retenue_source > 0 %}
                    <tr><td>(-) TVA HAD RETENUE À LA SOURCE</td> <td class="text-right text-red-600">({{ tva_had_retenue_source|floatformat:2 }})</td> </tr>
                    {% endif %}
     
                    <tr class="final-net-payer">
                        <td>NET À PAYER</td>
                        <td class="text-right">{{ net_a_payer|floatformat:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
     
        <div class="clear-both"></div>
     
        <div style="margin-top:8px;">
            <div style="font-weight:bold; margin-bottom:3px; font-size: 8pt;">ARRÊTÉ LA FACTURE À LA SOMME DE :</div>
            <div id="montant-en-lettres-display">{{ montant_en_lettres|default:""|upper }}</div>
        </div>
     
        <div style="margin-top: 10px; border-top: 1px solid #ccc; padding-top: 5px; font-size: 7pt;">
            </div>
     
     
    </div> </body>
    </html>

  2. #2
    Invité de passage
    Homme Profil pro
    Inscrit en
    Mars 2013
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2013
    Messages : 26
    Par défaut
    Bonjour, la règles @mediaprint n'existe pas, c'est en deux mot @media print.
    Je placerais la règle @page à l'intérieur de la media queries @media print.
    Et mieux encore je séparerais clairement dans deux fichiers différents. Le fichier d'impression appeler avec l’attribut media de la balise <link>.
    https://developer.mozilla.org/en-US/...eries/Printing

Discussions similaires

  1. Cleaner HTML/CSS pour impression
    Par d3LTa7 dans le forum Bibliothèques et frameworks
    Réponses: 0
    Dernier message: 09/10/2020, 22h46
  2. Mutualiser du code html/css pour un site internet
    Par pierre13000 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 15/10/2018, 13h50
  3. [html][CSS]insérer un lien avec css ?
    Par Phenomenium dans le forum Mise en page CSS
    Réponses: 4
    Dernier message: 16/01/2006, 21h14
  4. [eclipse 3.0.1]plugins pour dvlp web HTML / CSS / PHP
    Par partyboy dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 26/10/2004, 12h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo