[{"data":1,"prerenderedAt":141},["Reactive",2],{"/guides/csharp/restsharp/exporting-only-a-specific-set-of-pages":3,"/guides/csharp/restsharp/exporting-only-a-specific-set-of-pages-related":59},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"language":10,"library":11,"property":12,"output":13,"related":14,"default":6,"body":17,"_type":54,"_id":55,"_source":56,"_file":57,"_extension":58},"/guides/csharp/restsharp/exporting-only-a-specific-set-of-pages","restsharp",false,"","Exporting only a specific set of pages","Learn how to export only specific pages from a document when converting to PDF using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to select specific pages for export.","C#","RestSharp","pages","pdf",[15,16],"generate-a-document-with-full-height","save-your-pdf-online-and-get-back-a-url",{"type":18,"children":19,"toc":51},"root",[20,28,33,46],{"type":21,"tag":22,"props":23,"children":24},"element","p",{},[25],{"type":26,"value":27},"text","In this guide, we'll show you how to export only specific pages from a document when converting to PDF using C# and the RestSharp library.",{"type":21,"tag":22,"props":29,"children":30},{},[31],{"type":26,"value":32},"When converting documents, you might want to export only a specific range of pages rather than the entire document.",{"type":21,"tag":34,"props":35,"children":40},"pre",{"className":36,"code":38,"language":39,"meta":7},[37],"language-csharp","using RestSharp;\nusing System.IO;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new RestClient(\"https://api.pdfshift.io/v3/convert/pdf\");\nvar request = new RestRequest(Method.Post);\nrequest.AddHeader(\"X-API-Key\", apiKey);\nrequest.AddHeader(\"Content-Type\", \"application/json\");\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Export only pages 1-3\n    pages = \"1-3\"\n};\n\nrequest.AddJsonBody(payload);\n\nvar response = await client.ExecuteAsync(request);\n\n// Handle errors:\nif (response.StatusCode >= System.Net.HttpStatusCode.BadRequest)\n{\n    throw new Exception($\"Request failed with status code {response.StatusCode}\");\n}\n\nFile.WriteAllBytes(\"result.pdf\", response.RawBytes);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n","csharp",[41],{"type":21,"tag":42,"props":43,"children":44},"code",{"__ignoreMap":7},[45],{"type":26,"value":38},{"type":21,"tag":22,"props":47,"children":48},{},[49],{"type":26,"value":50},"This allows you to selectively export pages from multi-page documents.",{"title":7,"searchDepth":52,"depth":52,"links":53},2,[],"markdown","content:guides:csharp:restsharp:exporting-only-a-specific-set-of-pages.md","content","guides/csharp/restsharp/exporting-only-a-specific-set-of-pages.md","md",[60,64,68,72,76,80,84,88,92,93,97,101,105,109,113,117,121,125,129,133,137],{"_path":61,"title":62,"language":10,"library":11,"_id":63},"/guides/csharp/restsharp/accessing-secured-pages","Accessing secured pages","content:guides:csharp:restsharp:accessing-secured-pages.md",{"_path":65,"title":66,"language":10,"library":11,"_id":67},"/guides/csharp/restsharp/adding-a-custom-header-or-footer","Adding a custom header or footer","content:guides:csharp:restsharp:adding-a-custom-header-or-footer.md",{"_path":69,"title":70,"language":10,"library":11,"_id":71},"/guides/csharp/restsharp/adding-a-text-watermark","Adding a text watermark","content:guides:csharp:restsharp:adding-a-text-watermark.md",{"_path":73,"title":74,"language":10,"library":11,"_id":75},"/guides/csharp/restsharp/adding-an-image-watermark","Adding an image watermark","content:guides:csharp:restsharp:adding-an-image-watermark.md",{"_path":77,"title":78,"language":10,"library":11,"_id":79},"/guides/csharp/restsharp/avoid-conversion-on-error","Avoid conversion on error","content:guides:csharp:restsharp:avoid-conversion-on-error.md",{"_path":81,"title":82,"language":10,"library":11,"_id":83},"/guides/csharp/restsharp/convert-html-to-pdf-from-a-url","Convert HTML to PDF from a URL","content:guides:csharp:restsharp:convert-html-to-pdf-from-a-url.md",{"_path":85,"title":86,"language":10,"library":11,"_id":87},"/guides/csharp/restsharp/convert-html-to-pdf-from-raw-html","Convert HTML to PDF from raw HTML","content:guides:csharp:restsharp:convert-html-to-pdf-from-raw-html.md",{"_path":89,"title":90,"language":10,"library":11,"_id":91},"/guides/csharp/restsharp/define-a-time-limit","Define a time limit","content:guides:csharp:restsharp:define-a-time-limit.md",{"_path":4,"title":8,"language":10,"library":11,"_id":55},{"_path":94,"title":95,"language":10,"library":11,"_id":96},"/guides/csharp/restsharp/generate-a-document-with-full-height","Generate a document with full height","content:guides:csharp:restsharp:generate-a-document-with-full-height.md",{"_path":98,"title":99,"language":10,"library":11,"_id":100},"/guides/csharp/restsharp/loading-css-from-a-string","Loading CSS from a string","content:guides:csharp:restsharp:loading-css-from-a-string.md",{"_path":102,"title":103,"language":10,"library":11,"_id":104},"/guides/csharp/restsharp/loading-css-from-a-url","Loading CSS from a URL","content:guides:csharp:restsharp:loading-css-from-a-url.md",{"_path":106,"title":107,"language":10,"library":11,"_id":108},"/guides/csharp/restsharp/loading-javascript-from-a-string","Loading JavaScript from a string","content:guides:csharp:restsharp:loading-javascript-from-a-string.md",{"_path":110,"title":111,"language":10,"library":11,"_id":112},"/guides/csharp/restsharp/loading-javascript-from-a-url","Loading JavaScript from a URL","content:guides:csharp:restsharp:loading-javascript-from-a-url.md",{"_path":114,"title":115,"language":10,"library":11,"_id":116},"/guides/csharp/restsharp/protecting-the-generated-pdf","Protecting the generated PDF","content:guides:csharp:restsharp:protecting-the-generated-pdf.md",{"_path":118,"title":119,"language":10,"library":11,"_id":120},"/guides/csharp/restsharp/receive-a-webhook-event","Receive a webhook event","content:guides:csharp:restsharp:receive-a-webhook-event.md",{"_path":122,"title":123,"language":10,"library":11,"_id":124},"/guides/csharp/restsharp/save-your-pdf-online-and-get-back-a-url","Save your PDF online and get back a URL","content:guides:csharp:restsharp:save-your-pdf-online-and-get-back-a-url.md",{"_path":126,"title":127,"language":10,"library":11,"_id":128},"/guides/csharp/restsharp/save-your-pdf-to-your-amazon-s3-bucket","Save your PDF to your Amazon S3 bucket","content:guides:csharp:restsharp:save-your-pdf-to-your-amazon-s3-bucket.md",{"_path":130,"title":131,"language":10,"library":11,"_id":132},"/guides/csharp/restsharp/send-custom-http-headers","Send custom HTTP headers","content:guides:csharp:restsharp:send-custom-http-headers.md",{"_path":134,"title":135,"language":10,"library":11,"_id":136},"/guides/csharp/restsharp/using-cookies","Using cookies","content:guides:csharp:restsharp:using-cookies.md",{"_path":138,"title":139,"language":10,"library":11,"_id":140},"/guides/csharp/restsharp/waiting-for-a-custom-element-to-be-ready","Waiting for a custom element to be ready","content:guides:csharp:restsharp:waiting-for-a-custom-element-to-be-ready.md",1780405104209]