Skip to content

bhbaekhodev-commits/printbridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PrintBridge

Web-to-Print module for converting web content to high-quality PDFs

MIT License TypeScript GitHub stars GitHub issues PRs Welcome

Problem Statement

When creating exhibition websites, a common pain point is converting web content to print-ready PDFs:

  1. Layout breaks when converting web pages to PDF
  2. Manual work required to adjust layouts for different paper sizes (A4, booklet, etc.)
  3. Text sizing doesn't automatically fit within designated areas
  4. Repetitive process for each page/exhibition

PrintBridge solves this by providing a flexible, reusable module that automatically fits web content to print layouts.

Features

  • 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

Quick Start

Installation

# Core library (framework-agnostic)
npm install @printbridge/core

# React components
npm install @printbridge/react

Basic Usage

import { 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')}`);

Project Structure

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

Development

Prerequisites

  • Node.js 18+
  • npm 9+

Setup

# 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 dev

Commands

  • npm run build - Build all packages
  • npm run dev - Run all packages in development mode
  • npm run test - Run tests across all packages
  • npm run lint - Lint all packages
  • npm run format - Format code with Prettier

Roadmap

Phase 1: MVP (Current)

  • Core text fitting algorithm
  • Image layout engine
  • Basic utilities (units, page sizes)
  • TypeScript types
  • React components
  • Demo application

Phase 2: Templates

  • A4 portrait/landscape templates
  • Booklet template (2-up printing)
  • Template customization UI
  • Save/load layouts

Phase 3: PDF Generation

  • Client-side PDF generation (html2canvas + jsPDF)
  • Server-side PDF generation (Puppeteer)
  • High-quality output options
  • Batch processing

Phase 4: Advanced Features

  • Collaborative editing
  • Cloud storage integration
  • i18n support
  • Advanced typography controls

๐ŸŽ“ For Beginners (์ดˆ๋ณด์ž ๊ฐ€์ด๋“œ)

์ฝ”๋”ฉ์„ ๋ฐฐ์šฐ๋Š” ๋ถ„๋“ค์„ ์œ„ํ•œ ์‰ฌ์šด ์„ค๋ช…์ž…๋‹ˆ๋‹ค.

๐Ÿ“š ๊ฐœ๋ฐœ ์šฉ์–ด ์‚ฌ์ „ (์˜์–ด-ํ•œ๊ธ€-์„ค๋ช…)

์šฉ์–ด ํ•œ๊ธ€ ์‰ฌ์šด ์„ค๋ช…
Monorepo ๋ชจ๋…ธ๋ ˆํฌ ์—ฌ๋Ÿฌ ํ”„๋กœ์ ํŠธ๋ฅผ ํ•œ ํด๋”์— ๋ชจ์•„๋‘” ๊ฒƒ (๋ ˆ๊ณ  ์ƒ์ž ํ•˜๋‚˜์— ์—ฌ๋Ÿฌ ์„ธํŠธ)
TypeScript ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ JavaScript์— ํƒ€์ž… ์ฒดํฌ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•œ ์–ธ์–ด (์‹ค์ˆ˜ ๋ฐฉ์ง€ ๋„์šฐ๋ฏธ)
Package ํŒจํ‚ค์ง€ ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ฝ”๋“œ ๋ฌถ์Œ (์š”๋ฆฌ ์žฌ๋ฃŒ ํ‚คํŠธ)
npm NPM Node.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ €์žฅ์†Œ (์•ฑ ์Šคํ† ์–ด ๊ฐ™์€ ๊ณณ)
Build ๋นŒ๋“œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ (์š”๋ฆฌ ์žฌ๋ฃŒโ†’์™„์„ฑ๋œ ์Œ์‹)
Test ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๊ฐ€ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธ (๋ง›๋ณด๊ธฐ)
API API ํ”„๋กœ๊ทธ๋žจ๋ผ๋ฆฌ ๋Œ€ํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ• (๋ฉ”๋‰ดํŒ)
Layout Engine ๋ ˆ์ด์•„์›ƒ ์—”์ง„ ๊ธ€์ž์™€ ๊ทธ๋ฆผ์„ ์˜ˆ์˜๊ฒŒ ๋ฐฐ์น˜ํ•˜๋Š” ์‹œ์Šคํ…œ (์ž๋™ ์ •๋ฆฌ ๋กœ๋ด‡)
Git ๊นƒ ์ฝ”๋“œ ๋ณ€๊ฒฝ ์ด๋ ฅ์„ ์ €์žฅํ•˜๋Š” ๋„๊ตฌ (ํƒ€์ž„๋จธ์‹ )
Repository ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฝ”๋“œ๋ฅผ ์ €์žฅํ•˜๋Š” ์žฅ์†Œ (์ฝ”๋“œ ์ฐฝ๊ณ )

๐Ÿ—๏ธ ํ”„๋กœ์ ํŠธ ๊ตฌ์กฐ (5์„ธ ์„ค๋ช…)

PrintBridge๋Š” ๋ ˆ๊ณ  ์„ธํŠธ์ฒ˜๋Ÿผ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด์š”!

printbridge/               ๐Ÿ  ํฐ ์ง‘
โ”œโ”€โ”€ packages/             ๐Ÿ“ฆ ๋ ˆ๊ณ  ๋ธ”๋ก ๋ณด๊ด€ํ•จ
โ”‚   โ”œโ”€โ”€ core/            ๐Ÿงฑ ๊ธฐ๋ณธ ๋ธ”๋ก๋“ค (ํ…์ŠคํŠธ, ์ด๋ฏธ์ง€ ๋ฐฐ์น˜)
โ”‚   โ””โ”€โ”€ react/           ๐ŸŽจ ์˜ˆ์œ ๊พธ๋ฏธ๊ธฐ ๋ธ”๋ก๋“ค
โ”œโ”€โ”€ apps/                ๐ŸŽฎ ์™„์„ฑ๋œ ์žฅ๋‚œ๊ฐ๋“ค
โ”‚   โ””โ”€โ”€ demo/            ๐Ÿ–ผ๏ธ ์‹œ๋ฒ”์šฉ ์•ฑ
โ””โ”€โ”€ examples/            ๐Ÿ“– ์‚ฌ์šฉ ์„ค๋ช…์„œ

์‰ฝ๊ฒŒ ๋งํ•˜๋ฉด:

  • packages/core: ํ•ต์‹ฌ ๊ธฐ๋Šฅ (๋ ˆ๊ณ ์˜ ๊ธฐ๋ณธ ๋ธ”๋ก)
  • packages/react: ํ™”๋ฉด์— ๋ณด์ด๋Š” ๋ถ€๋ถ„ (๋ ˆ๊ณ ์˜ ๊พธ๋ฏธ๊ธฐ ๋ธ”๋ก)
  • apps/demo: ์‹ค์ œ ์‚ฌ์šฉ ์˜ˆ์‹œ (์™„์„ฑ๋œ ๋ ˆ๊ณ  ์ž‘ํ’ˆ)

๐Ÿ’ก ๊ผญ ์•”๊ธฐํ•ด์•ผ ํ•  ๊ฒฐ์ •์  ์ง€์‹

1. ์ด ํ”„๋กœ์ ํŠธ๊ฐ€ ํ•˜๋Š” ์ผ (ํ•œ ๋ฌธ์žฅ)

"์›น ํŽ˜์ด์ง€๋ฅผ ์ธ์‡„ํ•  ๋•Œ ๊ธ€์ž์™€ ๊ทธ๋ฆผ์ด ์ž๋™์œผ๋กœ ๋”ฑ ๋งž๊ฒŒ ์กฐ์ ˆ๋˜๋„๋ก ๋„์™€์ค˜์š”"

2. ํ•ต์‹ฌ ๊ธฐ๋Šฅ 3๊ฐ€์ง€

  1. ํ…์ŠคํŠธ ์ž๋™ ํฌ๊ธฐ ์กฐ์ ˆ - ๊ธ€์ž๊ฐ€ ๊ณต๊ฐ„์— ๊ฝ‰ ์ฐจ๊ฒŒ
  2. ์ด๋ฏธ์ง€ ๋ฐฐ์น˜ - ์‚ฌ์ง„์ด ์˜ˆ์˜๊ฒŒ ๋“ค์–ด๊ฐ€๊ฒŒ
  3. PDF ์ƒ์„ฑ - ์ธ์‡„์šฉ ํŒŒ์ผ๋กœ ๋ณ€ํ™˜

3. ํŒŒ์ผ์„ ์ˆ˜์ •ํ•  ๋•Œ ๊ทœ์น™

โœ… ํ•ด๋„ ๋˜๋Š” ๊ฒƒ:
- packages/core/src/ ์•ˆ์˜ TypeScript ํŒŒ์ผ ์ˆ˜์ •
- README.md ๋ฌธ์„œ ๊ฐœ์„ 
- ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€

โŒ ํ•˜๋ฉด ์•ˆ ๋˜๋Š” ๊ฒƒ:
- node_modules/ ์ ˆ๋Œ€ ๊ฑด๋“œ๋ฆฌ์ง€ ๋งˆ์„ธ์š”
- package-lock.json ์ˆ˜๋™์œผ๋กœ ์ˆ˜์ • ๊ธˆ์ง€
- dist/ ํด๋”๋Š” ์ž๋™ ์ƒ์„ฑ๋˜๋Š” ๊ณณ

4. ์ž์ฃผ ์“ฐ๋Š” ๋ช…๋ น์–ด (์™ธ์šฐ๋ฉด ์ข‹์•„์š”)

# ํŒจํ‚ค์ง€ ์„ค์น˜
npm install

# ๋นŒ๋“œํ•˜๊ธฐ (์ฝ”๋“œ๋ฅผ ์‹คํ–‰ ๊ฐ€๋Šฅํ•˜๊ฒŒ)
npm run build

# ํ…Œ์ŠคํŠธ ์‹คํ–‰
npm run test

# ์ฝ”๋“œ ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ €์žฅ
git add .
git commit -m "์„ค๋ช…"
git push

๐ŸŽฏ ์ฒ˜์Œ ์‹œ์ž‘ํ•˜๋Š” ๋ฐฉ๋ฒ• (๋‹จ๊ณ„๋ณ„)

Step 1: ํ”„๋กœ์ ํŠธ ๋‹ค์šด๋กœ๋“œ

git clone https://github.com/bhbaekhodev-commits/printbridge.git
cd printbridge

Step 2: ์žฌ๋ฃŒ ์ค€๋น„ (ํŒจํ‚ค์ง€ ์„ค์น˜)

npm install

โฐ 3-5๋ถ„ ์†Œ์š” (์ปคํ”ผ ํ•œ ์ž” ํƒ€์ž„!)

Step 3: ๋นŒ๋“œํ•˜๊ธฐ

npm run build

โœ… ์„ฑ๊ณตํ•˜๋ฉด: "Build success" ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์™€์š”

Step 4: ํ…Œ์ŠคํŠธํ•˜๊ธฐ

npm run test

โœ… ์„ฑ๊ณตํ•˜๋ฉด: "7 passed" ๊ฐ™์€ ๋ฉ”์‹œ์ง€


๐Ÿš€ ์‹ค์ „ ์˜ˆ์ œ (๋”ฐ๋ผ ํ•ด๋ณด์„ธ์š”)

์˜ˆ์ œ 1: ํ…์ŠคํŠธ ์ž๋™ ํฌ๊ธฐ ๋งž์ถ”๊ธฐ

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๊ฐ€ ์ž๋™์œผ๋กœ ๊ธ€์ž ํฌ๊ธฐ๋ฅผ ๊ณ„์‚ฐํ•ด์ค˜์š”
  • ๊ณต๊ฐ„์— ๋”ฑ ๋งž๋Š” ํฌ๊ธฐ๋ฅผ ์ฐพ์•„์ค˜์š”!

๐ŸŽ ์ข‹์€ ์Šต๊ด€ (์ถ”์ฒœ)

1. ์ฝ”๋“œ ์ž‘์„ฑ ์ „์—

# ํ•ญ์ƒ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๋ฐ์ดํŠธ
git pull

# ์ƒˆ ๋ธŒ๋žœ์น˜ ๋งŒ๋“ค๊ธฐ
git checkout -b my-feature

2. ์ฝ”๋“œ ์ž‘์„ฑ ํ›„์—

# ํ…Œ์ŠคํŠธ ๋จผ์ €!
npm run test

# ๋นŒ๋“œ ํ™•์ธ
npm run build

# ๋ฌธ์ œ ์—†์œผ๋ฉด ์ €์žฅ
git add .
git commit -m "feat: ์ƒˆ ๊ธฐ๋Šฅ ์ถ”๊ฐ€"
git push

3. ๋ง‰ํž ๋•Œ ๋„์›€ ๋ฐ›๊ธฐ

  • ๐Ÿ› ๋ฒ„๊ทธ ๋ฐœ๊ฒฌ: Issues์— ์˜ฌ๋ฆฌ๊ธฐ
  • ๐Ÿ’ฌ ์งˆ๋ฌธ: Discussions์— ๋ฌผ์–ด๋ณด๊ธฐ
  • ๐Ÿ“š ๋ฌธ์„œ: CONTRIBUTING.md ์ฝ์–ด๋ณด๊ธฐ

๐ŸŽจ ๋‹ค์Œ์— ๋ฐฐ์šธ ๊ฒƒ (์ˆœ์„œ๋Œ€๋กœ)

  1. โœ… ์™„๋ฃŒ: ํ”„๋กœ์ ํŠธ ์ดํ•ดํ•˜๊ธฐ
  2. ๐Ÿ“– ๋‹ค์Œ: TypeScript ๊ธฐ์ดˆ ๋ฐฐ์šฐ๊ธฐ
  3. ๐ŸŽฏ ๊ทธ ๋‹ค์Œ: ๊ฐ„๋‹จํ•œ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ํ•ด๋ณด๊ธฐ
  4. ๐Ÿš€ ๋‚˜์ค‘์—: React ์ปดํฌ๋„ŒํŠธ ๋งŒ๋“ค๊ธฐ

๊ฟ€ํŒ: ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์”ฉ! ์ฒœ์ฒœํžˆ ํ•ด๋„ ๊ดœ์ฐฎ์•„์š” ๐Ÿ˜Š


๐Ÿง  ํ”„๋ ˆ์ž„์›Œํฌ ๊นŠ์ด ์ดํ•ดํ•˜๊ธฐ

๋” ๊นŠ์€ ์ดํ•ด๋ฅผ ์›ํ•œ๋‹ค๋ฉด: ํ”„๋ ˆ์ž„์›Œํฌ & ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ฐ€์ด๋“œ

์ด ๋ฌธ์„œ์—์„œ๋Š” PrintBridge์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋“  ๊ธฐ์ˆ ์„ ๋‹ค์Œ ๊ด€์ ์œผ๋กœ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค:

  • ๐Ÿ”ท ์ง‘ํ•ฉ๋ก ์  ๊ตฌ์กฐ: ๊ณ„์ธต๊ณผ ํฌํ•จ ๊ด€๊ณ„
  • ๐Ÿ”— ๊ด€๊ณ„: ๋‹ค๋ฅธ ๊ธฐ์ˆ ๊ณผ์˜ ์—ฐ๊ฒฐ๊ณ ๋ฆฌ
  • โšก ํ˜„์ƒ: ์‹ค์ œ ์ž‘๋™ ๋ฐฉ์‹
  • โš–๏ธ ๋ชจ์ˆœ: ์žฅ๋‹จ์ ๊ณผ ํŠธ๋ ˆ์ด๋“œ์˜คํ”„

๋‹ค๋ฃจ๋Š” ๊ธฐ์ˆ :

  • Turborepo (๋ชจ๋…ธ๋ ˆํฌ)
  • TypeScript (ํƒ€์ž… ์‹œ์Šคํ…œ)
  • React (UI ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)
  • Vitest (ํ…Œ์ŠคํŠธ)
  • ๊ทธ ์™ธ ์ฃผ์š” ๋„๊ตฌ๋“ค

์ด ๋ฐฉ๋ฒ•์œผ๋กœ ์ƒˆ๋กœ์šด ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ๋ฐฐ์šฐ๋ฉด ๋ณธ์งˆ์„ ๋น ๋ฅด๊ฒŒ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!


Contributing

Contributions are welcome! Please read our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details

Author

Created to solve real-world exhibition website printing challenges.

Acknowledgments

  • 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.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •