<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>nodejs pdf on Document Processing REST APIs | GroupDocs Cloud</title>
    <link>https://blog-qa.groupdocs.cloud/tag/nodejs-pdf/</link>
    <description>Recent content in nodejs pdf on Document Processing REST APIs | GroupDocs Cloud</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 25 Sep 2026 09:41:12 +0000</lastBuildDate><atom:link href="https://blog-qa.groupdocs.cloud/tag/nodejs-pdf/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Split PDF into Multiple PDF in Node.JS</title>
      <link>https://blog-qa.groupdocs.cloud/merger/split-pdf-into-multiple-pdf-in-nodejs/</link>
      <pubDate>Fri, 25 Sep 2026 09:41:12 +0000</pubDate>
      
      <guid>https://blog-qa.groupdocs.cloud/merger/split-pdf-into-multiple-pdf-in-nodejs/</guid>
      <description>Learn to split PDFs in Node.js using GroupDocs.Merger Cloud SDK. Get step-by-step code, cURL examples, and configuration tips for PDF splitting.</description>
      <content:encoded><![CDATA[<p>Developers often need to break down large <a href="https://docs.fileformat.com/pdf">PDF</a> files into smaller, more manageable sections. With the <a href="https://products.groupdocs.cloud/merger/nodejs/">GroupDocs.Merger Cloud SDK for Node.JS</a>, splitting a PDF into multiple parts becomes straightforward, as the cloud service handles the heavy lifting while you concentrate on your application logic. This guide provides a full working example, shows how to perform the same task via cURL, and explains the configuration options that let you fine‑tune the split operation.</p>
<h2 id="split-pdf-into-multiple-pdf-in-nodejs---complete-code-example">Split PDF Into Multiple PDF in Node.JS - Complete Code Example</h2>
<p>This example demonstrates how to split a PDF into multiple PDF files using GroupDocs.Merger Cloud SDK for Node.JS.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">fs</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;fs&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">path</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;path&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;@groupdocs/merger-cloud&#39;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// ---------- Set up API credentials ----------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">client</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">ApiClient</span>();
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">client</span>.<span style="color:#a6e22e">appSid</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;YOUR_APP_SID&#39;</span>;
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">client</span>.<span style="color:#a6e22e">appKey</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;YOUR_APP_KEY&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// ---------- Initialize API instances ----------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">mergerApi</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">MergerApi</span>(<span style="color:#a6e22e">client</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">storageApi</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">StorageApi</span>(<span style="color:#a6e22e">client</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// ---------- Helper to upload a local file to cloud storage ----------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">async</span> <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">uploadFile</span>(<span style="color:#a6e22e">localPath</span>, <span style="color:#a6e22e">cloudPath</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">fileData</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">fs</span>.<span style="color:#a6e22e">readFileSync</span>(<span style="color:#a6e22e">localPath</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">uploadRequest</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">UploadFileRequest</span>({
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">path</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">cloudPath</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">file</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">fileData</span>
</span></span><span style="display:flex;"><span>    });
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">storageApi</span>.<span style="color:#a6e22e">uploadFile</span>(<span style="color:#a6e22e">uploadRequest</span>);
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// ---------- Helper to download a cloud file to local storage ----------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">async</span> <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">downloadFile</span>(<span style="color:#a6e22e">cloudPath</span>, <span style="color:#a6e22e">localPath</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">downloadRequest</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">DownloadFileRequest</span>({ <span style="color:#a6e22e">path</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">cloudPath</span> });
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">response</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">storageApi</span>.<span style="color:#a6e22e">downloadFile</span>(<span style="color:#a6e22e">downloadRequest</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">fs</span>.<span style="color:#a6e22e">writeFileSync</span>(<span style="color:#a6e22e">localPath</span>, <span style="color:#a6e22e">response</span>);
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// ---------- Main execution ----------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>(<span style="color:#66d9ef">async</span> () =&gt; {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">try</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 1. Upload source PDF to cloud storage
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">localInputPdf</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">path</span>.<span style="color:#a6e22e">resolve</span>(<span style="color:#a6e22e">__dirname</span>, <span style="color:#e6db74">&#39;input.pdf&#39;</span>);          <span style="color:#75715e">// local source PDF
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">cloudInputPdf</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;input/input.pdf&#39;</span>;                            <span style="color:#75715e">// cloud path
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">uploadFile</span>(<span style="color:#a6e22e">localInputPdf</span>, <span style="color:#a6e22e">cloudInputPdf</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;Uploaded PDF to cloud storage.&#39;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 2. Configure split options (example: split into two parts: pages 1‑2 and 3‑5)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">splitOptions</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">SplitOptions</span>({
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">pages</span><span style="color:#f92672">:</span> [<span style="color:#e6db74">&#39;1-2&#39;</span>, <span style="color:#e6db74">&#39;3-5&#39;</span>]                                            <span style="color:#75715e">// page ranges to split
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        });
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 3. Build split request
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">splitRequest</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">SplitDocumentRequest</span>({
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">fileInfo</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">FileInfo</span>({ <span style="color:#a6e22e">filePath</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">cloudInputPdf</span> }),
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">options</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">splitOptions</span>
</span></span><span style="display:flex;"><span>        });
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 4. Execute split operation
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">splitResult</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">mergerApi</span>.<span style="color:#a6e22e">splitDocument</span>(<span style="color:#a6e22e">splitRequest</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">`Split operation completed. </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">splitResult</span>.<span style="color:#a6e22e">length</span><span style="color:#e6db74">}</span><span style="color:#e6db74"> parts generated.`</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 5. Download each split part and save locally
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">for</span> (<span style="color:#66d9ef">let</span> <span style="color:#a6e22e">i</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>; <span style="color:#a6e22e">i</span> <span style="color:#f92672">&lt;</span> <span style="color:#a6e22e">splitResult</span>.<span style="color:#a6e22e">length</span>; <span style="color:#a6e22e">i</span><span style="color:#f92672">++</span>) {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">partInfo</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">splitResult</span>[<span style="color:#a6e22e">i</span>];
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">localOutputPath</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">path</span>.<span style="color:#a6e22e">resolve</span>(<span style="color:#a6e22e">__dirname</span>, <span style="color:#e6db74">`output_part_</span><span style="color:#e6db74">${</span><span style="color:#a6e22e">i</span> <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span><span style="color:#e6db74">}</span><span style="color:#e6db74">.pdf`</span>);
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">downloadFile</span>(<span style="color:#a6e22e">partInfo</span>.<span style="color:#a6e22e">path</span>, <span style="color:#a6e22e">localOutputPath</span>);
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">`Saved split part </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">i</span> <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span><span style="color:#e6db74">}</span><span style="color:#e6db74"> to </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">localOutputPath</span><span style="color:#e6db74">}</span><span style="color:#e6db74">`</span>);
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// 6. (Optional) Clean up cloud storage – delete uploaded source file
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">deleteRequest</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">DeleteFileRequest</span>({ <span style="color:#a6e22e">path</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">cloudInputPdf</span> });
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">storageApi</span>.<span style="color:#a6e22e">deleteFile</span>(<span style="color:#a6e22e">deleteRequest</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;Cleaned up source file from cloud storage.&#39;</span>);
</span></span><span style="display:flex;"><span>    } <span style="color:#66d9ef">catch</span> (<span style="color:#a6e22e">error</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">error</span>(<span style="color:#e6db74">&#39;Error during PDF split process:&#39;</span>, <span style="color:#a6e22e">error</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>})();
</span></span></code></pre></div><blockquote>
<p><strong>Note:</strong> This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the <a href="https://docs.groupdocs.cloud/merger/">official documentation</a> or reach out to the <a href="https://forum.groupdocs.cloud/c/merger/18">support team</a> for assistance.</p>
</blockquote>
<h2 id="split-pdf-using-rest-api-with-curl">Split PDF Using REST API with cURL</h2>
<p>If you prefer a pure REST approach, the same split operation can be performed with cURL commands. The steps below show how to obtain an access token, upload the source PDF, run the split, and download each part.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># 1. Get an access token (replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET)</span>
</span></span><span style="display:flex;"><span>curl -X POST <span style="color:#e6db74">&#34;https://api.groupdocs.cloud/v2.0/oauth2/token&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Content-Type: application/x-www-form-urlencoded&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -d <span style="color:#e6db74">&#34;grant_type=client_credentials&amp;client_id=YOUR_CLIENT_ID&amp;client_secret=YOUR_CLIENT_SECRET&#34;</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># 2. Upload the source PDF (replace YOUR_ACCESS_TOKEN and adjust paths)</span>
</span></span><span style="display:flex;"><span>curl -X PUT <span style="color:#e6db74">&#34;https://api.groupdocs.cloud/v2.0/storage/file/input.pdf&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Content-Type: application/pdf&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     --data-binary @./input.pdf
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># 3. Execute the split operation (pages 1-2 and 3-5)</span>
</span></span><span style="display:flex;"><span>curl -X POST <span style="color:#e6db74">&#34;https://api.groupdocs.cloud/v2.0/merger/split&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">           &#34;fileInfo&#34;: { &#34;filePath&#34;: &#34;input.pdf&#34; },
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">           &#34;options&#34;: { &#34;pages&#34;: [&#34;1-2&#34;,&#34;3-5&#34;] }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         }&#39;</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># 4. Download each generated part (example for part 1)</span>
</span></span><span style="display:flex;"><span>curl -X GET <span style="color:#e6db74">&#34;https://api.groupdocs.cloud/v2.0/storage/file/output_part_1.pdf&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -H <span style="color:#e6db74">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -o ./output_part_1.pdf
</span></span></code></pre></div><p>For a complete list of endpoints and parameters, see the <a href="https://reference.groupdocs.cloud/merger/">official API documentation</a>.</p>
<h2 id="how-split-pdf-into-multiple-pdf-in-nodejs-works">How Split PDF Into Multiple PDF in Node.JS Works</h2>
<p>Understanding the flow helps you adapt the code to more complex scenarios.</p>
<ol>
<li>
<p><strong>Initialize the API client</strong> - <code>new GroupDocsMergerCloud.ApiClient()</code> creates a client that holds your App SID and App Key.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">client</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">ApiClient</span>();
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">client</span>.<span style="color:#a6e22e">appSid</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;YOUR_APP_SID&#39;</span>;
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">client</span>.<span style="color:#a6e22e">appKey</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;YOUR_APP_KEY&#39;</span>;
</span></span></code></pre></div></li>
<li>
<p><strong>Upload the source file</strong> - The helper <code>uploadFile</code> reads the local PDF and sends it to cloud storage using <code>storageApi.uploadFile</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">await</span> <span style="color:#a6e22e">uploadFile</span>(<span style="color:#a6e22e">localInputPdf</span>, <span style="color:#a6e22e">cloudInputPdf</span>);
</span></span></code></pre></div></li>
<li>
<p><strong>Configure split options</strong> - <code>new GroupDocsMergerCloud.SplitOptions({ pages: ['1-2', '3-5'] })</code> tells the service which page ranges to extract.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">splitOptions</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">GroupDocsMergerCloud</span>.<span style="color:#a6e22e">SplitOptions</span>({
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">pages</span><span style="color:#f92672">:</span> [<span style="color:#e6db74">&#39;1-2&#39;</span>, <span style="color:#e6db74">&#39;3-5&#39;</span>]
</span></span><span style="display:flex;"><span>});
</span></span></code></pre></div></li>
<li>
<p><strong>Send the split request</strong> - <code>mergerApi.splitDocument(splitRequest)</code> posts the request and returns an array with information about each generated part.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">splitResult</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">mergerApi</span>.<span style="color:#a6e22e">splitDocument</span>(<span style="color:#a6e22e">splitRequest</span>);
</span></span></code></pre></div></li>
<li>
<p><strong>Download the results</strong> - The loop iterates over <code>splitResult</code>, calling <code>downloadFile</code> for each part and saving it locally.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#66d9ef">for</span> (<span style="color:#66d9ef">let</span> <span style="color:#a6e22e">i</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>; <span style="color:#a6e22e">i</span> <span style="color:#f92672">&lt;</span> <span style="color:#a6e22e">splitResult</span>.<span style="color:#a6e22e">length</span>; <span style="color:#a6e22e">i</span><span style="color:#f92672">++</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">partInfo</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">splitResult</span>[<span style="color:#a6e22e">i</span>];
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">downloadFile</span>(<span style="color:#a6e22e">partInfo</span>.<span style="color:#a6e22e">path</span>, <span style="color:#a6e22e">localOutputPath</span>);
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div></li>
</ol>
<p>For deeper details on each class and method, refer to the <a href="https://reference.groupdocs.cloud/merger/">API reference</a>.</p>
<h2 id="prerequisites-and-setup">Prerequisites and Setup</h2>
<p>Before you start, ensure you have the following:</p>
<ul>
<li>Node.js 14 or later installed.</li>
<li>A GroupDocs Cloud account with valid App SID and App Key.</li>
<li>Access to the internet for API calls.</li>
</ul>
<p>Install the SDK via npm and download the latest package:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>npm install groupdocs-merger-cloud
</span></span></code></pre></div><p>You can also fetch the binaries directly from the <a href="https://releases.groupdocs.cloud/merger/nodejs/">download page</a>.</p>
<h2 id="fine-tuning-split-options">Fine-Tuning Split Options</h2>
<p>The <code>SplitOptions</code> object offers several properties you can adjust:</p>
<ul>
<li><strong>pages</strong> - An array of page ranges (e.g., <code>['1-2','3-5']</code>). This is the core setting used in the example.</li>
<li><strong>outputPath</strong> - Optional folder where the split files will be stored in cloud storage.</li>
<li><strong>preserveMetadata</strong> - When set to <code>true</code>, original document metadata is copied to each part. See the <a href="https://reference.groupdocs.cloud/merger/">API reference</a> for more options.</li>
</ul>
<p>Adjusting these values lets you control the size, naming, and metadata of each resulting PDF.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Splitting PDF into multiple PDF in Node.JS becomes straightforward with the <a href="https://products.groupdocs.cloud/merger/nodejs/">GroupDocs.Merger Cloud SDK for Node.JS</a>. The SDK handles file upload, page‑range selection, and result retrieval, letting you focus on integrating the output into your workflow. Remember to secure your App SID and App Key, and consider using a commercial license for production deployments. Pricing details are available on the product page, and you can obtain a temporary license from the <a href="https://purchase.groupdocs.cloud/temporary-license/">temporary license page</a>. With the code, cURL examples, and configuration tips in this guide, you&rsquo;re ready to implement robust PDF splitting in your Node.JS applications.</p>
<h2 id="faqs">FAQs</h2>
<ul>
<li>
<p><strong>How do I split PDF into multiple PDF in Node.JS using custom page ranges?</strong><br>
Use the <code>pages</code> property of <code>SplitOptions</code> to define any range you need, such as <code>['1-3','4-6']</code>. The SDK will generate a separate PDF for each range.</p>
</li>
<li>
<p><strong>Can I split a PDF without storing it permanently in cloud storage?</strong><br>
Yes. After uploading the source file and completing the split, you can delete the original file with <code>storageApi.deleteFile</code> as shown in the example.</p>
</li>
<li>
<p><strong>Do I need a paid license to use the split feature in production?</strong><br>
A commercial license is required for production use. Visit the product page for pricing and obtain a temporary license from the <a href="https://purchase.groupdocs.cloud/temporary-license/">temporary license page</a> for evaluation.</p>
</li>
</ul>
<h2 id="read-more">Read More</h2>
<ul>
<li><a href="https://blog.groupdocs.cloud/merger/split-powerpoint-ppt-or-pptx-into-multiple-files-in-node.js/">Split PowerPoint PPT or PPTX into Multiple Files in Node.js</a></li>
<li><a href="https://blog.groupdocs.cloud/merger/split-pdf-file-into-multiple-pdf-files-using-python/">Split PDF File into Multiple PDF Files using Python</a></li>
<li><a href="https://blog.groupdocs.cloud/merger/java-document-splitting-split-pdf-into-multiple-files-in-java/">Java Document Splitting API - Split PDF into Multiple Files in Java</a></li>
</ul>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
