তুলনা

gPdf বনাম jsPDF: browser PDF generation নাকি edge API

jsPDF দ্রুত in-browser PDF-এর জন্য জনপ্রিয়। কিন্তু CJK font, barcode accuracy, mobile memory ও compliance দরকার হলে architecture বদলে যায়।

সংক্ষেপ

হালকা browser-generated PDF, prototype, receipt এবং offline export-এর জন্য jsPDF বাস্তবসম্মত পছন্দ। Trade-off দেখা যায় যখন production document-এ CJK text, scan-ready barcode, mobile stability বা compliance output দরকার হয়। gPdf font, barcode, layout এবং PDF generation কাজ controlled edge API-তে সরিয়ে দেয়; browser শুধু data পাঠায় এবং finished PDF পায়।

পাশাপাশি

মাপদণ্ড gPdf jsPDF এগিয়ে
Rendering কোথায় চলে
jsPDF মূল্যবান কারণ এটি client-side চলে; একই বৈশিষ্ট্য CPU ও memory pressure প্রতিটি user device-এ সরিয়ে দেয়।
Cloudflare Workers V8 isolates at the edge User-এর browser tab gPdf
CJK font handling
jsPDF-এর standard PDF fonts UTF-8/CJK text cover করে না; team-কে suitable TTF data load বা package করতে হয়।
Simplified Chinese, Japanese ও Korean-এর জন্য bundled fallback প্রয়োজনীয় glyph থাকা custom font দরকার gPdf
CJK-এর জন্য frontend payload Web app bundle-এ CJK font asset নেই প্রায়ই multi-megabyte font file বা generated base64 font module gPdf
Barcode generation model 1D ও 2D format-এর জন্য native `barcode` element সাধারণত separate barcode library, SVG/canvas বা image pipeline লাগে gPdf
Barcode print accuracy
Shipping label, warehouse label ও ticket-এ scanner screen appearance নয়, printed geometry, quiet zone ও module size দেখে।
PDF-এর ভিতরে vector bar ও module Browser barcode কীভাবে PDF-এ convert ও scale হয় তার ওপর নির্ভর gPdf
Mobile browser stability Rendering work tab থেকে offload হয় PDF generation, font, image ও barcode সব client memory খায় gPdf
Offline support API-তে network access দরকার PWA বা local-only app-এ পুরোপুরি offline চলতে পারে jsPDF
PDF/A ও e-invoicing PDF/A profiles এবং Factur-X/ZUGFeRD endpoint Archival বা hybrid e-invoice package-এর জন্য সাধারণ fit নয় gPdf
List price Basic plan মাসে ৫ USD-তে ১ লাখ পৃষ্ঠা দেয়; overage প্রতি পৃষ্ঠা ০.০০০০৫ USD থেকে শুরু Open-source library; library নিজে vendor bill তৈরি করে না jsPDF
Production ownership cost API font, barcode rendering, output environment ও upgrade own করে আপনার web app font packaging, barcode conversion, mobile memory ও browser QA own করে gPdf
Best default use case Structured production document: label, invoice, receipt, ticket, statement Small browser export, prototype, offline document এবং simple Latin-text PDF সমান

কখন কোনটা বাছবেন

gPdf বাছুন যখন
  • Document-এ Chinese, Japanese বা Korean text আছে এবং আপনি প্রতিটি browser-এ বড় font asset পাঠাতে চান না।
  • আপনি Code 128, GS1-128, QR, DataMatrix, PDF417 বা অন্য barcode সহ scan-critical label বা ticket generate করেন।
  • User প্রায়ই mobile browser-এ থাকে এবং PDF generation যেন page memory-এর সঙ্গে compete না করে।
  • আপনার PDF/A, Factur-X, ZUGFeRD বা audit-sensitive output-এর জন্য এক controlled renderer দরকার।
  • একই PDF কাজের ধারা frontend, backend, job ও integration থেকে callable হতে হবে।
jsPDF বাছুন যখন
  • Server call ছাড়া fully offline browser বা PWA export দরকার।
  • PDF ছোট, Latin-only, এবং মাঝে মাঝে এক user generate করে।
  • Prototype করছেন এবং JavaScript-এ text, line ও image দ্রুত draw করতে চান।
  • Data user-এর device ছেড়ে যেতে পারবে না, short-lived render request-ও নয়।
  • Font packaging, barcode encoding, scaling ও browser memory edge case নিজে own করতে রাজি।
সক্ষমতা

gPdf হলো high-volume ইনভয়েস PDF, ডকুমেন্ট, শিপিং লেবেল, বারকোড, PDF/A এবং e-invoice workflow-এর জন্য তৈরি edge-native JSON-to-PDF API। Global edge scale-এ মিলিসেকেন্ড-শ্রেণীর PDF rendering — predictable, industrial-grade document generation-এর জন্য অপ্টিমাইজড। Infrastructure-level pricing, এমন কম খরচে যাতে নিজস্ব PDF infrastructure তৈরি ও চালানোর বিকল্প হিসেবে ভাবা যায়।

সক্ষমতা

Lightweight browser export-এ jsPDF চমৎকার

jsPDF জনপ্রিয় কারণ এটি বাস্তব product problem সমাধান করে: backend service ছাড়া browser-এর ভেতর PDF তৈরি করা। Developer text, line, image ও simple table draw করে একই page থেকে download trigger করতে পারে। Prototype, ছোট admin screen, local receipt এবং offline PWA-এর জন্য এটি শক্তিশালী fit।

প্রশ্ন হলো browser boundary কোথায় ভুল boundary হয়ে যায়। PDF যদি customer scan করবে, archive করবে, email করবে বা অন্য system-এ submit করবে এমন business document হয়, কাজ তখন শুধু “file draw” নয়। তখন font management, barcode accuracy, mobile stability, deterministic output এবং কখনো PDF/A বা e-invoice packaging দরকার হয়।

Same PDF output, কিন্তু পণ্যসীমা আলাদা

jsPDF-তে frontend application-ই renderer। প্রতিটি browser tab-কে library, custom font, intermediate image, barcode output এবং final PDF bytes ধরে রাখতে হয়। Library bill zero থাকে, কিন্তু production responsibility প্রতিটি user device-এ চলে যায়।

gPdf-তে browser বা backend structured DocumentRequest অথবা template_id + data পাঠায়। Render environment, bundled font, barcode geometry এবং binary PDF generation edge-এ gPdf own করে। Application data ও template logic own করে, PDF engine নয়।

কোন কাজে মানায়: offline export বনাম operational document

PDF যদি local convenience feature হয়, jsPDF বেছে নিন: ছোট export button, simple Latin-only receipt, dashboard snapshot, অথবা network ছাড়াও চলতে হবে এমন PWA।

PDF যদি operational কাজের ধারার অংশ হয়, gPdf বেছে নিন: shipping label, warehouse tag, invoice, ticket, statement, customs form এবং cross-border receipt। এসব document-এ deviceভেদে best-effort output নয়, একই output দরকার।

খরচের মডেল: free library বনাম production surface নিজে সামলানো

jsPDF-এর obvious price advantage আছে: library open source, এবং browser CPU cloud bill-এ line item নয়। ছোট internal feature-এর জন্য এটি সস্তা পথ হতে পারে।

Production cost library-এর চারপাশে আসে:

  • CJK-capable font file বা generated base64 font module.
  • Barcode encoding ও conversion library.
  • Browser-specific memory ও download bug.
  • Scanner ও thermal printer-এর জন্য print QA.
  • Desktop, iOS Safari, Android WebView ও embedded browser-এ regression test.

gPdf এটিকে usage bill-এ রূপ দেয়। Public Basic plan মাসে ৫ USD-তে ১ লাখ পৃষ্ঠা দেয়, standard overage প্রতি পৃষ্ঠা ০.০০০০৫ USD থেকে শুরু। এটি vendor cost, কিন্তু প্রতিটি frontend bundle ও user device-কে production PDF service বানানোর দরকার সরিয়ে দেয়।

CJK cost শুধু file size নয়

প্রথম hard edge হলো CJK text: Chinese, Japanese ও Korean।

jsPDF-এর built-in standard PDF font simple Latin output-এর জন্য কাজের, কিন্তু সব Unicode glyph cover করে না। CJK text থাকলে application-কে এমন font দিতে হয় যাতে glyph আছে। বাস্তবে browser-side implementation প্রায়ই TTF package করে, base64 JavaScript module বানায়, বা PDF তৈরি করার আগে font data fetch করে।

এই cost দুবার দেওয়া হয়: প্রথমে larger frontend payload, তারপর PDF generation-এর সময় browser memory। Mobile-এ একই tab web app, font, barcode buffer, image এবং final PDF bytes একসঙ্গে ধরে রাখতে পারে।

gPdf কাজটি server-side রাখে। Browser structured JSON পাঠায়; renderer bundled font দিয়ে Latin, Greek, Cyrillic, CJK, Arabic, Devanagari, Bengali, Thai ও monospace text handle করে। 2 KB order payload-কে 12 MB font delivery path বানাতে হয় না।

Barcode cost: encoding সহজ, print reliability কঠিন

Logistics, ecommerce, manufacturing, healthcare, ticketing ও retail কাজের ধারায় barcode visible copy থেকেও বেশি গুরুত্বপূর্ণ হতে পারে। মানুষ order number পড়ে; operation পড়ে Code 128, GS1-128, QR, DataMatrix বা PDF417।

jsPDF-এর সঙ্গে barcode generation সাধারণত আলাদা product decision। Team jsPDF-এর সঙ্গে encoder মিলিয়ে barcode-কে SVG, canvas বা image বানায়, তারপর PDF-এ বসায়। Coupon QR code বা proof of concept-এ এটি চলে।

Operationally critical printed barcode হলে fragility আসে:

  • Canvas barcode ভুল resolution-এ rasterize হতে পারে।
  • Scaled image bars, modules বা quiet zones blur করতে পারে।
  • Browser, CSS transform বা export path final physical size বদলাতে পারে।
  • আলাদা barcode format-এর জন্য আলাদা library বা conversion path দরকার হতে পারে।
  • 203 DPI thermal printer ছোট sizing mistake দ্রুত দেখায়।

gPdf barcode-কে document element হিসেবে দেখে। Request-এ type: "barcode", format, payload এবং millimetres-এ physical size থাকে। Renderer supported 1D ও 2D format-এর জন্য PDF-এর ভিতরে vector barcode geometry emit করে, তাই text, shape, table, image ও barcode একই coordinate system-এ থাকে।

Studio ও template iteration

jsPDF code-first। Layout change মানে JavaScript drawing command, position, font registration, image conversion ও barcode placement বদলানো।

gPdf একই API-first কাজের ধারা রাখে, কিন্তু gPdf Studio free visual PDF designer হিসেবে যোগ করে। Team text, image, table, shape, header, footer ও barcode add/drag করতে পারে, তারপর design-কে template_id + data generation-এর সঙ্গে যুক্ত করতে পারে। Label, invoice বা receipt format ঘন ঘন বদলালে এবং PDF specialist নয় এমন মানুষকেও layout-এ অংশ নিতে হলে এটি গুরুত্বপূর্ণ।

Mobile browser heavy PDF work-এর জন্য ভুল জায়গা

Client-side PDF generation cheap মনে হয় কারণ server bill zero। Cost user device-এ যায়।

Desktop-এ এটি ঠিক থাকতে পারে। Mobile browser-এ production document tab-কে চাপ দিতে পারে: CJK font data, base64 image, canvas buffer, barcode image, generated PDF bytes এবং running application একসঙ্গে memory চায়। iOS Safari ও low-memory Android device developer laptop-এর মতো forgiving নয়।

gPdf-তে generation সরালে problem shape বদলে যায়। Browser ছোট JSON request বানায়, binary response অপেক্ষা করে এবং finished PDF download করে। User tab আর font manager, barcode renderer, layout engine ও binary PDF writer নয়।

কখন jsPDF এখনো সঠিক পছন্দ

jsPDF রাখার ভালো কারণ আছে।

User-কে offline export করতেই হলে jsPDF ভালো fit। Data device ছাড়তে না পারলে browser-side generation পরিষ্কার privacy boundary। Document ছোট, Latin-only ও occasional হলে API introduce করার operational cost worth নাও হতে পারে। Prototype ও internal tool-এ jsPDF প্রায়ই দ্রুততম পথ।

Decision বদলায় যখন output operational কাজের ধারার অংশ: scan হওয়া shipping label, archive হওয়া invoice, verify হওয়া ticket, বা CJK name ঠিকমতো render করতে হবে এমন cross-border order document। তখন “browser-এ PDF বানানো” নয়, “same production PDF reliably বানানো” বেশি গুরুত্বপূর্ণ।

মাইগ্রেশনের রূপ

Migration শুধু একটি function call বদলানো নয়। এটি imperative browser drawing থেকে structured document request-এ যাওয়া।

- // Before: browser-side drawing with jsPDF plus extra font/barcode setup.
- import { jsPDF } from "jspdf";
- import JsBarcode from "jsbarcode";
-
- const doc = new jsPDF({ unit: "mm", format: [100, 150] });
-
- // Load a CJK-capable TTF and register it before drawing CJK text.
- doc.addFileToVFS("NotoSansCJK-Regular.ttf", base64Font);
- doc.addFont("NotoSansCJK-Regular.ttf", "NotoSansCJK", "normal");
- doc.setFont("NotoSansCJK");
- doc.text("跨境订单 / Cross-border order", 6, 10);
-
- // Generate a barcode separately, then place it into the PDF.
- JsBarcode(canvas, "PDN0003507278", { format: "CODE128" });
- doc.addImage(canvas.toDataURL("image/png"), "PNG", 6, 72, 72, 20);
- doc.save("label.pdf");
+
+ // After: send one structured DocumentRequest to gPdf.
+ const res = await fetch("https://api.gpdf.com/api/v1/pdf/render", {
+   method: "POST",
+   headers: {
+     Authorization: `Bearer ${KEY}`,
+     "Content-Type": "application/json"
+   },
+   body: JSON.stringify({
+     settings: {
+       defaults: {
+         text: {
+           font_family: "NotoSans-Regular",
+           font_mode: "prefer",
+           font_size: 9,
+           color: "#111827"
+         }
+       }
+     },
+     pages: [{
+       width: 100,
+       height: 150,
+       elements: [
+         {
+           type: "text",
+           x: 6,
+           y: 8,
+           content: "跨境订单 / Cross-border order",
+           style: { width: 88, font_size: 12, font_weight: "bold" }
+         },
+         {
+           type: "barcode",
+           x: 6,
+           y: 70,
+           width: 72,
+           height: 18,
+           format: "code128",
+           content: "PDN0003507278",
+           barcode_text: { enabled: true, position: "bottom", offset: 1 }
+         },
+         {
+           type: "barcode",
+           x: 80,
+           y: 8,
+           width: 14,
+           height: 14,
+           format: "qrcode",
+           content: "https://track.example/PDN0003507278",
+           barcode_text: { enabled: false, position: "bottom" }
+         }
+       ]
+     }]
+   })
+ });
+ const pdf = await res.arrayBuffer();

মূল shift হলো ownership। jsPDF-তে web app CJK font path, barcode generation path, browser memory profile ও export behaviour own করে। gPdf-তে application data ও template own করে; edge renderer document mechanics own করে।

সম্পর্কিত PDF তৈরির ব্যবহারক্ষেত্র

jsPDF ও gPdf তুলনা করলে প্রথমে boundary ঠিক করুন: browser-এর ভিতরে offline export দরকার, নাকি production document service দরকার? CJK font, barcode ও mobile memory সমস্যা বড় হলে JSON to PDF API দেখুন। Operational workload হলে invoice PDF, shipping labelGS1 barcode API আলাদা করে তুলনা করুন। Archive বা e-invoice দরকার হলে PDF/A APIFactur-X API jsPDF-এর browser boundary থেকে আলাদা সিদ্ধান্তে নিয়ে যায়।

FAQ

jsPDF কি free?

Library open source। Production cost হলো surrounding work: CJK font, barcode library, browser QA, print QA এবং memory শেষ হয়ে যাওয়া device support।

gPdf কি সব jsPDF use case replace করে?

না। Offline browser export ও local-only document এখনো jsPDF-এর natural territory। gPdf production document-এর জন্য, যেখানে controlled renderer API call-এর মূল্য আছে।

Barcode cost আলাদা করে বলা কেন?

কারণ barcode screen-এ ঠিক দেখালেও scaling, rasterization বা thermal printing-এর পর fail করতে পারে। Operational document-এ visible pattern নয়, scanner reliability দরকার।

আরও পড়ুন