Web-to-Print module for converting web content to high-quality PDFs
When creating exhibition websites, a common pain point is converting web content to print-ready PDFs:
- Layout breaks when converting web pages to PDF
- Manual work required to adjust layouts for different paper sizes (A4, booklet, etc.)
- Text sizing doesn't automatically fit within designated areas
- Repetitive process for each page/exhibition
PrintBridge solves this by providing a flexible, reusable module that automatically fits web content to print layouts.
- Automatic Text Fitting: Adjusts font size to maximize text within designated areas
- Smart Image Layout: Supports multiple fit strategies (cover, contain, fill)
- Multiple Page Formats: A4, A5, Letter, Legal, Tabloid
- Template System: Pre-built templates with customization options
- Framework Agnostic: Core library works anywhere, with React components available
- TypeScript First: Fully typed API for great developer experience
# Core library (framework-agnostic)
npm install @printbridge/core
# React components
npm install @printbridge/reactimport { fitTextToArea } from '@printbridge/core';
const text = 'Your exhibition text here...';
const area = { x: 0, y: 0, width: 400, height: 600 };
const constraints = {
minFontSize: 12,
maxFontSize: 48,
lineHeight: 1.5,
fontFamily: 'Arial',
};
const result = fitTextToArea(text, area, constraints);
console.log(`Optimal font size: ${result.fontSize}pt`);
console.log(`Lines: ${result.lines.join('\n')}`);This is a monorepo managed with Turborepo:
printbridge/
โโโ packages/
โ โโโ core/ # Core layout engine (framework-agnostic)
โ โโโ react/ # React components
โโโ apps/
โ โโโ demo/ # Next.js demo application
โโโ examples/
โโโ exhibition-website/ # Real-world usage example
- Node.js 18+
- npm 9+
# Clone the repository
git clone https://github.com/YOUR_USERNAME/printbridge.git
cd printbridge
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm run test
# Start demo app
npm run devnpm run build- Build all packagesnpm run dev- Run all packages in development modenpm run test- Run tests across all packagesnpm run lint- Lint all packagesnpm run format- Format code with Prettier
- Core text fitting algorithm
- Image layout engine
- Basic utilities (units, page sizes)
- TypeScript types
- React components
- Demo application
- A4 portrait/landscape templates
- Booklet template (2-up printing)
- Template customization UI
- Save/load layouts
- Client-side PDF generation (html2canvas + jsPDF)
- Server-side PDF generation (Puppeteer)
- High-quality output options
- Batch processing
- Collaborative editing
- Cloud storage integration
- i18n support
- Advanced typography controls
์ฝ๋ฉ์ ๋ฐฐ์ฐ๋ ๋ถ๋ค์ ์ํ ์ฌ์ด ์ค๋ช ์ ๋๋ค.
| ์ฉ์ด | ํ๊ธ | ์ฌ์ด ์ค๋ช |
|---|---|---|
| Monorepo | ๋ชจ๋ ธ๋ ํฌ | ์ฌ๋ฌ ํ๋ก์ ํธ๋ฅผ ํ ํด๋์ ๋ชจ์๋ ๊ฒ (๋ ๊ณ ์์ ํ๋์ ์ฌ๋ฌ ์ธํธ) |
| TypeScript | ํ์ ์คํฌ๋ฆฝํธ | JavaScript์ ํ์ ์ฒดํฌ ๊ธฐ๋ฅ์ ์ถ๊ฐํ ์ธ์ด (์ค์ ๋ฐฉ์ง ๋์ฐ๋ฏธ) |
| Package | ํจํค์ง | ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ฝ๋ ๋ฌถ์ (์๋ฆฌ ์ฌ๋ฃ ํคํธ) |
| npm | NPM | Node.js ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ฅ์ (์ฑ ์คํ ์ด ๊ฐ์ ๊ณณ) |
| Build | ๋น๋ | ์ฝ๋๋ฅผ ์คํ ๊ฐ๋ฅํ ํํ๋ก ๋ณํ (์๋ฆฌ ์ฌ๋ฃโ์์ฑ๋ ์์) |
| Test | ํ ์คํธ | ์ฝ๋๊ฐ ์ ๋๋ก ์๋ํ๋์ง ํ์ธ (๋ง๋ณด๊ธฐ) |
| API | API | ํ๋ก๊ทธ๋จ๋ผ๋ฆฌ ๋ํํ๋ ๋ฐฉ๋ฒ (๋ฉ๋ดํ) |
| Layout Engine | ๋ ์ด์์ ์์ง | ๊ธ์์ ๊ทธ๋ฆผ์ ์์๊ฒ ๋ฐฐ์นํ๋ ์์คํ (์๋ ์ ๋ฆฌ ๋ก๋ด) |
| Git | ๊น | ์ฝ๋ ๋ณ๊ฒฝ ์ด๋ ฅ์ ์ ์ฅํ๋ ๋๊ตฌ (ํ์๋จธ์ ) |
| Repository | ๋ฆฌํฌ์งํ ๋ฆฌ | ์ฝ๋๋ฅผ ์ ์ฅํ๋ ์ฅ์ (์ฝ๋ ์ฐฝ๊ณ ) |
PrintBridge๋ ๋ ๊ณ ์ธํธ์ฒ๋ผ ๊ตฌ์ฑ๋์ด ์์ด์!
printbridge/ ๐ ํฐ ์ง
โโโ packages/ ๐ฆ ๋ ๊ณ ๋ธ๋ก ๋ณด๊ดํจ
โ โโโ core/ ๐งฑ ๊ธฐ๋ณธ ๋ธ๋ก๋ค (ํ
์คํธ, ์ด๋ฏธ์ง ๋ฐฐ์น)
โ โโโ react/ ๐จ ์์ ๊พธ๋ฏธ๊ธฐ ๋ธ๋ก๋ค
โโโ apps/ ๐ฎ ์์ฑ๋ ์ฅ๋๊ฐ๋ค
โ โโโ demo/ ๐ผ๏ธ ์๋ฒ์ฉ ์ฑ
โโโ examples/ ๐ ์ฌ์ฉ ์ค๋ช
์
์ฝ๊ฒ ๋งํ๋ฉด:
packages/core: ํต์ฌ ๊ธฐ๋ฅ (๋ ๊ณ ์ ๊ธฐ๋ณธ ๋ธ๋ก)packages/react: ํ๋ฉด์ ๋ณด์ด๋ ๋ถ๋ถ (๋ ๊ณ ์ ๊พธ๋ฏธ๊ธฐ ๋ธ๋ก)apps/demo: ์ค์ ์ฌ์ฉ ์์ (์์ฑ๋ ๋ ๊ณ ์ํ)
"์น ํ์ด์ง๋ฅผ ์ธ์ํ ๋ ๊ธ์์ ๊ทธ๋ฆผ์ด ์๋์ผ๋ก ๋ฑ ๋ง๊ฒ ์กฐ์ ๋๋๋ก ๋์์ค์"
- ํ ์คํธ ์๋ ํฌ๊ธฐ ์กฐ์ - ๊ธ์๊ฐ ๊ณต๊ฐ์ ๊ฝ ์ฐจ๊ฒ
- ์ด๋ฏธ์ง ๋ฐฐ์น - ์ฌ์ง์ด ์์๊ฒ ๋ค์ด๊ฐ๊ฒ
- PDF ์์ฑ - ์ธ์์ฉ ํ์ผ๋ก ๋ณํ
โ
ํด๋ ๋๋ ๊ฒ:
- packages/core/src/ ์์ TypeScript ํ์ผ ์์
- README.md ๋ฌธ์ ๊ฐ์
- ํ
์คํธ ์ถ๊ฐ
โ ํ๋ฉด ์ ๋๋ ๊ฒ:
- node_modules/ ์ ๋ ๊ฑด๋๋ฆฌ์ง ๋ง์ธ์
- package-lock.json ์๋์ผ๋ก ์์ ๊ธ์ง
- dist/ ํด๋๋ ์๋ ์์ฑ๋๋ ๊ณณ
# ํจํค์ง ์ค์น
npm install
# ๋น๋ํ๊ธฐ (์ฝ๋๋ฅผ ์คํ ๊ฐ๋ฅํ๊ฒ)
npm run build
# ํ
์คํธ ์คํ
npm run test
# ์ฝ๋ ๋ณ๊ฒฝ์ฌํญ ์ ์ฅ
git add .
git commit -m "์ค๋ช
"
git pushgit clone https://github.com/bhbaekhodev-commits/printbridge.git
cd printbridgenpm installโฐ 3-5๋ถ ์์ (์ปคํผ ํ ์ ํ์!)
npm run buildโ ์ฑ๊ณตํ๋ฉด: "Build success" ๋ฉ์์ง๊ฐ ๋์์
npm run testโ ์ฑ๊ณตํ๋ฉด: "7 passed" ๊ฐ์ ๋ฉ์์ง
import { fitTextToArea } from '@printbridge/core';
// 1. ํ
์คํธ ์ค๋น
const myText = "์๋
ํ์ธ์! PrintBridge์
๋๋ค.";
// 2. ๊ณต๊ฐ ์ ํ๊ธฐ (๊ฐ๋ก 400, ์ธ๋ก 300)
const space = { x: 0, y: 0, width: 400, height: 300 };
// 3. ์ค์ ํ๊ธฐ
const settings = {
minFontSize: 12, // ์ต์ ๊ธ์ ํฌ๊ธฐ
maxFontSize: 48, // ์ต๋ ๊ธ์ ํฌ๊ธฐ
lineHeight: 1.5, // ์ค ๊ฐ๊ฒฉ
fontFamily: 'Arial'
};
// 4. ๋ง๋ฒ ๋ฐ๋! โจ
const result = fitTextToArea(myText, space, settings);
// 5. ๊ฒฐ๊ณผ ํ์ธ
console.log(`์ต์ ๊ธ์ ํฌ๊ธฐ: ${result.fontSize}pt`);
console.log(`์ค ์: ${result.lines.length}`);๋ฌด์จ ์ผ์ด ์ผ์ด๋ฌ๋์?
- PrintBridge๊ฐ ์๋์ผ๋ก ๊ธ์ ํฌ๊ธฐ๋ฅผ ๊ณ์ฐํด์ค์
- ๊ณต๊ฐ์ ๋ฑ ๋ง๋ ํฌ๊ธฐ๋ฅผ ์ฐพ์์ค์!
# ํญ์ ์ต์ ๋ฒ์ ์ผ๋ก ์
๋ฐ์ดํธ
git pull
# ์ ๋ธ๋์น ๋ง๋ค๊ธฐ
git checkout -b my-feature# ํ
์คํธ ๋จผ์ !
npm run test
# ๋น๋ ํ์ธ
npm run build
# ๋ฌธ์ ์์ผ๋ฉด ์ ์ฅ
git add .
git commit -m "feat: ์ ๊ธฐ๋ฅ ์ถ๊ฐ"
git push- ๐ ๋ฒ๊ทธ ๋ฐ๊ฒฌ: Issues์ ์ฌ๋ฆฌ๊ธฐ
- ๐ฌ ์ง๋ฌธ: Discussions์ ๋ฌผ์ด๋ณด๊ธฐ
- ๐ ๋ฌธ์: CONTRIBUTING.md ์ฝ์ด๋ณด๊ธฐ
- โ ์๋ฃ: ํ๋ก์ ํธ ์ดํดํ๊ธฐ
- ๐ ๋ค์: TypeScript ๊ธฐ์ด ๋ฐฐ์ฐ๊ธฐ
- ๐ฏ ๊ทธ ๋ค์: ๊ฐ๋จํ ๊ธฐ๋ฅ ์ถ๊ฐํด๋ณด๊ธฐ
- ๐ ๋์ค์: React ์ปดํฌ๋ํธ ๋ง๋ค๊ธฐ
๊ฟํ: ํ ๋ฒ์ ํ๋์ฉ! ์ฒ์ฒํ ํด๋ ๊ด์ฐฎ์์ ๐
๋ ๊น์ ์ดํด๋ฅผ ์ํ๋ค๋ฉด: ํ๋ ์์ํฌ & ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฐ์ด๋
์ด ๋ฌธ์์์๋ PrintBridge์์ ์ฌ์ฉํ๋ ๋ชจ๋ ๊ธฐ์ ์ ๋ค์ ๊ด์ ์ผ๋ก ์ค๋ช ํฉ๋๋ค:
- ๐ท ์งํฉ๋ก ์ ๊ตฌ์กฐ: ๊ณ์ธต๊ณผ ํฌํจ ๊ด๊ณ
- ๐ ๊ด๊ณ: ๋ค๋ฅธ ๊ธฐ์ ๊ณผ์ ์ฐ๊ฒฐ๊ณ ๋ฆฌ
- โก ํ์: ์ค์ ์๋ ๋ฐฉ์
- โ๏ธ ๋ชจ์: ์ฅ๋จ์ ๊ณผ ํธ๋ ์ด๋์คํ
๋ค๋ฃจ๋ ๊ธฐ์ :
- Turborepo (๋ชจ๋ ธ๋ ํฌ)
- TypeScript (ํ์ ์์คํ )
- React (UI ๋ผ์ด๋ธ๋ฌ๋ฆฌ)
- Vitest (ํ ์คํธ)
- ๊ทธ ์ธ ์ฃผ์ ๋๊ตฌ๋ค
์ด ๋ฐฉ๋ฒ์ผ๋ก ์๋ก์ด ํ๋ ์์ํฌ๋ฅผ ๋ฐฐ์ฐ๋ฉด ๋ณธ์ง์ ๋น ๋ฅด๊ฒ ํ์ ํ ์ ์์ต๋๋ค!
Contributions are welcome! Please read our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see the LICENSE file for details
Created to solve real-world exhibition website printing challenges.
- Inspired by the need for seamless web-to-print workflows
- Built with TypeScript, React, and Next.js
- Powered by Turborepo
PrintBridge - Bridging the gap between web and print.