dompdf / dompdf/dompdf

Scaling moves content and doesn't change page count

Open
#1,193 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
11.2k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

My objective is to create a PDF of an html table containing user-defined content that affects both the number of columns and rows in the table. For a selected paper size, the number of columns may cause the content to extend beyond the width of the page. I implemented a user-defined scale that effectively inserts body {-webkit-transform: scale(0.80);} as a style if the user sets the scale to 80%. This has the effect of reducing the height and width of the table to 80% but two undesired side effects occur:

  1. The left margin width is inversely proportional to the scale. The lower the scale, the greater the left margin width resulting in the right of the table still extending beyond the page width. This seems to be caused by the pdf content centered on the page even though the html page is aligned left. I've experimented with margins for html, body, and @page but these cause other undesired side effects.
  2. The number of table rows per page isn't increased when the content is scaled down resulting in the same number of pages consumed and content having greater top and bottom margins.

Is there a solution for reducing the scale of the content but keeping a consistent margin on all sides of the content regardless of scale?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are identified in the issue. Start by reproducing a scaled HTML table with user-defined rows and columns in dompdf, then inspect how scaling affects horizontal margins and pagination. Done means the scaled content keeps consistent page margins and the reduced height allows the expected number of rows per page.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.