Skip to content

Shifting text downwards #1010

Description

@MrSatyam77

Text Position Shifts Down in Generated PDF

Version

  • Framework: Angular ^21.2.0
  • Angular Material: ^21.2.0
  • Tailwind CSS: ^3.4.19
  • html2pdf.js: ^0.14.0

Issue

I'm seeing a text positioning issue when generating a PDF with html2pdf.js. The content renders correctly in the browser, but after exporting to PDF, the text shifts downward relative to its original position.

Expected Behavior

The PDF output should match the browser rendering exactly.

Actual Behavior

The text is rendered lower in the generated PDF than it appears in the HTML.

html2pdf Configuration

const opt = {
  margin: 0.3,
  filename: generatedFileName,
  image: { type: 'jpeg' as const, quality: 1 },
  html2canvas: { scale: 2, useCORS: true, logging: false },
  jsPDF: { unit: 'in' as const, format: 'letter' as const, orientation: 'portrait' as const, compress: true},
  pagebreak: { mode: ['css', 'legacy'], before: '#page2el' }
};
html2pdf().from(element).set(opt).save();

Screenshots

Browser Rendering:
Image

Generated PDF:
Image

Any guidance would be appreciated. Thanks!

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