How to display preview of HTML content same as browser’s print preview?

I need to create a preview feature that shows users exactly how their HTML content will look when printed by the browser, without actually printing or showing any print dialogs.

Problem:
I have an HTML editor where users create content with specific print styles (A4 format, margins, page breaks, etc.). Before printing, I want to show user exactly how their content will appear when printed by the browser. The preview must be exact same with the actual browser print output, as this is crucial for my use case.

Why Integrating Other Libraries Don’t Work:
Libraries like jsPDF, html2Pdf or other PDF generation libraries don’t produce the exact same output as the browser’s print engine. The differences in rendering, content positions and page breaks styles make these solutions inadequate for my needs.

Is there a way to:

  1. Access browser’s print preview rendering engine programmatically?
  2. Display the preview without triggering the print dialog?