비즈니스 레터
개요
Letter 컴포넌트는 발신자/수신자 헤더, 날짜, 제목, 본문 단락, 서명 블록이 포함된 공식 비즈니스 레터 PDF를 생성합니다.
사용법
import "github.com/gpdf-dev/gpdf/template"
doc := template.Letter(template.LetterData{
From: template.LetterParty{
Name: "ACME Corporation",
Address: []string{
"123 Business Street",
"Suite 100",
"San Francisco, CA 94105",
"[email protected]",
},
},
To: template.LetterParty{
Name: "Mr. John Smith",
Address: []string{
"Tech Solutions Inc.",
"456 Client Avenue",
"New York, NY 10001",
},
},
Date: "March 1, 2026",
Subject: "Partnership Proposal",
Greeting: "Dear Mr. Smith,",
Body: []string{
"I am writing to express our interest in establishing a strategic partnership " +
"between ACME Corporation and Tech Solutions Inc. Over the past year, we have " +
"observed the remarkable growth of your organization and believe that a collaboration " +
"would be mutually beneficial.",
"Our proposal includes joint development of cloud-based solutions targeting " +
"the enterprise market. ACME Corporation brings extensive experience in PDF " +
"generation and document processing, while Tech Solutions Inc. has demonstrated " +
"excellence in frontend technologies and user experience design.",
"We would like to schedule a meeting at your earliest convenience to discuss " +
"the details of this proposal. Please feel free to contact me directly at " +
"[email protected] or call our office at (415) 555-0100.",
},
Closing: "Sincerely,",
Signature: "Jane Doe",
SignerTitle: "Chief Executive Officer",
})
data, err := doc.Generate()
┌─ A4 ──────────────────────────────────────────────┐
│ │
│ ACME Corporation │
│ 123 Business Street │
│ Suite 100 │
│ San Francisco, CA 94105 │
│ [email protected] │
│ │
│ March 1, 2026 │
│ │
│ Mr. John Smith │
│ Tech Solutions Inc. │
│ 456 Client Avenue │
│ New York, NY 10001 │
│ │
│ RE: Partnership Proposal │
│ ──────────────────────────────────────────────── │
│ │
│ Dear Mr. Smith, │
│ │
│ I am writing to express our interest in │
│ establishing a strategic partnership between │
│ ACME Corporation and Tech Solutions Inc... │
│ │
│ Our proposal includes joint development of │
│ cloud-based solutions targeting the enterprise │
│ market... │
│ │
│ We would like to schedule a meeting at your │
│ earliest convenience to discuss the details... │
│ │
│ │
│ Sincerely, │
│ │
│ Jane Doe │
│ Chief Executive Officer │
│ │
└───────────────────────────────────────────────────┘
데이터 타입
LetterData
| 필드 | 타입 | 설명 |
|---|---|---|
From | LetterParty | 발신자 정보 |
To | LetterParty | 수신자 정보 |
Date | string | 레터 날짜 |
Subject | string | 제목줄 |
Greeting | string | 인사말 (예: "Dear Mr. Smith,") |
Body | []string | 본문 단락 |
Closing | string | 맺음말 (예: "Sincerely,") |
Signature | string | 서명자 이름 |
SignerTitle | string | 서명자 직함 |
LetterParty
type LetterParty struct {
Name string
Address []string
}
커스터마이징
문서 옵션을 전달하여 레터를 커스터마이징합니다:
fontData, _ := os.ReadFile("fonts/NotoSansJP-Regular.ttf")
doc := template.Letter(letterData,
template.WithFont("NotoSansJP", fontData),
template.WithDefaultFont("NotoSansJP", 12),
template.WithPageSize(document.Letter),
)
퍼사드 사용
import "github.com/gpdf-dev/gpdf"
doc := gpdf.NewLetter(letterData)