Skip to main content

Rich Text & Word to PDF Converter

Convert formatted text, Google Docs, or Word clipboard content into clean A4 PDF documents while preserving bolding, headers, lists, and colors.

Loading editor...

Technical Architecture: Reverse-Engineering Clipboard Ingestion & Print Layout​

Copy-pasting styled content from Microsoft Word, Google Docs, or Apple Pages injects hundreds of proprietary MSO tags (e.g. <!--[if gte mso 9]>, class="MsoNormal"). This converter normalizes the DOM tree into clean semantic HTML before applying A4 print styles and compiling the PDF.

1. Clipboard HTML Sanitization & Normalization​

When pasted into the ContentEditable container, the ingestion pipeline strips proprietary Microsoft Office metadata while preserving structural semantic formatting:

function cleanPastedWordHtml(rawHtml: string): string {
// Strip MSO header and comment blocks
let clean = rawHtml.replace(/<!--[\s\S]*?-->/g, '');
clean = clean.replace(/<o:p>[\s\S]*?<\/o:p>/g, '');
clean = clean.replace(/class="MsoNormal"/g, '');

// Preserve core semantic elements: <b>, <i>, <ul>, <ol>, <h1>-<h3>, <table>
return clean;
}

2. High-DPI Canvas Rendering & Multi-Page Calculation​

To prevent low-resolution raster artifacts on high-DPI and Retina screens, the document is rasterized using a 2x device pixel ratio scale factor before generating PDF pages:

import html2pdf from 'html2pdf.js';

function exportRichTextToPdf(element: HTMLElement, filename: string) {
const options = {
margin: [15, 15, 15, 15], // 15mm margins
filename: `${filename}.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true, letterRendering: true },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
};

html2pdf().set(options).from(element).save();
}

Supported Rich Text Formatting Attributes​

Formatting FeatureClipboard SourceImplementation Note
Typography HierarchyWord / Google Docs H1–H3Scaled with proportional line heights
ListsBulleted (<ul>) & Numbered (<ol>)Native indentation and margin preservation
Inline StylesBold, Italic, Underline, StrikethroughRendered with standard font weights
Text ColorsHex & RGB text colorsHigh-contrast reproduction
Page SizingISO Standard A4 (210 × 297 mm)Automatic page breaks between long sections

Client-Side Security & Zero-Server Data Isolation​

  • Pure Local Execution: 100% of clipboard parsing, styling, and PDF assembly occurs in your local browser thread. Private legal memos, resumes, and proprietary corporate documents are never uploaded to any server.
  • Ephemeral Memory State: Pasted rich text is not written to localStorage or transmitted across background network requests.
  • Zero Telemetry on Content: Document titles and clipboard data remain completely private.

Get notified about updates to this tool

No spam. Just high-quality updates about new features and guides.