<?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>pdf splitting on Document Processing REST APIs | GroupDocs Cloud</title>
    <link>https://blog-qa.groupdocs.cloud/fr/tag/pdf-splitting/</link>
    <description>Recent content in pdf splitting on Document Processing REST APIs | GroupDocs Cloud</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>fr</language>
    <lastBuildDate>Fri, 25 Sep 2026 09:41:12 +0000</lastBuildDate><atom:link href="https://blog-qa.groupdocs.cloud/fr/tag/pdf-splitting/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Diviser le PDF en plusieurs PDF dans Node.JS</title>
      <link>https://blog-qa.groupdocs.cloud/fr/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/fr/merger/split-pdf-into-multiple-pdf-in-nodejs/</guid>
      <description>Apprenez à diviser des PDF dans Node.js en utilisant GroupDocs.Merger Cloud SDK. Obtenez du code étape par étape, des exemples cURL et des conseils de configuration pour la division de PDF.</description>
      <content:encoded><![CDATA[<p>Les développeurs ont souvent besoin de découper de gros fichiers <a href="https://docs.fileformat.com/pdf">PDF</a> en sections plus petites et plus faciles à gérer. Avec le <a href="https://products.groupdocs.cloud/merger/nodejs/">GroupDocs.Merger Cloud SDK for Node.JS</a>, diviser un PDF en plusieurs parties devient simple, car le service cloud se charge du travail lourd pendant que vous vous concentrez sur la logique de votre application. Ce guide fournit un exemple complet fonctionnel, montre comment effectuer la même tâche via cURL, et explique les options de configuration qui vous permettent d’ajuster finement l’opération de division.</p>
<h2 id="diviser-un-pdf-en-plusieurs-pdf-dans-nodejs---exemple-de-code-complet">Diviser un PDF en plusieurs PDF dans Node.JS - Exemple de code complet</h2>
<p>Cet exemple montre comment diviser un PDF en plusieurs fichiers PDF en utilisant 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>Remarque:</strong> Cet exemple de code démontre la fonctionnalité principale. Avant de l&rsquo;utiliser dans votre projet, assurez-vous de mettre à jour tous les chemins de fichiers et les valeurs de configuration pour qu&rsquo;ils correspondent à votre environnement réel, vérifiez que toutes les dépendances requises sont correctement installées et testez soigneusement dans votre environnement de développement. Si vous rencontrez des problèmes, veuillez consulter la <a href="https://docs.groupdocs.cloud/merger/">documentation officielle</a> ou contacter l&rsquo;<a href="https://forum.groupdocs.cloud/c/merger/18">équipe d&rsquo;assistance</a> pour obtenir de l&rsquo;aide.</p>
</blockquote>
<h2 id="fractionner-un-pdf-avec-lapi-rest-et-curl">Fractionner un PDF avec l&rsquo;API REST et cURL</h2>
<p>Si vous préférez une approche purement REST, la même opération de fractionnement peut être effectuée avec des commandes cURL. Les étapes ci‑dessous montrent comment obtenir un jeton d’accès, télécharger le PDF source, exécuter le fractionnement et télécharger chaque partie.</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>Pour une liste complète des points de terminaison et des paramètres, consultez la <a href="https://reference.groupdocs.cloud/merger/">documentation officielle de l&rsquo;API</a>.</p>
<h2 id="comment-le-fractionnement-de-pdf-en-plusieurs-pdf-fonctionne-en-nodejs">Comment le fractionnement de PDF en plusieurs PDF fonctionne en Node.JS</h2>
<p>Comprendre le flux vous aide à adapter le code à des scénarios plus complexes.</p>
<ol>
<li><strong>Initialiser le client API</strong> - <code>new GroupDocsMergerCloud.ApiClient()</code> crée un client qui contient votre SID d&rsquo;application et votre clé d&rsquo;application.</li>
</ol>
<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><ol start="2">
<li>
<p><strong>Téléverser le fichier source</strong> - L’assistant <code>uploadFile</code> lit le PDF local et l’envoie au stockage cloud en utilisant <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>Configurer les options de division</strong> - <code>new GroupDocsMergerCloud.SplitOptions({ pages: ['1-2', '3-5'] })</code> indique au service quelles plages de pages extraire.</p>
</li>
</ol>
<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><ol start="4">
<li><strong>Envoyer la requête de division</strong> - <code>mergerApi.splitDocument(splitRequest)</code> envoie la requête et renvoie un tableau contenant les informations sur chaque partie générée.</li>
</ol>
<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><ol start="5">
<li><strong>Télécharger les résultats</strong> - La boucle parcourt <code>splitResult</code>, appelant <code>downloadFile</code> pour chaque partie et l&rsquo;enregistre localement.</li>
</ol>
<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><p>Pour plus de détails sur chaque classe et méthode, consultez la <a href="https://reference.groupdocs.cloud/merger/">référence API</a>.</p>
<h2 id="prérequis-et-configuration">Prérequis et configuration</h2>
<p>Avant de commencer, assurez‑vous d&rsquo;avoir ce qui suit :</p>
<ul>
<li>Node.js 14 ou version ultérieure installé.</li>
<li>Un compte GroupDocs Cloud avec SID d&rsquo;application et clé d&rsquo;application valides.</li>
<li>Accès à Internet pour les appels d&rsquo;API.</li>
</ul>
<p>Installez le SDK via npm et téléchargez le dernier 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>Vous pouvez également récupérer les binaires directement depuis la <a href="https://releases.groupdocs.cloud/merger/nodejs/">page de téléchargement</a>.</p>
<h2 id="options-de-réglage-fin-du-fractionnement">Options de réglage fin du fractionnement</h2>
<p>L&rsquo;objet <code>SplitOptions</code> propose plusieurs propriétés que vous pouvez ajuster :</p>
<ul>
<li><strong>pages</strong> - Un tableau de plages de pages (par ex., <code>['1-2','3-5']</code>). C’est le paramètre principal utilisé dans l’exemple.</li>
<li><strong>outputPath</strong> - Dossier optionnel où les fichiers découpés seront stockés dans le stockage cloud.</li>
<li><strong>preserveMetadata</strong> - Lorsqu’il est défini sur <code>true</code>, les métadonnées du document original sont copiées dans chaque partie. Voir la <a href="https://reference.groupdocs.cloud/merger/">référence API</a> pour plus d’options.</li>
</ul>
<p>Ajuster ces valeurs vous permet de contrôler la taille, le nom et les métadonnées de chaque PDF résultant.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Diviser un PDF en plusieurs PDF dans Node.JS devient simple avec le <a href="https://products.groupdocs.cloud/merger/nodejs/">GroupDocs.Merger Cloud SDK for Node.JS</a>. Le SDK gère le téléchargement du fichier, la sélection de la plage de pages et la récupération du résultat, vous permettant de vous concentrer sur l&rsquo;intégration de la sortie dans votre flux de travail. N&rsquo;oubliez pas de sécuriser votre App SID et votre App Key, et envisagez d&rsquo;utiliser une licence commerciale pour les déploiements en production. Les détails de tarification sont disponibles sur la page du produit, et vous pouvez obtenir une licence temporaire depuis la <a href="https://purchase.groupdocs.cloud/temporary-license/">page de licence temporaire</a>. Avec le code, les exemples cURL et les conseils de configuration présentés dans ce guide, vous êtes prêt à implémenter une division robuste de PDF dans vos applications Node.JS.</p>
<h2 id="faqs">FAQs</h2>
<ul>
<li>
<p><strong>Comment diviser un PDF en plusieurs PDF dans Node.JS en utilisant des plages de pages personnalisées ?</strong><br>
Utilisez la propriété <code>pages</code> de <code>SplitOptions</code> pour définir la plage dont vous avez besoin, par exemple <code>['1-3','4-6']</code>. Le SDK générera un PDF distinct pour chaque plage.</p>
</li>
<li>
<p><strong>Puis-je diviser un PDF sans le stocker de façon permanente dans le stockage cloud ?</strong><br>
Oui. Après avoir téléchargé le fichier source et terminé la division, vous pouvez supprimer le fichier original avec <code>storageApi.deleteFile</code> comme indiqué dans l&rsquo;exemple.</p>
</li>
<li>
<p><strong>Ai‑je besoin d’une licence payante pour utiliser la fonction de fractionnement en production ?</strong><br>
Une licence commerciale est requise pour une utilisation en production. Consultez la page du produit pour les tarifs et obtenez une licence temporaire depuis la <a href="https://purchase.groupdocs.cloud/temporary-license/">page de licence temporaire</a> pour l’évaluation.</p>
</li>
</ul>
<h2 id="en-savoir-plus">En savoir plus</h2>
<ul>
<li><a href="https://blog.groupdocs.cloud/fr/merger/split-powerpoint-ppt-or-pptx-into-multiple-files-in-node.js/">Diviser un PowerPoint PPT ou PPTX en plusieurs fichiers avec Node.js</a></li>
<li><a href="https://blog.groupdocs.cloud/fr/merger/split-pdf-file-into-multiple-pdf-files-using-python/">Diviser un fichier PDF en plusieurs fichiers PDF en utilisant Python</a></li>
<li><a href="https://blog.groupdocs.cloud/fr/merger/java-document-splitting-split-pdf-into-multiple-files-in-java/">API de fractionnement de documents Java - Diviser un PDF en plusieurs fichiers en Java</a></li>
</ul>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
