Skip to content

Portrait images are rotated in PDF output #840

@Wrightie

Description

@Wrightie

Hello, I am experimenting an odd issue :)
I'm creating a table with images; some of them are oriented in portait mode, some are in landscape.
This is the PHP code which generates the HTML:

  $myhtml = $myhtml . '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed;"><tbody>';
    $myhtml = $myhtml . '<tr style="height: 28px;">';
      $myhtml = $myhtml . '<td style="width: 100%; padding: 6px 8px; border-bottom: 2px solid black;" colspan="2"><b>ALLEGATI</b></td>';
    $myhtml = $myhtml . '</tr>';
  $myhtml = $myhtml . '</tbody></table>';
    $fotoid = 0;
    foreach ($qryfotovideo as $fotovideo) {
      $fotoid +=1;
      if ($fotoid % 2 == 1) {
        $myhtml = $myhtml . '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed;"><tbody>';
        $myhtml = $myhtml . '<tr>';
      }
      $myhtml = $myhtml . '<td style="width: 50%; text-align: center; padding: 6px 8px; border-bottom: 0.25px dashed black; font-size: 11px;">';
        if ($fotovideo["URL"] != "") {
          $fotoURL = $fotovideo["URL"];
          $myhtml = $myhtml . '<img style="display: block; margin-left: auto; margin-right: auto;" src="';
          $myhtml = $myhtml . $fotoURL . '" alt="" width="200" /><br><br>';
        }
        $myhtml = $myhtml . $fotovideo["DESCRIZIONE"];
        $myhtml = $myhtml . '</td>';
      if ($fotoid % 2 == 0) {
        $myhtml = $myhtml . '</tr>';
        $myhtml = $myhtml . '</tbody></table>';
      }
    }
    if ($fotoid % 2 == 1) {
      $myhtml = $myhtml . '<td></td>';
      $myhtml = $myhtml . '</tr>';
      $myhtml = $myhtml . '</tbody></table>';
    }

The resulting HTML is the following (note: it's an excerpt):

<table border="0" style="width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed;">
  <tbody>
    <tr>
      <td style="width: 50%; text-align: center; padding: 6px 8px; border-bottom: 0.25px dashed black; font-size: 11px;"><img style="display: block; margin-left: auto; margin-right: auto;" src="media/dmsf/2025/05/250511212135_10804_A08.JPG" alt="" width="200" /><br><br>250509 A08</td>
      <td style="width: 50%; text-align: center; padding: 6px 8px; border-bottom: 0.25px dashed black; font-size: 11px;"><img style="display: block; margin-left: auto; margin-right: auto;" src="media/dmsf/2025/05/250511212135_10805_A12.JPG" alt="" width="200" /><br><br>250509 A12</td>
    </tr>
  </tbody>
</table>
<table border="0" style="width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed;">
  <tbody>
    <tr>
      <td style="width: 50%; text-align: center; padding: 6px 8px; border-bottom: 0.25px dashed black; font-size: 11px;"><img style="display: block; margin-left: auto; margin-right: auto;" src="media/dmsf/2025/05/250511212135_10806_M01.JPG" alt="" width="200" /><br><br>250509 M01</td>
      <td style="width: 50%; text-align: center; padding: 6px 8px; border-bottom: 0.25px dashed black; font-size: 11px;"><img style="display: block; margin-left: auto; margin-right: auto;" src="media/dmsf/2025/05/250511212135_10807_I01.JPG" alt="" width="200" /><br><br>250509 I01</td>
    </tr>
  </tbody>
</table>

If I test the resulting HTML code, it works as expected, with portrait images correctly oriented (Chrome screenshot):
Image

...but the resulting PDF shows me rotated portrait images:
Image

Any idea?
Thanks a lot in advance :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions