<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Souvik Dalai</title>
    <description>The latest articles on Forem by Souvik Dalai (@souvikdalai44ops).</description>
    <link>https://forem.com/souvikdalai44ops</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3687185%2Fefa8e28b-23f9-4277-a67f-1ad461f6bbf3.png</url>
      <title>Forem: Souvik Dalai</title>
      <link>https://forem.com/souvikdalai44ops</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/souvikdalai44ops"/>
    <language>en</language>
    <item>
      <title>Client-side PDF tools using JavaScript</title>
      <dc:creator>Souvik Dalai</dc:creator>
      <pubDate>Wed, 31 Dec 2025 08:38:53 +0000</pubDate>
      <link>https://forem.com/souvikdalai44ops/client-side-pdf-tools-using-javascript-2nli</link>
      <guid>https://forem.com/souvikdalai44ops/client-side-pdf-tools-using-javascript-2nli</guid>
      <description>&lt;p&gt;Server-side PDF processing has been the default approach for years. Users upload a document, the server processes it, and the result is sent back. While simple to implement, this model introduces privacy, scalability, and performance concerns.&lt;/p&gt;

&lt;p&gt;Modern browsers are now powerful enough to handle many PDF operations entirely on the client side using JavaScript.&lt;/p&gt;

&lt;p&gt;What is client-side PDF processing?&lt;/p&gt;

&lt;p&gt;Client-side PDF processing means that PDF files are:&lt;/p&gt;

&lt;p&gt;Loaded locally in the browser&lt;/p&gt;

&lt;p&gt;Parsed and modified using JavaScript&lt;/p&gt;

&lt;p&gt;Generated and downloaded without any server interaction&lt;/p&gt;

&lt;p&gt;The file never leaves the user’s device.&lt;/p&gt;

&lt;p&gt;This model is increasingly popular for privacy-focused and lightweight web applications.&lt;/p&gt;

&lt;p&gt;Why developers are moving away from server-based PDF tools&lt;/p&gt;

&lt;p&gt;Server-based tools come with several downsides:&lt;/p&gt;

&lt;p&gt;Handling sensitive user documents&lt;/p&gt;

&lt;p&gt;Increased bandwidth and storage costs&lt;/p&gt;

&lt;p&gt;File cleanup and retention logic&lt;/p&gt;

&lt;p&gt;Legal and compliance complexity&lt;/p&gt;

&lt;p&gt;Client-side tools remove these issues by design.&lt;/p&gt;

&lt;p&gt;Core technologies behind client-side PDF tools&lt;br&gt;
File &amp;amp; Blob APIs&lt;/p&gt;

&lt;p&gt;Browsers allow users to securely select local files using an . JavaScript can then read the file as an ArrayBuffer.&lt;/p&gt;

&lt;p&gt;JavaScript PDF libraries&lt;/p&gt;

&lt;p&gt;Libraries like pdf-lib enable reading, modifying, and creating PDFs directly in JavaScript without external services.&lt;/p&gt;

&lt;p&gt;WebAssembly (WASM)&lt;/p&gt;

&lt;p&gt;Some tools use WASM to achieve near-native performance for heavy PDF operations.&lt;/p&gt;

&lt;p&gt;Example: Splitting a PDF using JavaScript (pdf-lib)&lt;/p&gt;

&lt;p&gt;Below is a simplified example showing how a PDF can be split client-side.&lt;/p&gt;

&lt;p&gt;import { PDFDocument } from "pdf-lib";&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function splitPdf(file, pagesToExtract) {
  const arrayBuffer = await file.arrayBuffer();
  const sourcePdf = await PDFDocument.load(arrayBuffer);
  const newPdf = await PDFDocument.create();

  const pages = await newPdf.copyPages(
    sourcePdf,
    pagesToExtract.map(p =&amp;gt; p - 1)
  );

  pages.forEach(page =&amp;gt; newPdf.addPage(page));

  const pdfBytes = await newPdf.save();
  return new Blob([pdfBytes], { type: "application/pdf" });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;This function:&lt;/p&gt;

&lt;p&gt;Loads a PDF locally&lt;/p&gt;

&lt;p&gt;Extracts selected pages&lt;/p&gt;

&lt;p&gt;Generates a new downloadable PDF&lt;/p&gt;

&lt;p&gt;No uploads. No backend.&lt;/p&gt;

&lt;p&gt;Advantages of client-side PDF tools&lt;br&gt;
Privacy-first architecture&lt;/p&gt;

&lt;p&gt;User documents never leave their device, making this ideal for financial, legal, and personal files.&lt;/p&gt;

&lt;p&gt;Lower infrastructure cost&lt;/p&gt;

&lt;p&gt;No servers, no storage, no scaling problems.&lt;/p&gt;

&lt;p&gt;Faster UX&lt;/p&gt;

&lt;p&gt;Large PDFs often process faster locally than uploading and downloading them.&lt;/p&gt;

&lt;p&gt;Offline-friendly&lt;/p&gt;

&lt;p&gt;Once loaded, many tools continue to work without an active internet connection.&lt;/p&gt;

&lt;p&gt;Common real-world use cases&lt;/p&gt;

&lt;p&gt;Client-side PDF processing works well for:&lt;/p&gt;

&lt;p&gt;Splitting PDFs by page range&lt;/p&gt;

&lt;p&gt;Extracting specific pages&lt;/p&gt;

&lt;p&gt;Merging multiple PDFs&lt;/p&gt;

&lt;p&gt;Reordering or removing pages&lt;/p&gt;

&lt;p&gt;Quick document preparation workflows&lt;/p&gt;

&lt;p&gt;Reference implementation&lt;/p&gt;

&lt;p&gt;A real-world example of a fully client-side PDF tool (no uploads involved) can be seen here as a reference implementation:&lt;br&gt;
&lt;a href="https://free-pdf-tools-e7x.pages.dev/split.html" rel="noopener noreferrer"&gt;https://free-pdf-tools-e7x.pages.dev/split.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It demonstrates how modern browsers can handle PDF manipulation using only frontend technologies.&lt;/p&gt;

&lt;p&gt;Things to keep in mind as a developer&lt;/p&gt;

&lt;p&gt;Large PDFs can consume significant memory&lt;/p&gt;

&lt;p&gt;Always provide loading/progress feedback&lt;/p&gt;

&lt;p&gt;Clearly communicate privacy guarantees&lt;/p&gt;

&lt;p&gt;Test across Chrome, Firefox, and Edge&lt;/p&gt;

&lt;p&gt;Consider graceful fallbacks for older browsers&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Client-side PDF tools using JavaScript are no longer experimental. With modern browser APIs, WebAssembly, and mature libraries, many PDF operations can be done securely and efficiently without a backend.&lt;/p&gt;

&lt;p&gt;For developers, this means simpler architectures, lower costs, and better privacy guarantees — a strong combination for modern web apps.&lt;em&gt;****&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>privacy</category>
      <category>pdf</category>
    </item>
  </channel>
</rss>
