@jackgreen2018/gbp-post-generator
v1.0.3
Published
Generate Google Business Profile post PDFs client-side via Rust/WASM. Fast, browser-first, no server required.
Readme
@jackgreen2018/gbp-post-generator
A lightweight, high-performance Google Business Profile post PDF generator that runs entirely in the browser or Node.js via Rust/WASM. No server required — 100% client-side with Rust-level speed.
Generate professional post cards for Google Business Profile updates. Perfect for small business owners who want a clean, branded post draft in seconds.
Install
npm install @jackgreen2018/gbp-post-generatorUsage
import { generateGbpPost, initialize } from '@jackgreen2018/gbp-post-generator';
await initialize();
const pdfBytes = await generateGbpPost({
business_name: "Joe's Coffee Shop",
post_headline: "Summer Special: Cold Brew 20% Off!",
post_body: "Stop by Joe's Coffee Shop this summer and enjoy 20% off all cold brew beverages. Valid through August 31st.",
cta_text: "Learn More",
offer_text: "20% off cold brew",
offer_valid_until: "August 31, 2026",
accent_color: [41, 98, 255]
});
// pdfBytes is a Uint8Array containing the PDF
// Save it or display it in the browser
const blob = new Blob([pdfBytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
window.open(url);Node.js (save to file)
import { writeFile } from 'fs/promises';
import { generateGbpPost, initialize } from '@jackgreen2018/gbp-post-generator';
await initialize();
const pdfBytes = await generateGbpPost({
business_name: "Joe's Coffee Shop",
post_headline: "Grand Opening!",
post_body: "We are excited to announce our grand opening. Join us this weekend for special offers and free samples!",
cta_text: "Get Directions",
accent_color: [41, 98, 255]
});
await writeFile('gbp-post.pdf', Buffer.from(pdfBytes));API
generateGbpPost(options)
Returns a Promise<Uint8Array> containing the PDF bytes.
Options:
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| business_name | string | yes | — | Business name displayed in header |
| post_headline | string | yes | — | Post title/headline |
| post_body | string | yes | — | Main post content text |
| cta_text | string | no | — | Call-to-action button text |
| offer_text | string | no | — | Offer/promotion text |
| offer_valid_until | string | no | — | Offer expiration date |
| event_date | string | no | — | Event date |
| event_time | string | no | — | Event time |
| event_location | string | no | — | Event location |
| accent_color | [number, number, number] | no | [41, 98, 255] | RGB color for header/CTA |
Benchmark
Compared against pdf-lib on a realistic GBP post generation (100 iterations):
| Library | Time (ms) | Size (bytes) | |---------|-----------|--------------| | @jackgreen2018/gbp-post-generator | 13.6 | 1474 | | pdf-lib | 140.8 | 577 |
WASM speedup: 10.33x faster
Benchmarks run via node benchmark.mjs. All measurements are real, not estimated.
Build
npm install
npm run build
npm testLicense
MIT
