[{"data":1,"prerenderedAt":2164},["Reactive",2],{"/guides/csharp/httpwebrequest":3},[4,68,106,144,180,218,255,291,328,366,403,440,475,513,549,585,621,659,695,732,768,804,844,876,908,940,972,1004,1036,1068,1100,1132,1164,1196,1228,1260,1292,1324,1356,1388,1420,1452,1484,1524,1556,1588,1620,1652,1684,1716,1748,1780,1812,1844,1876,1908,1940,1972,2004,2036,2068,2100,2132],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"language":11,"library":12,"property":13,"output":14,"related":15,"default":18,"body":19,"_type":63,"_id":64,"_source":65,"_file":66,"_extension":67},"/guides/csharp/httpclient/accessing-secured-pages","httpclient",false,"","Accessing secured pages","Learn how to access secured pages using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, highlighting how you can access page protected by basic authentication to convert them to PDF using PDFShift's API.","C#","HttpClient","auth","pdf",[16,17],"send-custom-http-headers","using-cookies",true,{"type":20,"children":21,"toc":60},"root",[22,30,43,55],{"type":23,"tag":24,"props":25,"children":26},"element","p",{},[27],{"type":28,"value":29},"text","In this guide, we'll show you how to access secured page (protected by basic authentication) using C# and the HttpClient library to convert them to PDF using PDFShift's API.",{"type":23,"tag":24,"props":31,"children":32},{},[33,35,41],{"type":28,"value":34},"When you're converting a document, you might want to access a secured page (protected by basic authentication) to convert it to PDF. This can be done by setting the ",{"type":23,"tag":36,"props":37,"children":39},"code",{"className":38},[],[40],{"type":28,"value":13},{"type":28,"value":42}," parameter to the request.",{"type":23,"tag":44,"props":45,"children":50},"pre",{"className":46,"code":48,"language":49,"meta":8},[47],"language-csharp","using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // You can set a basic authentication by passing the \"auth\" property which contains a username and password\n    auth = new\n    {\n        username = \"user\",\n        password = \"password\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n","csharp",[51],{"type":23,"tag":36,"props":52,"children":53},{"__ignoreMap":8},[54],{"type":28,"value":48},{"type":23,"tag":24,"props":56,"children":57},{},[58],{"type":28,"value":59},"This allows you to protect your documents from any visitors while allowing PDFShift to access the page and convert it to PDF.",{"title":8,"searchDepth":61,"depth":61,"links":62},2,[],"markdown","content:guides:csharp:httpclient:accessing-secured-pages.md","content","guides/csharp/httpclient/accessing-secured-pages.md","md",{"_path":69,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":70,"description":71,"language":11,"library":12,"property":72,"output":14,"related":73,"default":7,"body":76,"_type":63,"_id":104,"_source":65,"_file":105,"_extension":67},"/guides/csharp/httpclient/adding-a-custom-header-or-footer","Adding a custom header or footer","Learn how to add custom headers and footers to your PDFs using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to customize PDF appearance with headers and footers.","header",[74,75],"loading-css-from-a-string","loading-css-from-a-url",{"type":20,"children":77,"toc":102},[78,83,88,97],{"type":23,"tag":24,"props":79,"children":80},{},[81],{"type":28,"value":82},"In this guide, we'll show you how to add custom headers and footers to your PDFs using C# and the HttpClient library.",{"type":23,"tag":24,"props":84,"children":85},{},[86],{"type":28,"value":87},"When generating PDFs, you might want to add custom headers and footers to your documents for branding or informational purposes.",{"type":23,"tag":44,"props":89,"children":92},{"className":90,"code":91,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add custom header and footer\n    header = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Header Content\u003C/div>\",\n        height = \"20mm\"\n    },\n    footer = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Footer Content\u003C/div>\",\n        height = \"20mm\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[93],{"type":23,"tag":36,"props":94,"children":95},{"__ignoreMap":8},[96],{"type":28,"value":91},{"type":23,"tag":24,"props":98,"children":99},{},[100],{"type":28,"value":101},"This allows you to add consistent branding elements to all your generated PDF documents.",{"title":8,"searchDepth":61,"depth":61,"links":103},[],"content:guides:csharp:httpclient:adding-a-custom-header-or-footer.md","guides/csharp/httpclient/adding-a-custom-header-or-footer.md",{"_path":107,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":108,"description":109,"language":11,"library":12,"property":110,"output":14,"related":111,"default":7,"body":114,"_type":63,"_id":142,"_source":65,"_file":143,"_extension":67},"/guides/csharp/httpclient/adding-a-text-watermark","Adding a text watermark","Learn how to add text watermarks to your PDFs using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to apply text watermarks to protect your documents.","watermark",[112,113],"adding-an-image-watermark","protecting-the-generated-pdf",{"type":20,"children":115,"toc":140},[116,121,126,135],{"type":23,"tag":24,"props":117,"children":118},{},[119],{"type":28,"value":120},"In this guide, we'll show you how to add text watermarks to your PDFs using C# and the HttpClient library.",{"type":23,"tag":24,"props":122,"children":123},{},[124],{"type":28,"value":125},"When generating PDFs, you might want to add text watermarks to your documents for protection or branding purposes.",{"type":23,"tag":44,"props":127,"children":130},{"className":128,"code":129,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add text watermark\n    watermark = new\n    {\n        text = \"CONFIDENTIAL\",\n        opacity = 0.3,\n        size = \"20px\",\n        color = \"#000000\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[131],{"type":23,"tag":36,"props":132,"children":133},{"__ignoreMap":8},[134],{"type":28,"value":129},{"type":23,"tag":24,"props":136,"children":137},{},[138],{"type":28,"value":139},"This allows you to add textual protection to your documents with customizable text.",{"title":8,"searchDepth":61,"depth":61,"links":141},[],"content:guides:csharp:httpclient:adding-a-text-watermark.md","guides/csharp/httpclient/adding-a-text-watermark.md",{"_path":145,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":146,"description":147,"language":11,"library":12,"property":110,"output":14,"related":148,"default":7,"body":150,"_type":63,"_id":178,"_source":65,"_file":179,"_extension":67},"/guides/csharp/httpclient/adding-an-image-watermark","Adding an image watermark","Learn how to add image watermarks to your PDFs using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to apply image watermarks to protect your documents.",[149,113],"adding-a-text-watermark",{"type":20,"children":151,"toc":176},[152,157,162,171],{"type":23,"tag":24,"props":153,"children":154},{},[155],{"type":28,"value":156},"In this guide, we'll show you how to add image watermarks to your PDFs using C# and the HttpClient library.",{"type":23,"tag":24,"props":158,"children":159},{},[160],{"type":28,"value":161},"When generating PDFs, you might want to add image watermarks to your documents for protection or branding purposes.",{"type":23,"tag":44,"props":163,"children":166},{"className":164,"code":165,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add image watermark\n    watermark = new\n    {\n        image = \"https://example.com/watermark.png\",\n        opacity = 0.5,\n        position = \"center\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[167],{"type":23,"tag":36,"props":168,"children":169},{"__ignoreMap":8},[170],{"type":28,"value":165},{"type":23,"tag":24,"props":172,"children":173},{},[174],{"type":28,"value":175},"This allows you to add visual protection to your documents with custom images.",{"title":8,"searchDepth":61,"depth":61,"links":177},[],"content:guides:csharp:httpclient:adding-an-image-watermark.md","guides/csharp/httpclient/adding-an-image-watermark.md",{"_path":181,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":182,"description":183,"language":11,"library":12,"property":184,"output":14,"related":185,"default":7,"body":188,"_type":63,"_id":216,"_source":65,"_file":217,"_extension":67},"/guides/csharp/httpclient/avoid-conversion-on-error","Avoid conversion on error","Learn how to avoid conversion on error using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to handle conversion errors gracefully.","continue_on_error",[186,187],"define-a-time-limit","receive-a-webhook-event",{"type":20,"children":189,"toc":214},[190,195,200,209],{"type":23,"tag":24,"props":191,"children":192},{},[193],{"type":28,"value":194},"In this guide, we'll show you how to avoid conversion on error using C# and the HttpClient library.",{"type":23,"tag":24,"props":196,"children":197},{},[198],{"type":28,"value":199},"When converting documents to PDF, you might want to prevent conversion if certain errors occur to avoid generating invalid PDFs.",{"type":23,"tag":44,"props":201,"children":204},{"className":202,"code":203,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Prevent conversion on error\n    continue_on_error = false\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[205],{"type":23,"tag":36,"props":206,"children":207},{"__ignoreMap":8},[208],{"type":28,"value":203},{"type":23,"tag":24,"props":210,"children":211},{},[212],{"type":28,"value":213},"This allows you to fail fast when conversion issues occur.",{"title":8,"searchDepth":61,"depth":61,"links":215},[],"content:guides:csharp:httpclient:avoid-conversion-on-error.md","guides/csharp/httpclient/avoid-conversion-on-error.md",{"_path":219,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":220,"description":221,"language":11,"library":12,"property":222,"output":14,"related":223,"default":18,"body":225,"_type":63,"_id":253,"_source":65,"_file":254,"_extension":67},"/guides/csharp/httpclient/convert-html-to-pdf-from-a-url","Convert HTML to PDF from a URL","Learn how to convert HTML from a URL to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to convert online HTML content to PDF.","source",[224,75],"convert-html-to-pdf-from-raw-html",{"type":20,"children":226,"toc":251},[227,232,237,246],{"type":23,"tag":24,"props":228,"children":229},{},[230],{"type":28,"value":231},"In this guide, we'll show you how to convert HTML from a URL to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":233,"children":234},{},[235],{"type":28,"value":236},"Converting HTML from a URL to PDF is a common requirement when you want to generate PDFs from existing web content.",{"type":23,"tag":44,"props":238,"children":241},{"className":239,"code":240,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[242],{"type":23,"tag":36,"props":243,"children":244},{"__ignoreMap":8},[245],{"type":28,"value":240},{"type":23,"tag":24,"props":247,"children":248},{},[249],{"type":28,"value":250},"This allows you to easily convert any webpage to a PDF document.",{"title":8,"searchDepth":61,"depth":61,"links":252},[],"content:guides:csharp:httpclient:convert-html-to-pdf-from-a-url.md","guides/csharp/httpclient/convert-html-to-pdf-from-a-url.md",{"_path":256,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":257,"description":258,"language":11,"library":12,"property":222,"output":14,"related":259,"default":18,"body":261,"_type":63,"_id":289,"_source":65,"_file":290,"_extension":67},"/guides/csharp/httpclient/convert-html-to-pdf-from-raw-html","Convert HTML to PDF from raw HTML","Learn how to convert raw HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to convert HTML content directly to PDF.",[260,74],"convert-html-to-pdf-from-a-url",{"type":20,"children":262,"toc":287},[263,268,273,282],{"type":23,"tag":24,"props":264,"children":265},{},[266],{"type":28,"value":267},"In this guide, we'll show you how to convert raw HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":269,"children":270},{},[271],{"type":28,"value":272},"Converting raw HTML content to PDF is useful when you have HTML content that isn't hosted on a web server.",{"type":23,"tag":44,"props":274,"children":277},{"className":275,"code":276,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"\u003Chtml>\u003Cbody>\u003Ch1>Hello World\u003C/h1>\u003C/body>\u003C/html>\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[278],{"type":23,"tag":36,"props":279,"children":280},{"__ignoreMap":8},[281],{"type":28,"value":276},{"type":23,"tag":24,"props":283,"children":284},{},[285],{"type":28,"value":286},"This allows you to convert HTML content directly to PDF without needing a URL.",{"title":8,"searchDepth":61,"depth":61,"links":288},[],"content:guides:csharp:httpclient:convert-html-to-pdf-from-raw-html.md","guides/csharp/httpclient/convert-html-to-pdf-from-raw-html.md",{"_path":292,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":293,"description":294,"language":11,"library":12,"property":295,"output":14,"related":296,"default":7,"body":298,"_type":63,"_id":326,"_source":65,"_file":327,"_extension":67},"/guides/csharp/httpclient/define-a-time-limit","Define a time limit","Learn how to define a time limit for PDF conversions using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to set timeouts to prevent long-running conversions.","timeout",[297,186],"avoid-conversion-on-error",{"type":20,"children":299,"toc":324},[300,305,310,319],{"type":23,"tag":24,"props":301,"children":302},{},[303],{"type":28,"value":304},"In this guide, we'll show you how to define a time limit for PDF conversions using C# and the HttpClient library.",{"type":23,"tag":24,"props":306,"children":307},{},[308],{"type":28,"value":309},"When converting documents to PDF, you might want to set a timeout to prevent long-running conversions from blocking your application.",{"type":23,"tag":44,"props":311,"children":314},{"className":312,"code":313,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Set a timeout in seconds\n    timeout = 30\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[315],{"type":23,"tag":36,"props":316,"children":317},{"__ignoreMap":8},[318],{"type":28,"value":313},{"type":23,"tag":24,"props":320,"children":321},{},[322],{"type":28,"value":323},"This allows you to control how long a conversion can take before timing out.",{"title":8,"searchDepth":61,"depth":61,"links":325},[],"content:guides:csharp:httpclient:define-a-time-limit.md","guides/csharp/httpclient/define-a-time-limit.md",{"_path":329,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":330,"description":331,"language":11,"library":12,"property":332,"output":14,"related":333,"default":7,"body":336,"_type":63,"_id":364,"_source":65,"_file":365,"_extension":67},"/guides/csharp/httpclient/exporting-only-a-specific-set-of-pages","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 HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to select specific pages for export.","pages",[334,335],"generate-a-document-with-full-height","save-your-pdf-online-and-get-back-a-url",{"type":20,"children":337,"toc":362},[338,343,348,357],{"type":23,"tag":24,"props":339,"children":340},{},[341],{"type":28,"value":342},"In this guide, we'll show you how to export only specific pages from a document when converting to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":344,"children":345},{},[346],{"type":28,"value":347},"When converting documents, you might want to export only a specific range of pages rather than the entire document.",{"type":23,"tag":44,"props":349,"children":352},{"className":350,"code":351,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Export only pages 1-3\n    pages = \"1-3\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[353],{"type":23,"tag":36,"props":354,"children":355},{"__ignoreMap":8},[356],{"type":28,"value":351},{"type":23,"tag":24,"props":358,"children":359},{},[360],{"type":28,"value":361},"This allows you to selectively export pages from multi-page documents.",{"title":8,"searchDepth":61,"depth":61,"links":363},[],"content:guides:csharp:httpclient:exporting-only-a-specific-set-of-pages.md","guides/csharp/httpclient/exporting-only-a-specific-set-of-pages.md",{"_path":367,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":368,"description":369,"language":11,"library":12,"property":370,"output":14,"related":371,"default":7,"body":373,"_type":63,"_id":401,"_source":65,"_file":402,"_extension":67},"/guides/csharp/httpclient/generate-a-document-with-full-height","Generate a document with full height","Learn how to generate a document with full height using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to create full-height PDFs.","full_height",[372,335],"exporting-only-a-specific-set-of-pages",{"type":20,"children":374,"toc":399},[375,380,385,394],{"type":23,"tag":24,"props":376,"children":377},{},[378],{"type":28,"value":379},"In this guide, we'll show you how to generate a document with full height using C# and the HttpClient library.",{"type":23,"tag":24,"props":381,"children":382},{},[383],{"type":28,"value":384},"When converting documents to PDF, you might want to ensure the entire document height is preserved.",{"type":23,"tag":44,"props":386,"children":389},{"className":387,"code":388,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Generate document with full height\n    full_height = true\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[390],{"type":23,"tag":36,"props":391,"children":392},{"__ignoreMap":8},[393],{"type":28,"value":388},{"type":23,"tag":24,"props":395,"children":396},{},[397],{"type":28,"value":398},"This ensures the entire document content is included in the PDF.",{"title":8,"searchDepth":61,"depth":61,"links":400},[],"content:guides:csharp:httpclient:generate-a-document-with-full-height.md","guides/csharp/httpclient/generate-a-document-with-full-height.md",{"_path":404,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":405,"description":406,"language":11,"library":12,"property":407,"output":14,"related":408,"default":7,"body":410,"_type":63,"_id":438,"_source":65,"_file":439,"_extension":67},"/guides/csharp/httpclient/loading-css-from-a-string","Loading CSS from a string","Learn how to load CSS from a string when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to apply inline CSS styling.","css",[75,409],"adding-a-custom-header-or-footer",{"type":20,"children":411,"toc":436},[412,417,422,431],{"type":23,"tag":24,"props":413,"children":414},{},[415],{"type":28,"value":416},"In this guide, we'll show you how to load CSS from a string when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":418,"children":419},{},[420],{"type":28,"value":421},"When converting HTML to PDF, you might want to apply CSS styling using inline CSS rather than external stylesheets.",{"type":23,"tag":44,"props":423,"children":426},{"className":424,"code":425,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load CSS from a string\n    css = \"body { font-family: Arial; } h1 { color: blue; }\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[427],{"type":23,"tag":36,"props":428,"children":429},{"__ignoreMap":8},[430],{"type":28,"value":425},{"type":23,"tag":24,"props":432,"children":433},{},[434],{"type":28,"value":435},"This allows you to apply custom styling directly to your PDFs.",{"title":8,"searchDepth":61,"depth":61,"links":437},[],"content:guides:csharp:httpclient:loading-css-from-a-string.md","guides/csharp/httpclient/loading-css-from-a-string.md",{"_path":441,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":442,"description":443,"language":11,"library":12,"property":407,"output":14,"related":444,"default":7,"body":445,"_type":63,"_id":473,"_source":65,"_file":474,"_extension":67},"/guides/csharp/httpclient/loading-css-from-a-url","Loading CSS from a URL","Learn how to load CSS from a URL when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to reference external CSS files.",[74,260],{"type":20,"children":446,"toc":471},[447,452,457,466],{"type":23,"tag":24,"props":448,"children":449},{},[450],{"type":28,"value":451},"In this guide, we'll show you how to load CSS from a URL when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":453,"children":454},{},[455],{"type":28,"value":456},"When converting HTML to PDF, you might want to reference external CSS files to maintain consistent styling.",{"type":23,"tag":44,"props":458,"children":461},{"className":459,"code":460,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load CSS from a URL\n    css = \"https://example.com/styles.css\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[462],{"type":23,"tag":36,"props":463,"children":464},{"__ignoreMap":8},[465],{"type":28,"value":460},{"type":23,"tag":24,"props":467,"children":468},{},[469],{"type":28,"value":470},"This allows you to apply external stylesheets to your PDFs.",{"title":8,"searchDepth":61,"depth":61,"links":472},[],"content:guides:csharp:httpclient:loading-css-from-a-url.md","guides/csharp/httpclient/loading-css-from-a-url.md",{"_path":476,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":477,"description":478,"language":11,"library":12,"property":479,"output":14,"related":480,"default":7,"body":483,"_type":63,"_id":511,"_source":65,"_file":512,"_extension":67},"/guides/csharp/httpclient/loading-javascript-from-a-string","Loading JavaScript from a string","Learn how to load JavaScript from a string when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to include inline JavaScript.","javascript",[481,482],"loading-javascript-from-a-url","waiting-for-a-custom-element-to-be-ready",{"type":20,"children":484,"toc":509},[485,490,495,504],{"type":23,"tag":24,"props":486,"children":487},{},[488],{"type":28,"value":489},"In this guide, we'll show you how to load JavaScript from a string when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":491,"children":492},{},[493],{"type":28,"value":494},"When converting HTML to PDF, you might want to include JavaScript functionality using inline code.",{"type":23,"tag":44,"props":496,"children":499},{"className":497,"code":498,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load JavaScript from a string\n    javascript = \"document.body.style.backgroundColor = 'red';\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[500],{"type":23,"tag":36,"props":501,"children":502},{"__ignoreMap":8},[503],{"type":28,"value":498},{"type":23,"tag":24,"props":505,"children":506},{},[507],{"type":28,"value":508},"This enables dynamic behavior in your PDFs.",{"title":8,"searchDepth":61,"depth":61,"links":510},[],"content:guides:csharp:httpclient:loading-javascript-from-a-string.md","guides/csharp/httpclient/loading-javascript-from-a-string.md",{"_path":514,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":515,"description":516,"language":11,"library":12,"property":479,"output":14,"related":517,"default":7,"body":519,"_type":63,"_id":547,"_source":65,"_file":548,"_extension":67},"/guides/csharp/httpclient/loading-javascript-from-a-url","Loading JavaScript from a URL","Learn how to load JavaScript from a URL when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to reference external JavaScript files.",[518,482],"loading-javascript-from-a-string",{"type":20,"children":520,"toc":545},[521,526,531,540],{"type":23,"tag":24,"props":522,"children":523},{},[524],{"type":28,"value":525},"In this guide, we'll show you how to load JavaScript from a URL when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":527,"children":528},{},[529],{"type":28,"value":530},"When converting HTML to PDF, you might want to reference external JavaScript files to include dynamic functionality.",{"type":23,"tag":44,"props":532,"children":535},{"className":533,"code":534,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load JavaScript from a URL\n    javascript = \"https://example.com/script.js\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[536],{"type":23,"tag":36,"props":537,"children":538},{"__ignoreMap":8},[539],{"type":28,"value":534},{"type":23,"tag":24,"props":541,"children":542},{},[543],{"type":28,"value":544},"This allows you to include external JavaScript libraries in your PDFs.",{"title":8,"searchDepth":61,"depth":61,"links":546},[],"content:guides:csharp:httpclient:loading-javascript-from-a-url.md","guides/csharp/httpclient/loading-javascript-from-a-url.md",{"_path":550,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":551,"description":552,"language":11,"library":12,"property":553,"output":14,"related":554,"default":7,"body":555,"_type":63,"_id":583,"_source":65,"_file":584,"_extension":67},"/guides/csharp/httpclient/protecting-the-generated-pdf","Protecting the generated PDF","Learn how to protect generated PDFs with passwords using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to secure your PDF documents.","protection",[112,149],{"type":20,"children":556,"toc":581},[557,562,567,576],{"type":23,"tag":24,"props":558,"children":559},{},[560],{"type":28,"value":561},"In this guide, we'll show you how to protect generated PDFs with passwords using C# and the HttpClient library.",{"type":23,"tag":24,"props":563,"children":564},{},[565],{"type":28,"value":566},"When generating PDFs, you might want to add password protection to restrict access.",{"type":23,"tag":44,"props":568,"children":571},{"className":569,"code":570,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Protect the PDF with a password\n    protection = new\n    {\n        user_password = \"user123\",\n        owner_password = \"owner123\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[572],{"type":23,"tag":36,"props":573,"children":574},{"__ignoreMap":8},[575],{"type":28,"value":570},{"type":23,"tag":24,"props":577,"children":578},{},[579],{"type":28,"value":580},"This allows you to secure your PDF documents with passwords.",{"title":8,"searchDepth":61,"depth":61,"links":582},[],"content:guides:csharp:httpclient:protecting-the-generated-pdf.md","guides/csharp/httpclient/protecting-the-generated-pdf.md",{"_path":586,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":587,"description":588,"language":11,"library":12,"property":589,"output":14,"related":590,"default":7,"body":591,"_type":63,"_id":619,"_source":65,"_file":620,"_extension":67},"/guides/csharp/httpclient/receive-a-webhook-event","Receive a webhook event","Learn how to receive webhook events when PDF conversion is complete using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to handle asynchronous conversion notifications.","webhook",[335,297],{"type":20,"children":592,"toc":617},[593,598,603,612],{"type":23,"tag":24,"props":594,"children":595},{},[596],{"type":28,"value":597},"In this guide, we'll show you how to receive webhook events when PDF conversion is complete using C# and the HttpClient library.",{"type":23,"tag":24,"props":599,"children":600},{},[601],{"type":28,"value":602},"When converting documents asynchronously, you might want to be notified when the conversion is complete via a webhook.",{"type":23,"tag":44,"props":604,"children":607},{"className":605,"code":606,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Set up webhook notification\n    webhook = new\n    {\n        url = \"https://your-server.com/webhook\",\n        secret = \"your-secret-key\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[608],{"type":23,"tag":36,"props":609,"children":610},{"__ignoreMap":8},[611],{"type":28,"value":606},{"type":23,"tag":24,"props":613,"children":614},{},[615],{"type":28,"value":616},"This allows you to be notified when conversions are complete without polling.",{"title":8,"searchDepth":61,"depth":61,"links":618},[],"content:guides:csharp:httpclient:receive-a-webhook-event.md","guides/csharp/httpclient/receive-a-webhook-event.md",{"_path":622,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":623,"description":624,"language":11,"library":12,"property":625,"output":626,"related":627,"default":7,"body":629,"_type":63,"_id":657,"_source":65,"_file":658,"_extension":67},"/guides/csharp/httpclient/save-your-pdf-online-and-get-back-a-url","Save your PDF online and get back a URL","Learn how to save your PDF online and get back a URL using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to store PDFs in cloud storage and retrieve URLs.","output","url",[628,187],"save-your-pdf-to-your-amazon-s3-bucket",{"type":20,"children":630,"toc":655},[631,636,641,650],{"type":23,"tag":24,"props":632,"children":633},{},[634],{"type":28,"value":635},"In this guide, we'll show you how to save your PDF online and get back a URL using C# and the HttpClient library.",{"type":23,"tag":24,"props":637,"children":638},{},[639],{"type":28,"value":640},"When generating PDFs, you might want to store them in cloud storage and get a URL to access them later.",{"type":23,"tag":44,"props":642,"children":645},{"className":643,"code":644,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Save PDF to cloud storage and get URL\n    output = new\n    {\n        type = \"url\",\n        url = \"https://your-storage.com/\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[646],{"type":23,"tag":36,"props":647,"children":648},{"__ignoreMap":8},[649],{"type":28,"value":644},{"type":23,"tag":24,"props":651,"children":652},{},[653],{"type":28,"value":654},"This allows you to store PDFs in cloud storage and access them via URLs.",{"title":8,"searchDepth":61,"depth":61,"links":656},[],"content:guides:csharp:httpclient:save-your-pdf-online-and-get-back-a-url.md","guides/csharp/httpclient/save-your-pdf-online-and-get-back-a-url.md",{"_path":660,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":661,"description":662,"language":11,"library":12,"property":625,"output":663,"related":664,"default":7,"body":665,"_type":63,"_id":693,"_source":65,"_file":694,"_extension":67},"/guides/csharp/httpclient/save-your-pdf-to-your-amazon-s3-bucket","Save your PDF to your Amazon S3 bucket","Learn how to save your PDF to your Amazon S3 bucket using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to store PDFs directly in AWS S3.","s3",[335,187],{"type":20,"children":666,"toc":691},[667,672,677,686],{"type":23,"tag":24,"props":668,"children":669},{},[670],{"type":28,"value":671},"In this guide, we'll show you how to save your PDF to your Amazon S3 bucket using C# and the HttpClient library.",{"type":23,"tag":24,"props":673,"children":674},{},[675],{"type":28,"value":676},"When generating PDFs, you might want to store them directly in Amazon S3 for easy access and management.",{"type":23,"tag":44,"props":678,"children":681},{"className":679,"code":680,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Save PDF to Amazon S3 bucket\n    output = new\n    {\n        type = \"s3\",\n        bucket = \"your-bucket-name\",\n        key = \"path/to/document.pdf\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[682],{"type":23,"tag":36,"props":683,"children":684},{"__ignoreMap":8},[685],{"type":28,"value":680},{"type":23,"tag":24,"props":687,"children":688},{},[689],{"type":28,"value":690},"This allows you to store PDFs directly in your AWS S3 buckets.",{"title":8,"searchDepth":61,"depth":61,"links":692},[],"content:guides:csharp:httpclient:save-your-pdf-to-your-amazon-s3-bucket.md","guides/csharp/httpclient/save-your-pdf-to-your-amazon-s3-bucket.md",{"_path":696,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":697,"description":698,"language":11,"library":12,"property":699,"output":14,"related":700,"default":7,"body":702,"_type":63,"_id":730,"_source":65,"_file":731,"_extension":67},"/guides/csharp/httpclient/send-custom-http-headers","Send custom HTTP headers","Learn how to send custom HTTP headers when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to customize request headers.","headers",[701,17],"accessing-secured-pages",{"type":20,"children":703,"toc":728},[704,709,714,723],{"type":23,"tag":24,"props":705,"children":706},{},[707],{"type":28,"value":708},"In this guide, we'll show you how to send custom HTTP headers when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":710,"children":711},{},[712],{"type":28,"value":713},"When converting HTML to PDF, you might need to send custom HTTP headers to access protected resources or provide additional information.",{"type":23,"tag":44,"props":715,"children":718},{"className":716,"code":717,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Send custom HTTP headers\n    headers = new\n    {\n        authorization = \"Bearer token123\",\n        \"user-agent\" = \"MyApp/1.0\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[719],{"type":23,"tag":36,"props":720,"children":721},{"__ignoreMap":8},[722],{"type":28,"value":717},{"type":23,"tag":24,"props":724,"children":725},{},[726],{"type":28,"value":727},"This allows you to customize the HTTP requests sent to the source URL.",{"title":8,"searchDepth":61,"depth":61,"links":729},[],"content:guides:csharp:httpclient:send-custom-http-headers.md","guides/csharp/httpclient/send-custom-http-headers.md",{"_path":733,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":734,"description":735,"language":11,"library":12,"property":736,"output":14,"related":737,"default":7,"body":738,"_type":63,"_id":766,"_source":65,"_file":767,"_extension":67},"/guides/csharp/httpclient/using-cookies","Using cookies","Learn how to use cookies when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to manage cookies during conversion.","cookies",[701,16],{"type":20,"children":739,"toc":764},[740,745,750,759],{"type":23,"tag":24,"props":741,"children":742},{},[743],{"type":28,"value":744},"In this guide, we'll show you how to use cookies when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":746,"children":747},{},[748],{"type":28,"value":749},"When converting HTML to PDF, you might need to send cookies to access authenticated content or maintain session state.",{"type":23,"tag":44,"props":751,"children":754},{"className":752,"code":753,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Send cookies with the request\n    cookies = new\n    {\n        sessionid = \"abc123\",\n        user = \"john_doe\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[755],{"type":23,"tag":36,"props":756,"children":757},{"__ignoreMap":8},[758],{"type":28,"value":753},{"type":23,"tag":24,"props":760,"children":761},{},[762],{"type":28,"value":763},"This allows you to maintain session state when accessing protected content.",{"title":8,"searchDepth":61,"depth":61,"links":765},[],"content:guides:csharp:httpclient:using-cookies.md","guides/csharp/httpclient/using-cookies.md",{"_path":769,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":770,"description":771,"language":11,"library":12,"property":772,"output":14,"related":773,"default":7,"body":774,"_type":63,"_id":802,"_source":65,"_file":803,"_extension":67},"/guides/csharp/httpclient/waiting-for-a-custom-element-to-be-ready","Waiting for a custom element to be ready","Learn how to wait for a custom element to be ready when converting HTML to PDF using C# and the HttpClient library. This guide offers detailed steps with code samples in C# and the HttpClient library, showing how to handle dynamic content.","wait_for",[518,481],{"type":20,"children":775,"toc":800},[776,781,786,795],{"type":23,"tag":24,"props":777,"children":778},{},[779],{"type":28,"value":780},"In this guide, we'll show you how to wait for a custom element to be ready when converting HTML to PDF using C# and the HttpClient library.",{"type":23,"tag":24,"props":782,"children":783},{},[784],{"type":28,"value":785},"When converting HTML containing dynamic content, you might need to wait for specific elements to be rendered before generating the PDF.",{"type":23,"tag":44,"props":787,"children":790},{"className":788,"code":789,"language":49,"meta":8},[47],"using System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading.Tasks;\n\n// You can get an API key at https://pdfshift.io\nvar apiKey = \"sk_xxxxxxxxxxxx\";\n\nvar client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Wait for a specific element to be ready\n    wait_for = \"#dynamic-content.loaded\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nvar content = new StringContent(json, System.Text.Encoding.UTF8, \"application/json\");\n\nvar response = await client.PostAsync(\"https://api.pdfshift.io/v3/convert/pdf\", content);\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\nvar result = await response.Content.ReadAsByteArrayAsync();\n\nSystem.IO.File.WriteAllBytes(\"result.pdf\", result);\n\nConsole.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n",[791],{"type":23,"tag":36,"props":792,"children":793},{"__ignoreMap":8},[794],{"type":28,"value":789},{"type":23,"tag":24,"props":796,"children":797},{},[798],{"type":28,"value":799},"This allows you to ensure dynamic content is fully loaded before PDF generation.",{"title":8,"searchDepth":61,"depth":61,"links":801},[],"content:guides:csharp:httpclient:waiting-for-a-custom-element-to-be-ready.md","guides/csharp/httpclient/waiting-for-a-custom-element-to-be-ready.md",{"_path":805,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":807,"language":11,"library":808,"property":13,"output":14,"related":809,"default":18,"body":810,"_type":63,"_id":842,"_source":65,"_file":843,"_extension":67},"/guides/csharp/httpwebrequest/accessing-secured-pages","httpwebrequest","Learn how to access secured pages using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, highlighting how you can access page protected by basic authentication to convert them to PDF using PDFShift's API.","HTTPWebRequest",[16,17],{"type":20,"children":811,"toc":840},[812,817,827,836],{"type":23,"tag":24,"props":813,"children":814},{},[815],{"type":28,"value":816},"In this guide, we'll show you how to access secured page (protected by basic authentication) using C# and the HTTPWebRequest library to convert them to PDF using PDFShift's API.",{"type":23,"tag":24,"props":818,"children":819},{},[820,821,826],{"type":28,"value":34},{"type":23,"tag":36,"props":822,"children":824},{"className":823},[],[825],{"type":28,"value":13},{"type":28,"value":42},{"type":23,"tag":44,"props":828,"children":831},{"className":829,"code":830,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // You can set a basic authentication by passing the \"auth\" property which contains a username and password\n    auth = new\n    {\n        username = \"user\",\n        password = \"password\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[832],{"type":23,"tag":36,"props":833,"children":834},{"__ignoreMap":8},[835],{"type":28,"value":830},{"type":23,"tag":24,"props":837,"children":838},{},[839],{"type":28,"value":59},{"title":8,"searchDepth":61,"depth":61,"links":841},[],"content:guides:csharp:httpwebrequest:accessing-secured-pages.md","guides/csharp/httpwebrequest/accessing-secured-pages.md",{"_path":845,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":70,"description":846,"language":11,"library":808,"property":72,"output":14,"related":847,"default":7,"body":848,"_type":63,"_id":874,"_source":65,"_file":875,"_extension":67},"/guides/csharp/httpwebrequest/adding-a-custom-header-or-footer","Learn how to add custom headers and footers to your PDFs using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to customize PDF appearance with headers and footers.",[74,75],{"type":20,"children":849,"toc":872},[850,855,859,868],{"type":23,"tag":24,"props":851,"children":852},{},[853],{"type":28,"value":854},"In this guide, we'll show you how to add custom headers and footers to your PDFs using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":856,"children":857},{},[858],{"type":28,"value":87},{"type":23,"tag":44,"props":860,"children":863},{"className":861,"code":862,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add custom header and footer\n    header = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Header Content\u003C/div>\",\n        height = \"20mm\"\n    },\n    footer = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Footer Content\u003C/div>\",\n        height = \"20mm\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[864],{"type":23,"tag":36,"props":865,"children":866},{"__ignoreMap":8},[867],{"type":28,"value":862},{"type":23,"tag":24,"props":869,"children":870},{},[871],{"type":28,"value":101},{"title":8,"searchDepth":61,"depth":61,"links":873},[],"content:guides:csharp:httpwebrequest:adding-a-custom-header-or-footer.md","guides/csharp/httpwebrequest/adding-a-custom-header-or-footer.md",{"_path":877,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":108,"description":878,"language":11,"library":808,"property":110,"output":14,"related":879,"default":7,"body":880,"_type":63,"_id":906,"_source":65,"_file":907,"_extension":67},"/guides/csharp/httpwebrequest/adding-a-text-watermark","Learn how to add text watermarks to your PDFs using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to apply text watermarks to protect your documents.",[112,113],{"type":20,"children":881,"toc":904},[882,887,891,900],{"type":23,"tag":24,"props":883,"children":884},{},[885],{"type":28,"value":886},"In this guide, we'll show you how to add text watermarks to your PDFs using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":888,"children":889},{},[890],{"type":28,"value":125},{"type":23,"tag":44,"props":892,"children":895},{"className":893,"code":894,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add text watermark\n    watermark = new\n    {\n        text = \"CONFIDENTIAL\",\n        opacity = 0.3,\n        size = \"20px\",\n        color = \"#000000\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[896],{"type":23,"tag":36,"props":897,"children":898},{"__ignoreMap":8},[899],{"type":28,"value":894},{"type":23,"tag":24,"props":901,"children":902},{},[903],{"type":28,"value":139},{"title":8,"searchDepth":61,"depth":61,"links":905},[],"content:guides:csharp:httpwebrequest:adding-a-text-watermark.md","guides/csharp/httpwebrequest/adding-a-text-watermark.md",{"_path":909,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":146,"description":910,"language":11,"library":808,"property":110,"output":14,"related":911,"default":7,"body":912,"_type":63,"_id":938,"_source":65,"_file":939,"_extension":67},"/guides/csharp/httpwebrequest/adding-an-image-watermark","Learn how to add image watermarks to your PDFs using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to apply image watermarks to protect your documents.",[149,113],{"type":20,"children":913,"toc":936},[914,919,923,932],{"type":23,"tag":24,"props":915,"children":916},{},[917],{"type":28,"value":918},"In this guide, we'll show you how to add image watermarks to your PDFs using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":920,"children":921},{},[922],{"type":28,"value":161},{"type":23,"tag":44,"props":924,"children":927},{"className":925,"code":926,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Add image watermark\n    watermark = new\n    {\n        image = \"https://example.com/watermark.png\",\n        opacity = 0.5,\n        position = \"center\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[928],{"type":23,"tag":36,"props":929,"children":930},{"__ignoreMap":8},[931],{"type":28,"value":926},{"type":23,"tag":24,"props":933,"children":934},{},[935],{"type":28,"value":175},{"title":8,"searchDepth":61,"depth":61,"links":937},[],"content:guides:csharp:httpwebrequest:adding-an-image-watermark.md","guides/csharp/httpwebrequest/adding-an-image-watermark.md",{"_path":941,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":182,"description":942,"language":11,"library":808,"property":184,"output":14,"related":943,"default":7,"body":944,"_type":63,"_id":970,"_source":65,"_file":971,"_extension":67},"/guides/csharp/httpwebrequest/avoid-conversion-on-error","Learn how to avoid conversion on error using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to handle conversion errors gracefully.",[186,187],{"type":20,"children":945,"toc":968},[946,951,955,964],{"type":23,"tag":24,"props":947,"children":948},{},[949],{"type":28,"value":950},"In this guide, we'll show you how to avoid conversion on error using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":952,"children":953},{},[954],{"type":28,"value":199},{"type":23,"tag":44,"props":956,"children":959},{"className":957,"code":958,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Prevent conversion on error\n    continue_on_error = false\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[960],{"type":23,"tag":36,"props":961,"children":962},{"__ignoreMap":8},[963],{"type":28,"value":958},{"type":23,"tag":24,"props":965,"children":966},{},[967],{"type":28,"value":213},{"title":8,"searchDepth":61,"depth":61,"links":969},[],"content:guides:csharp:httpwebrequest:avoid-conversion-on-error.md","guides/csharp/httpwebrequest/avoid-conversion-on-error.md",{"_path":973,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":220,"description":974,"language":11,"library":808,"property":222,"output":14,"related":975,"default":18,"body":976,"_type":63,"_id":1002,"_source":65,"_file":1003,"_extension":67},"/guides/csharp/httpwebrequest/convert-html-to-pdf-from-a-url","Learn how to convert HTML from a URL to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to convert online HTML content to PDF.",[224,75],{"type":20,"children":977,"toc":1000},[978,983,987,996],{"type":23,"tag":24,"props":979,"children":980},{},[981],{"type":28,"value":982},"In this guide, we'll show you how to convert HTML from a URL to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":984,"children":985},{},[986],{"type":28,"value":236},{"type":23,"tag":44,"props":988,"children":991},{"className":989,"code":990,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[992],{"type":23,"tag":36,"props":993,"children":994},{"__ignoreMap":8},[995],{"type":28,"value":990},{"type":23,"tag":24,"props":997,"children":998},{},[999],{"type":28,"value":250},{"title":8,"searchDepth":61,"depth":61,"links":1001},[],"content:guides:csharp:httpwebrequest:convert-html-to-pdf-from-a-url.md","guides/csharp/httpwebrequest/convert-html-to-pdf-from-a-url.md",{"_path":1005,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":257,"description":1006,"language":11,"library":808,"property":222,"output":14,"related":1007,"default":18,"body":1008,"_type":63,"_id":1034,"_source":65,"_file":1035,"_extension":67},"/guides/csharp/httpwebrequest/convert-html-to-pdf-from-raw-html","Learn how to convert raw HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to convert HTML content directly to PDF.",[260,74],{"type":20,"children":1009,"toc":1032},[1010,1015,1019,1028],{"type":23,"tag":24,"props":1011,"children":1012},{},[1013],{"type":28,"value":1014},"In this guide, we'll show you how to convert raw HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1016,"children":1017},{},[1018],{"type":28,"value":272},{"type":23,"tag":44,"props":1020,"children":1023},{"className":1021,"code":1022,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"\u003Chtml>\u003Cbody>\u003Ch1>Hello World\u003C/h1>\u003C/body>\u003C/html>\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1024],{"type":23,"tag":36,"props":1025,"children":1026},{"__ignoreMap":8},[1027],{"type":28,"value":1022},{"type":23,"tag":24,"props":1029,"children":1030},{},[1031],{"type":28,"value":286},{"title":8,"searchDepth":61,"depth":61,"links":1033},[],"content:guides:csharp:httpwebrequest:convert-html-to-pdf-from-raw-html.md","guides/csharp/httpwebrequest/convert-html-to-pdf-from-raw-html.md",{"_path":1037,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":293,"description":1038,"language":11,"library":808,"property":295,"output":14,"related":1039,"default":7,"body":1040,"_type":63,"_id":1066,"_source":65,"_file":1067,"_extension":67},"/guides/csharp/httpwebrequest/define-a-time-limit","Learn how to define a time limit for PDF conversions using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to set timeouts to prevent long-running conversions.",[297,186],{"type":20,"children":1041,"toc":1064},[1042,1047,1051,1060],{"type":23,"tag":24,"props":1043,"children":1044},{},[1045],{"type":28,"value":1046},"In this guide, we'll show you how to define a time limit for PDF conversions using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1048,"children":1049},{},[1050],{"type":28,"value":309},{"type":23,"tag":44,"props":1052,"children":1055},{"className":1053,"code":1054,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n// Set a timeout in milliseconds\nrequest.Timeout = 30000;\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Set a timeout in seconds\n    timeout = 30\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1056],{"type":23,"tag":36,"props":1057,"children":1058},{"__ignoreMap":8},[1059],{"type":28,"value":1054},{"type":23,"tag":24,"props":1061,"children":1062},{},[1063],{"type":28,"value":323},{"title":8,"searchDepth":61,"depth":61,"links":1065},[],"content:guides:csharp:httpwebrequest:define-a-time-limit.md","guides/csharp/httpwebrequest/define-a-time-limit.md",{"_path":1069,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":330,"description":1070,"language":11,"library":808,"property":332,"output":14,"related":1071,"default":7,"body":1072,"_type":63,"_id":1098,"_source":65,"_file":1099,"_extension":67},"/guides/csharp/httpwebrequest/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 HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to select specific pages for export.",[334,335],{"type":20,"children":1073,"toc":1096},[1074,1079,1083,1092],{"type":23,"tag":24,"props":1075,"children":1076},{},[1077],{"type":28,"value":1078},"In this guide, we'll show you how to export only specific pages from a document when converting to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1080,"children":1081},{},[1082],{"type":28,"value":347},{"type":23,"tag":44,"props":1084,"children":1087},{"className":1085,"code":1086,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Export only pages 1-3\n    pages = \"1-3\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1088],{"type":23,"tag":36,"props":1089,"children":1090},{"__ignoreMap":8},[1091],{"type":28,"value":1086},{"type":23,"tag":24,"props":1093,"children":1094},{},[1095],{"type":28,"value":361},{"title":8,"searchDepth":61,"depth":61,"links":1097},[],"content:guides:csharp:httpwebrequest:exporting-only-a-specific-set-of-pages.md","guides/csharp/httpwebrequest/exporting-only-a-specific-set-of-pages.md",{"_path":1101,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":368,"description":1102,"language":11,"library":808,"property":370,"output":14,"related":1103,"default":7,"body":1104,"_type":63,"_id":1130,"_source":65,"_file":1131,"_extension":67},"/guides/csharp/httpwebrequest/generate-a-document-with-full-height","Learn how to generate a document with full height using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to create full-height PDFs.",[372,335],{"type":20,"children":1105,"toc":1128},[1106,1111,1115,1124],{"type":23,"tag":24,"props":1107,"children":1108},{},[1109],{"type":28,"value":1110},"In this guide, we'll show you how to generate a document with full height using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1112,"children":1113},{},[1114],{"type":28,"value":384},{"type":23,"tag":44,"props":1116,"children":1119},{"className":1117,"code":1118,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Generate document with full height\n    full_height = true\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1120],{"type":23,"tag":36,"props":1121,"children":1122},{"__ignoreMap":8},[1123],{"type":28,"value":1118},{"type":23,"tag":24,"props":1125,"children":1126},{},[1127],{"type":28,"value":398},{"title":8,"searchDepth":61,"depth":61,"links":1129},[],"content:guides:csharp:httpwebrequest:generate-a-document-with-full-height.md","guides/csharp/httpwebrequest/generate-a-document-with-full-height.md",{"_path":1133,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":405,"description":1134,"language":11,"library":808,"property":407,"output":14,"related":1135,"default":7,"body":1136,"_type":63,"_id":1162,"_source":65,"_file":1163,"_extension":67},"/guides/csharp/httpwebrequest/loading-css-from-a-string","Learn how to load CSS from a string when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to apply inline CSS styling.",[75,409],{"type":20,"children":1137,"toc":1160},[1138,1143,1147,1156],{"type":23,"tag":24,"props":1139,"children":1140},{},[1141],{"type":28,"value":1142},"In this guide, we'll show you how to load CSS from a string when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1144,"children":1145},{},[1146],{"type":28,"value":421},{"type":23,"tag":44,"props":1148,"children":1151},{"className":1149,"code":1150,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load CSS from a string\n    css = \"body { font-family: Arial; } h1 { color: blue; }\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1152],{"type":23,"tag":36,"props":1153,"children":1154},{"__ignoreMap":8},[1155],{"type":28,"value":1150},{"type":23,"tag":24,"props":1157,"children":1158},{},[1159],{"type":28,"value":435},{"title":8,"searchDepth":61,"depth":61,"links":1161},[],"content:guides:csharp:httpwebrequest:loading-css-from-a-string.md","guides/csharp/httpwebrequest/loading-css-from-a-string.md",{"_path":1165,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":442,"description":1166,"language":11,"library":808,"property":407,"output":14,"related":1167,"default":7,"body":1168,"_type":63,"_id":1194,"_source":65,"_file":1195,"_extension":67},"/guides/csharp/httpwebrequest/loading-css-from-a-url","Learn how to load CSS from a URL when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to reference external CSS files.",[74,260],{"type":20,"children":1169,"toc":1192},[1170,1175,1179,1188],{"type":23,"tag":24,"props":1171,"children":1172},{},[1173],{"type":28,"value":1174},"In this guide, we'll show you how to load CSS from a URL when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1176,"children":1177},{},[1178],{"type":28,"value":456},{"type":23,"tag":44,"props":1180,"children":1183},{"className":1181,"code":1182,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load CSS from a URL\n    css = \"https://example.com/styles.css\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1184],{"type":23,"tag":36,"props":1185,"children":1186},{"__ignoreMap":8},[1187],{"type":28,"value":1182},{"type":23,"tag":24,"props":1189,"children":1190},{},[1191],{"type":28,"value":470},{"title":8,"searchDepth":61,"depth":61,"links":1193},[],"content:guides:csharp:httpwebrequest:loading-css-from-a-url.md","guides/csharp/httpwebrequest/loading-css-from-a-url.md",{"_path":1197,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":477,"description":1198,"language":11,"library":808,"property":479,"output":14,"related":1199,"default":7,"body":1200,"_type":63,"_id":1226,"_source":65,"_file":1227,"_extension":67},"/guides/csharp/httpwebrequest/loading-javascript-from-a-string","Learn how to load JavaScript from a string when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to include inline JavaScript.",[481,482],{"type":20,"children":1201,"toc":1224},[1202,1207,1211,1220],{"type":23,"tag":24,"props":1203,"children":1204},{},[1205],{"type":28,"value":1206},"In this guide, we'll show you how to load JavaScript from a string when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1208,"children":1209},{},[1210],{"type":28,"value":494},{"type":23,"tag":44,"props":1212,"children":1215},{"className":1213,"code":1214,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load JavaScript from a string\n    javascript = \"document.body.style.backgroundColor = 'red';\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1216],{"type":23,"tag":36,"props":1217,"children":1218},{"__ignoreMap":8},[1219],{"type":28,"value":1214},{"type":23,"tag":24,"props":1221,"children":1222},{},[1223],{"type":28,"value":508},{"title":8,"searchDepth":61,"depth":61,"links":1225},[],"content:guides:csharp:httpwebrequest:loading-javascript-from-a-string.md","guides/csharp/httpwebrequest/loading-javascript-from-a-string.md",{"_path":1229,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":515,"description":1230,"language":11,"library":808,"property":479,"output":14,"related":1231,"default":7,"body":1232,"_type":63,"_id":1258,"_source":65,"_file":1259,"_extension":67},"/guides/csharp/httpwebrequest/loading-javascript-from-a-url","Learn how to load JavaScript from a URL when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to reference external JavaScript files.",[518,482],{"type":20,"children":1233,"toc":1256},[1234,1239,1243,1252],{"type":23,"tag":24,"props":1235,"children":1236},{},[1237],{"type":28,"value":1238},"In this guide, we'll show you how to load JavaScript from a URL when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1240,"children":1241},{},[1242],{"type":28,"value":530},{"type":23,"tag":44,"props":1244,"children":1247},{"className":1245,"code":1246,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Load JavaScript from a URL\n    javascript = \"https://example.com/script.js\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1248],{"type":23,"tag":36,"props":1249,"children":1250},{"__ignoreMap":8},[1251],{"type":28,"value":1246},{"type":23,"tag":24,"props":1253,"children":1254},{},[1255],{"type":28,"value":544},{"title":8,"searchDepth":61,"depth":61,"links":1257},[],"content:guides:csharp:httpwebrequest:loading-javascript-from-a-url.md","guides/csharp/httpwebrequest/loading-javascript-from-a-url.md",{"_path":1261,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":551,"description":1262,"language":11,"library":808,"property":553,"output":14,"related":1263,"default":7,"body":1264,"_type":63,"_id":1290,"_source":65,"_file":1291,"_extension":67},"/guides/csharp/httpwebrequest/protecting-the-generated-pdf","Learn how to protect generated PDFs with passwords using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to secure your PDF documents.",[112,149],{"type":20,"children":1265,"toc":1288},[1266,1271,1275,1284],{"type":23,"tag":24,"props":1267,"children":1268},{},[1269],{"type":28,"value":1270},"In this guide, we'll show you how to protect generated PDFs with passwords using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1272,"children":1273},{},[1274],{"type":28,"value":566},{"type":23,"tag":44,"props":1276,"children":1279},{"className":1277,"code":1278,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Protect the PDF with a password\n    protection = new\n    {\n        user_password = \"user123\",\n        owner_password = \"owner123\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1280],{"type":23,"tag":36,"props":1281,"children":1282},{"__ignoreMap":8},[1283],{"type":28,"value":1278},{"type":23,"tag":24,"props":1285,"children":1286},{},[1287],{"type":28,"value":580},{"title":8,"searchDepth":61,"depth":61,"links":1289},[],"content:guides:csharp:httpwebrequest:protecting-the-generated-pdf.md","guides/csharp/httpwebrequest/protecting-the-generated-pdf.md",{"_path":1293,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":587,"description":1294,"language":11,"library":808,"property":589,"output":14,"related":1295,"default":7,"body":1296,"_type":63,"_id":1322,"_source":65,"_file":1323,"_extension":67},"/guides/csharp/httpwebrequest/receive-a-webhook-event","Learn how to receive webhook events when PDF conversion is complete using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to handle asynchronous conversion notifications.",[335,297],{"type":20,"children":1297,"toc":1320},[1298,1303,1307,1316],{"type":23,"tag":24,"props":1299,"children":1300},{},[1301],{"type":28,"value":1302},"In this guide, we'll show you how to receive webhook events when PDF conversion is complete using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1304,"children":1305},{},[1306],{"type":28,"value":602},{"type":23,"tag":44,"props":1308,"children":1311},{"className":1309,"code":1310,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Set up webhook notification\n    webhook = new\n    {\n        url = \"https://your-server.com/webhook\",\n        secret = \"your-secret-key\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1312],{"type":23,"tag":36,"props":1313,"children":1314},{"__ignoreMap":8},[1315],{"type":28,"value":1310},{"type":23,"tag":24,"props":1317,"children":1318},{},[1319],{"type":28,"value":616},{"title":8,"searchDepth":61,"depth":61,"links":1321},[],"content:guides:csharp:httpwebrequest:receive-a-webhook-event.md","guides/csharp/httpwebrequest/receive-a-webhook-event.md",{"_path":1325,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":623,"description":1326,"language":11,"library":808,"property":625,"output":626,"related":1327,"default":7,"body":1328,"_type":63,"_id":1354,"_source":65,"_file":1355,"_extension":67},"/guides/csharp/httpwebrequest/save-your-pdf-online-and-get-back-a-url","Learn how to save your PDF online and get back a URL using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to store PDFs in cloud storage and retrieve URLs.",[628,187],{"type":20,"children":1329,"toc":1352},[1330,1335,1339,1348],{"type":23,"tag":24,"props":1331,"children":1332},{},[1333],{"type":28,"value":1334},"In this guide, we'll show you how to save your PDF online and get back a URL using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1336,"children":1337},{},[1338],{"type":28,"value":640},{"type":23,"tag":44,"props":1340,"children":1343},{"className":1341,"code":1342,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Save PDF to cloud storage and get URL\n    output = new\n    {\n        type = \"url\",\n        url = \"https://your-storage.com/\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1344],{"type":23,"tag":36,"props":1345,"children":1346},{"__ignoreMap":8},[1347],{"type":28,"value":1342},{"type":23,"tag":24,"props":1349,"children":1350},{},[1351],{"type":28,"value":654},{"title":8,"searchDepth":61,"depth":61,"links":1353},[],"content:guides:csharp:httpwebrequest:save-your-pdf-online-and-get-back-a-url.md","guides/csharp/httpwebrequest/save-your-pdf-online-and-get-back-a-url.md",{"_path":1357,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":661,"description":1358,"language":11,"library":808,"property":625,"output":663,"related":1359,"default":7,"body":1360,"_type":63,"_id":1386,"_source":65,"_file":1387,"_extension":67},"/guides/csharp/httpwebrequest/save-your-pdf-to-your-amazon-s3-bucket","Learn how to save your PDF to your Amazon S3 bucket using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to store PDFs directly in AWS S3.",[335,187],{"type":20,"children":1361,"toc":1384},[1362,1367,1371,1380],{"type":23,"tag":24,"props":1363,"children":1364},{},[1365],{"type":28,"value":1366},"In this guide, we'll show you how to save your PDF to your Amazon S3 bucket using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1368,"children":1369},{},[1370],{"type":28,"value":676},{"type":23,"tag":44,"props":1372,"children":1375},{"className":1373,"code":1374,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Save PDF to Amazon S3 bucket\n    output = new\n    {\n        type = \"s3\",\n        bucket = \"your-bucket-name\",\n        key = \"path/to/document.pdf\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1376],{"type":23,"tag":36,"props":1377,"children":1378},{"__ignoreMap":8},[1379],{"type":28,"value":1374},{"type":23,"tag":24,"props":1381,"children":1382},{},[1383],{"type":28,"value":690},{"title":8,"searchDepth":61,"depth":61,"links":1385},[],"content:guides:csharp:httpwebrequest:save-your-pdf-to-your-amazon-s3-bucket.md","guides/csharp/httpwebrequest/save-your-pdf-to-your-amazon-s3-bucket.md",{"_path":1389,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":697,"description":1390,"language":11,"library":808,"property":699,"output":14,"related":1391,"default":7,"body":1392,"_type":63,"_id":1418,"_source":65,"_file":1419,"_extension":67},"/guides/csharp/httpwebrequest/send-custom-http-headers","Learn how to send custom HTTP headers when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to customize request headers.",[701,17],{"type":20,"children":1393,"toc":1416},[1394,1399,1403,1412],{"type":23,"tag":24,"props":1395,"children":1396},{},[1397],{"type":28,"value":1398},"In this guide, we'll show you how to send custom HTTP headers when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1400,"children":1401},{},[1402],{"type":28,"value":713},{"type":23,"tag":44,"props":1404,"children":1407},{"className":1405,"code":1406,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Send custom HTTP headers\n    headers = new\n    {\n        authorization = \"Bearer token123\",\n        \"user-agent\" = \"MyApp/1.0\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1408],{"type":23,"tag":36,"props":1409,"children":1410},{"__ignoreMap":8},[1411],{"type":28,"value":1406},{"type":23,"tag":24,"props":1413,"children":1414},{},[1415],{"type":28,"value":727},{"title":8,"searchDepth":61,"depth":61,"links":1417},[],"content:guides:csharp:httpwebrequest:send-custom-http-headers.md","guides/csharp/httpwebrequest/send-custom-http-headers.md",{"_path":1421,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":734,"description":1422,"language":11,"library":808,"property":736,"output":14,"related":1423,"default":7,"body":1424,"_type":63,"_id":1450,"_source":65,"_file":1451,"_extension":67},"/guides/csharp/httpwebrequest/using-cookies","Learn how to use cookies when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to manage cookies during conversion.",[701,16],{"type":20,"children":1425,"toc":1448},[1426,1431,1435,1444],{"type":23,"tag":24,"props":1427,"children":1428},{},[1429],{"type":28,"value":1430},"In this guide, we'll show you how to use cookies when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1432,"children":1433},{},[1434],{"type":28,"value":749},{"type":23,"tag":44,"props":1436,"children":1439},{"className":1437,"code":1438,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Send cookies with the request\n    cookies = new\n    {\n        sessionid = \"abc123\",\n        user = \"john_doe\"\n    }\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1440],{"type":23,"tag":36,"props":1441,"children":1442},{"__ignoreMap":8},[1443],{"type":28,"value":1438},{"type":23,"tag":24,"props":1445,"children":1446},{},[1447],{"type":28,"value":763},{"title":8,"searchDepth":61,"depth":61,"links":1449},[],"content:guides:csharp:httpwebrequest:using-cookies.md","guides/csharp/httpwebrequest/using-cookies.md",{"_path":1453,"_dir":806,"_draft":7,"_partial":7,"_locale":8,"title":770,"description":1454,"language":11,"library":808,"property":772,"output":14,"related":1455,"default":7,"body":1456,"_type":63,"_id":1482,"_source":65,"_file":1483,"_extension":67},"/guides/csharp/httpwebrequest/waiting-for-a-custom-element-to-be-ready","Learn how to wait for a custom element to be ready when converting HTML to PDF using C# and the HTTPWebRequest library. This guide offers detailed steps with code samples in C# and the HTTPWebRequest library, showing how to handle dynamic content.",[518,481],{"type":20,"children":1457,"toc":1480},[1458,1463,1467,1476],{"type":23,"tag":24,"props":1459,"children":1460},{},[1461],{"type":28,"value":1462},"In this guide, we'll show you how to wait for a custom element to be ready when converting HTML to PDF using C# and the HTTPWebRequest library.",{"type":23,"tag":24,"props":1464,"children":1465},{},[1466],{"type":28,"value":785},{"type":23,"tag":44,"props":1468,"children":1471},{"className":1469,"code":1470,"language":49,"meta":8},[47],"using System;\nusing System.Net;\nusing System.Text;\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 request = (HttpWebRequest)WebRequest.Create(\"https://api.pdfshift.io/v3/convert/pdf\");\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\nrequest.Headers.Add(\"X-API-Key\", apiKey);\n\nvar payload = new\n{\n    source = \"https://www.example.com\",\n    // Wait for a specific element to be ready\n    wait_for = \"#dynamic-content.loaded\"\n};\n\nvar json = System.Text.Json.JsonSerializer.Serialize(payload);\nbyte[] data = Encoding.UTF8.GetBytes(json);\nrequest.ContentLength = data.Length;\n\nusing (var stream = request.GetRequestStream())\n{\n    stream.Write(data, 0, data.Length);\n}\n\ntry\n{\n    var response = (HttpWebResponse)request.GetResponse();\n    \n    // Handle errors:\n    if (response.StatusCode >= HttpStatusCode.BadRequest)\n    {\n        throw new Exception($\"Request failed with status code {response.StatusCode}\");\n    }\n\n    using (var reader = new StreamReader(response.GetResponseStream()))\n    {\n        var result = reader.ReadToEnd();\n        File.WriteAllText(\"result.pdf\", result);\n    }\n\n    Console.WriteLine(\"The PDF document was generated and saved to result.pdf\");\n}\ncatch (WebException ex)\n{\n    Console.WriteLine($\"Error: {ex.Message}\");\n}\n",[1472],{"type":23,"tag":36,"props":1473,"children":1474},{"__ignoreMap":8},[1475],{"type":28,"value":1470},{"type":23,"tag":24,"props":1477,"children":1478},{},[1479],{"type":28,"value":799},{"title":8,"searchDepth":61,"depth":61,"links":1481},[],"content:guides:csharp:httpwebrequest:waiting-for-a-custom-element-to-be-ready.md","guides/csharp/httpwebrequest/waiting-for-a-custom-element-to-be-ready.md",{"_path":1485,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":1487,"language":11,"library":1488,"property":13,"output":14,"related":1489,"default":18,"body":1490,"_type":63,"_id":1522,"_source":65,"_file":1523,"_extension":67},"/guides/csharp/restsharp/accessing-secured-pages","restsharp","Learn how to access secured pages using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, highlighting how you can access page protected by basic authentication to convert them to PDF using PDFShift's API.","RestSharp",[16,17],{"type":20,"children":1491,"toc":1520},[1492,1497,1507,1516],{"type":23,"tag":24,"props":1493,"children":1494},{},[1495],{"type":28,"value":1496},"In this guide, we'll show you how to access secured page (protected by basic authentication) using C# and the RestSharp library to convert them to PDF using PDFShift's API.",{"type":23,"tag":24,"props":1498,"children":1499},{},[1500,1501,1506],{"type":28,"value":34},{"type":23,"tag":36,"props":1502,"children":1504},{"className":1503},[],[1505],{"type":28,"value":13},{"type":28,"value":42},{"type":23,"tag":44,"props":1508,"children":1511},{"className":1509,"code":1510,"language":49,"meta":8},[47],"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    // You can set a basic authentication by passing the \"auth\" property which contains a username and password\n    auth = new\n    {\n        username = \"user\",\n        password = \"password\"\n    }\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",[1512],{"type":23,"tag":36,"props":1513,"children":1514},{"__ignoreMap":8},[1515],{"type":28,"value":1510},{"type":23,"tag":24,"props":1517,"children":1518},{},[1519],{"type":28,"value":59},{"title":8,"searchDepth":61,"depth":61,"links":1521},[],"content:guides:csharp:restsharp:accessing-secured-pages.md","guides/csharp/restsharp/accessing-secured-pages.md",{"_path":1525,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":70,"description":1526,"language":11,"library":1488,"property":72,"output":14,"related":1527,"default":7,"body":1528,"_type":63,"_id":1554,"_source":65,"_file":1555,"_extension":67},"/guides/csharp/restsharp/adding-a-custom-header-or-footer","Learn how to add custom headers and footers to your PDFs using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to customize PDF appearance with headers and footers.",[74,75],{"type":20,"children":1529,"toc":1552},[1530,1535,1539,1548],{"type":23,"tag":24,"props":1531,"children":1532},{},[1533],{"type":28,"value":1534},"In this guide, we'll show you how to add custom headers and footers to your PDFs using C# and the RestSharp library.",{"type":23,"tag":24,"props":1536,"children":1537},{},[1538],{"type":28,"value":87},{"type":23,"tag":44,"props":1540,"children":1543},{"className":1541,"code":1542,"language":49,"meta":8},[47],"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    // Add custom header and footer\n    header = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Header Content\u003C/div>\",\n        height = \"20mm\"\n    },\n    footer = new\n    {\n        content = \"\u003Cdiv style='text-align: center;'>Footer Content\u003C/div>\",\n        height = \"20mm\"\n    }\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",[1544],{"type":23,"tag":36,"props":1545,"children":1546},{"__ignoreMap":8},[1547],{"type":28,"value":1542},{"type":23,"tag":24,"props":1549,"children":1550},{},[1551],{"type":28,"value":101},{"title":8,"searchDepth":61,"depth":61,"links":1553},[],"content:guides:csharp:restsharp:adding-a-custom-header-or-footer.md","guides/csharp/restsharp/adding-a-custom-header-or-footer.md",{"_path":1557,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":108,"description":1558,"language":11,"library":1488,"property":110,"output":14,"related":1559,"default":7,"body":1560,"_type":63,"_id":1586,"_source":65,"_file":1587,"_extension":67},"/guides/csharp/restsharp/adding-a-text-watermark","Learn how to add text watermarks to your PDFs using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to apply text watermarks to protect your documents.",[112,113],{"type":20,"children":1561,"toc":1584},[1562,1567,1571,1580],{"type":23,"tag":24,"props":1563,"children":1564},{},[1565],{"type":28,"value":1566},"In this guide, we'll show you how to add text watermarks to your PDFs using C# and the RestSharp library.",{"type":23,"tag":24,"props":1568,"children":1569},{},[1570],{"type":28,"value":125},{"type":23,"tag":44,"props":1572,"children":1575},{"className":1573,"code":1574,"language":49,"meta":8},[47],"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    // Add text watermark\n    watermark = new\n    {\n        text = \"CONFIDENTIAL\",\n        opacity = 0.3,\n        size = \"20px\",\n        color = \"#000000\"\n    }\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",[1576],{"type":23,"tag":36,"props":1577,"children":1578},{"__ignoreMap":8},[1579],{"type":28,"value":1574},{"type":23,"tag":24,"props":1581,"children":1582},{},[1583],{"type":28,"value":139},{"title":8,"searchDepth":61,"depth":61,"links":1585},[],"content:guides:csharp:restsharp:adding-a-text-watermark.md","guides/csharp/restsharp/adding-a-text-watermark.md",{"_path":1589,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":146,"description":1590,"language":11,"library":1488,"property":110,"output":14,"related":1591,"default":7,"body":1592,"_type":63,"_id":1618,"_source":65,"_file":1619,"_extension":67},"/guides/csharp/restsharp/adding-an-image-watermark","Learn how to add image watermarks to your PDFs using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to apply image watermarks to protect your documents.",[149,113],{"type":20,"children":1593,"toc":1616},[1594,1599,1603,1612],{"type":23,"tag":24,"props":1595,"children":1596},{},[1597],{"type":28,"value":1598},"In this guide, we'll show you how to add image watermarks to your PDFs using C# and the RestSharp library.",{"type":23,"tag":24,"props":1600,"children":1601},{},[1602],{"type":28,"value":161},{"type":23,"tag":44,"props":1604,"children":1607},{"className":1605,"code":1606,"language":49,"meta":8},[47],"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    // Add image watermark\n    watermark = new\n    {\n        image = \"https://example.com/watermark.png\",\n        opacity = 0.5,\n        position = \"center\"\n    }\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",[1608],{"type":23,"tag":36,"props":1609,"children":1610},{"__ignoreMap":8},[1611],{"type":28,"value":1606},{"type":23,"tag":24,"props":1613,"children":1614},{},[1615],{"type":28,"value":175},{"title":8,"searchDepth":61,"depth":61,"links":1617},[],"content:guides:csharp:restsharp:adding-an-image-watermark.md","guides/csharp/restsharp/adding-an-image-watermark.md",{"_path":1621,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":182,"description":1622,"language":11,"library":1488,"property":184,"output":14,"related":1623,"default":7,"body":1624,"_type":63,"_id":1650,"_source":65,"_file":1651,"_extension":67},"/guides/csharp/restsharp/avoid-conversion-on-error","Learn how to avoid conversion on error using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to handle conversion errors gracefully.",[186,187],{"type":20,"children":1625,"toc":1648},[1626,1631,1635,1644],{"type":23,"tag":24,"props":1627,"children":1628},{},[1629],{"type":28,"value":1630},"In this guide, we'll show you how to avoid conversion on error using C# and the RestSharp library.",{"type":23,"tag":24,"props":1632,"children":1633},{},[1634],{"type":28,"value":199},{"type":23,"tag":44,"props":1636,"children":1639},{"className":1637,"code":1638,"language":49,"meta":8},[47],"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    // Prevent conversion on error\n    continue_on_error = false\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",[1640],{"type":23,"tag":36,"props":1641,"children":1642},{"__ignoreMap":8},[1643],{"type":28,"value":1638},{"type":23,"tag":24,"props":1645,"children":1646},{},[1647],{"type":28,"value":213},{"title":8,"searchDepth":61,"depth":61,"links":1649},[],"content:guides:csharp:restsharp:avoid-conversion-on-error.md","guides/csharp/restsharp/avoid-conversion-on-error.md",{"_path":1653,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":220,"description":1654,"language":11,"library":1488,"property":222,"output":14,"related":1655,"default":18,"body":1656,"_type":63,"_id":1682,"_source":65,"_file":1683,"_extension":67},"/guides/csharp/restsharp/convert-html-to-pdf-from-a-url","Learn how to convert HTML from a URL 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 convert online HTML content to PDF.",[224,75],{"type":20,"children":1657,"toc":1680},[1658,1663,1667,1676],{"type":23,"tag":24,"props":1659,"children":1660},{},[1661],{"type":28,"value":1662},"In this guide, we'll show you how to convert HTML from a URL to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1664,"children":1665},{},[1666],{"type":28,"value":236},{"type":23,"tag":44,"props":1668,"children":1671},{"className":1669,"code":1670,"language":49,"meta":8},[47],"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};\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",[1672],{"type":23,"tag":36,"props":1673,"children":1674},{"__ignoreMap":8},[1675],{"type":28,"value":1670},{"type":23,"tag":24,"props":1677,"children":1678},{},[1679],{"type":28,"value":250},{"title":8,"searchDepth":61,"depth":61,"links":1681},[],"content:guides:csharp:restsharp:convert-html-to-pdf-from-a-url.md","guides/csharp/restsharp/convert-html-to-pdf-from-a-url.md",{"_path":1685,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":257,"description":1686,"language":11,"library":1488,"property":222,"output":14,"related":1687,"default":18,"body":1688,"_type":63,"_id":1714,"_source":65,"_file":1715,"_extension":67},"/guides/csharp/restsharp/convert-html-to-pdf-from-raw-html","Learn how to convert raw HTML 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 convert HTML content directly to PDF.",[260,74],{"type":20,"children":1689,"toc":1712},[1690,1695,1699,1708],{"type":23,"tag":24,"props":1691,"children":1692},{},[1693],{"type":28,"value":1694},"In this guide, we'll show you how to convert raw HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1696,"children":1697},{},[1698],{"type":28,"value":272},{"type":23,"tag":44,"props":1700,"children":1703},{"className":1701,"code":1702,"language":49,"meta":8},[47],"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 = \"\u003Chtml>\u003Cbody>\u003Ch1>Hello World\u003C/h1>\u003C/body>\u003C/html>\"\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",[1704],{"type":23,"tag":36,"props":1705,"children":1706},{"__ignoreMap":8},[1707],{"type":28,"value":1702},{"type":23,"tag":24,"props":1709,"children":1710},{},[1711],{"type":28,"value":286},{"title":8,"searchDepth":61,"depth":61,"links":1713},[],"content:guides:csharp:restsharp:convert-html-to-pdf-from-raw-html.md","guides/csharp/restsharp/convert-html-to-pdf-from-raw-html.md",{"_path":1717,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":293,"description":1718,"language":11,"library":1488,"property":295,"output":14,"related":1719,"default":7,"body":1720,"_type":63,"_id":1746,"_source":65,"_file":1747,"_extension":67},"/guides/csharp/restsharp/define-a-time-limit","Learn how to define a time limit for PDF conversions using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to set timeouts to prevent long-running conversions.",[297,186],{"type":20,"children":1721,"toc":1744},[1722,1727,1731,1740],{"type":23,"tag":24,"props":1723,"children":1724},{},[1725],{"type":28,"value":1726},"In this guide, we'll show you how to define a time limit for PDF conversions using C# and the RestSharp library.",{"type":23,"tag":24,"props":1728,"children":1729},{},[1730],{"type":28,"value":309},{"type":23,"tag":44,"props":1732,"children":1735},{"className":1733,"code":1734,"language":49,"meta":8},[47],"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\");\nclient.Timeout = 30000; // 30 seconds timeout\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    // Set a timeout in seconds\n    timeout = 30\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",[1736],{"type":23,"tag":36,"props":1737,"children":1738},{"__ignoreMap":8},[1739],{"type":28,"value":1734},{"type":23,"tag":24,"props":1741,"children":1742},{},[1743],{"type":28,"value":323},{"title":8,"searchDepth":61,"depth":61,"links":1745},[],"content:guides:csharp:restsharp:define-a-time-limit.md","guides/csharp/restsharp/define-a-time-limit.md",{"_path":1749,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":330,"description":1750,"language":11,"library":1488,"property":332,"output":14,"related":1751,"default":7,"body":1752,"_type":63,"_id":1778,"_source":65,"_file":1779,"_extension":67},"/guides/csharp/restsharp/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.",[334,335],{"type":20,"children":1753,"toc":1776},[1754,1759,1763,1772],{"type":23,"tag":24,"props":1755,"children":1756},{},[1757],{"type":28,"value":1758},"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":23,"tag":24,"props":1760,"children":1761},{},[1762],{"type":28,"value":347},{"type":23,"tag":44,"props":1764,"children":1767},{"className":1765,"code":1766,"language":49,"meta":8},[47],"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",[1768],{"type":23,"tag":36,"props":1769,"children":1770},{"__ignoreMap":8},[1771],{"type":28,"value":1766},{"type":23,"tag":24,"props":1773,"children":1774},{},[1775],{"type":28,"value":361},{"title":8,"searchDepth":61,"depth":61,"links":1777},[],"content:guides:csharp:restsharp:exporting-only-a-specific-set-of-pages.md","guides/csharp/restsharp/exporting-only-a-specific-set-of-pages.md",{"_path":1781,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":368,"description":1782,"language":11,"library":1488,"property":370,"output":14,"related":1783,"default":7,"body":1784,"_type":63,"_id":1810,"_source":65,"_file":1811,"_extension":67},"/guides/csharp/restsharp/generate-a-document-with-full-height","Learn how to generate a document with full height using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to create full-height PDFs.",[372,335],{"type":20,"children":1785,"toc":1808},[1786,1791,1795,1804],{"type":23,"tag":24,"props":1787,"children":1788},{},[1789],{"type":28,"value":1790},"In this guide, we'll show you how to generate a document with full height using C# and the RestSharp library.",{"type":23,"tag":24,"props":1792,"children":1793},{},[1794],{"type":28,"value":384},{"type":23,"tag":44,"props":1796,"children":1799},{"className":1797,"code":1798,"language":49,"meta":8},[47],"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    // Generate document with full height\n    full_height = true\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",[1800],{"type":23,"tag":36,"props":1801,"children":1802},{"__ignoreMap":8},[1803],{"type":28,"value":1798},{"type":23,"tag":24,"props":1805,"children":1806},{},[1807],{"type":28,"value":398},{"title":8,"searchDepth":61,"depth":61,"links":1809},[],"content:guides:csharp:restsharp:generate-a-document-with-full-height.md","guides/csharp/restsharp/generate-a-document-with-full-height.md",{"_path":1813,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":405,"description":1814,"language":11,"library":1488,"property":407,"output":14,"related":1815,"default":7,"body":1816,"_type":63,"_id":1842,"_source":65,"_file":1843,"_extension":67},"/guides/csharp/restsharp/loading-css-from-a-string","Learn how to load CSS from a string when converting HTML 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 apply inline CSS styling.",[75,409],{"type":20,"children":1817,"toc":1840},[1818,1823,1827,1836],{"type":23,"tag":24,"props":1819,"children":1820},{},[1821],{"type":28,"value":1822},"In this guide, we'll show you how to load CSS from a string when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1824,"children":1825},{},[1826],{"type":28,"value":421},{"type":23,"tag":44,"props":1828,"children":1831},{"className":1829,"code":1830,"language":49,"meta":8},[47],"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    // Load CSS from a string\n    css = \"body { font-family: Arial; } h1 { color: blue; }\"\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",[1832],{"type":23,"tag":36,"props":1833,"children":1834},{"__ignoreMap":8},[1835],{"type":28,"value":1830},{"type":23,"tag":24,"props":1837,"children":1838},{},[1839],{"type":28,"value":435},{"title":8,"searchDepth":61,"depth":61,"links":1841},[],"content:guides:csharp:restsharp:loading-css-from-a-string.md","guides/csharp/restsharp/loading-css-from-a-string.md",{"_path":1845,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":442,"description":1846,"language":11,"library":1488,"property":407,"output":14,"related":1847,"default":7,"body":1848,"_type":63,"_id":1874,"_source":65,"_file":1875,"_extension":67},"/guides/csharp/restsharp/loading-css-from-a-url","Learn how to load CSS from a URL when converting HTML 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 reference external CSS files.",[74,260],{"type":20,"children":1849,"toc":1872},[1850,1855,1859,1868],{"type":23,"tag":24,"props":1851,"children":1852},{},[1853],{"type":28,"value":1854},"In this guide, we'll show you how to load CSS from a URL when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1856,"children":1857},{},[1858],{"type":28,"value":456},{"type":23,"tag":44,"props":1860,"children":1863},{"className":1861,"code":1862,"language":49,"meta":8},[47],"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    // Load CSS from a URL\n    css = \"https://example.com/styles.css\"\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",[1864],{"type":23,"tag":36,"props":1865,"children":1866},{"__ignoreMap":8},[1867],{"type":28,"value":1862},{"type":23,"tag":24,"props":1869,"children":1870},{},[1871],{"type":28,"value":470},{"title":8,"searchDepth":61,"depth":61,"links":1873},[],"content:guides:csharp:restsharp:loading-css-from-a-url.md","guides/csharp/restsharp/loading-css-from-a-url.md",{"_path":1877,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":477,"description":1878,"language":11,"library":1488,"property":479,"output":14,"related":1879,"default":7,"body":1880,"_type":63,"_id":1906,"_source":65,"_file":1907,"_extension":67},"/guides/csharp/restsharp/loading-javascript-from-a-string","Learn how to load JavaScript from a string when converting HTML 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 include inline JavaScript.",[481,482],{"type":20,"children":1881,"toc":1904},[1882,1887,1891,1900],{"type":23,"tag":24,"props":1883,"children":1884},{},[1885],{"type":28,"value":1886},"In this guide, we'll show you how to load JavaScript from a string when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1888,"children":1889},{},[1890],{"type":28,"value":494},{"type":23,"tag":44,"props":1892,"children":1895},{"className":1893,"code":1894,"language":49,"meta":8},[47],"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    // Load JavaScript from a string\n    javascript = \"document.body.style.backgroundColor = 'red';\"\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",[1896],{"type":23,"tag":36,"props":1897,"children":1898},{"__ignoreMap":8},[1899],{"type":28,"value":1894},{"type":23,"tag":24,"props":1901,"children":1902},{},[1903],{"type":28,"value":508},{"title":8,"searchDepth":61,"depth":61,"links":1905},[],"content:guides:csharp:restsharp:loading-javascript-from-a-string.md","guides/csharp/restsharp/loading-javascript-from-a-string.md",{"_path":1909,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":515,"description":1910,"language":11,"library":1488,"property":479,"output":14,"related":1911,"default":7,"body":1912,"_type":63,"_id":1938,"_source":65,"_file":1939,"_extension":67},"/guides/csharp/restsharp/loading-javascript-from-a-url","Learn how to load JavaScript from a URL when converting HTML 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 reference external JavaScript files.",[518,482],{"type":20,"children":1913,"toc":1936},[1914,1919,1923,1932],{"type":23,"tag":24,"props":1915,"children":1916},{},[1917],{"type":28,"value":1918},"In this guide, we'll show you how to load JavaScript from a URL when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":1920,"children":1921},{},[1922],{"type":28,"value":530},{"type":23,"tag":44,"props":1924,"children":1927},{"className":1925,"code":1926,"language":49,"meta":8},[47],"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    // Load JavaScript from a URL\n    javascript = \"https://example.com/script.js\"\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",[1928],{"type":23,"tag":36,"props":1929,"children":1930},{"__ignoreMap":8},[1931],{"type":28,"value":1926},{"type":23,"tag":24,"props":1933,"children":1934},{},[1935],{"type":28,"value":544},{"title":8,"searchDepth":61,"depth":61,"links":1937},[],"content:guides:csharp:restsharp:loading-javascript-from-a-url.md","guides/csharp/restsharp/loading-javascript-from-a-url.md",{"_path":1941,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":551,"description":1942,"language":11,"library":1488,"property":553,"output":14,"related":1943,"default":7,"body":1944,"_type":63,"_id":1970,"_source":65,"_file":1971,"_extension":67},"/guides/csharp/restsharp/protecting-the-generated-pdf","Learn how to protect generated PDFs with passwords using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to secure your PDF documents.",[112,149],{"type":20,"children":1945,"toc":1968},[1946,1951,1955,1964],{"type":23,"tag":24,"props":1947,"children":1948},{},[1949],{"type":28,"value":1950},"In this guide, we'll show you how to protect generated PDFs with passwords using C# and the RestSharp library.",{"type":23,"tag":24,"props":1952,"children":1953},{},[1954],{"type":28,"value":566},{"type":23,"tag":44,"props":1956,"children":1959},{"className":1957,"code":1958,"language":49,"meta":8},[47],"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    // Protect the PDF with a password\n    protection = new\n    {\n        user_password = \"user123\",\n        owner_password = \"owner123\"\n    }\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",[1960],{"type":23,"tag":36,"props":1961,"children":1962},{"__ignoreMap":8},[1963],{"type":28,"value":1958},{"type":23,"tag":24,"props":1965,"children":1966},{},[1967],{"type":28,"value":580},{"title":8,"searchDepth":61,"depth":61,"links":1969},[],"content:guides:csharp:restsharp:protecting-the-generated-pdf.md","guides/csharp/restsharp/protecting-the-generated-pdf.md",{"_path":1973,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":587,"description":1974,"language":11,"library":1488,"property":589,"output":14,"related":1975,"default":7,"body":1976,"_type":63,"_id":2002,"_source":65,"_file":2003,"_extension":67},"/guides/csharp/restsharp/receive-a-webhook-event","Learn how to receive webhook events when PDF conversion is complete using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to handle asynchronous conversion notifications.",[335,297],{"type":20,"children":1977,"toc":2000},[1978,1983,1987,1996],{"type":23,"tag":24,"props":1979,"children":1980},{},[1981],{"type":28,"value":1982},"In this guide, we'll show you how to receive webhook events when PDF conversion is complete using C# and the RestSharp library.",{"type":23,"tag":24,"props":1984,"children":1985},{},[1986],{"type":28,"value":602},{"type":23,"tag":44,"props":1988,"children":1991},{"className":1989,"code":1990,"language":49,"meta":8},[47],"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    // Set up webhook notification\n    webhook = new\n    {\n        url = \"https://your-server.com/webhook\",\n        secret = \"your-secret-key\"\n    }\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",[1992],{"type":23,"tag":36,"props":1993,"children":1994},{"__ignoreMap":8},[1995],{"type":28,"value":1990},{"type":23,"tag":24,"props":1997,"children":1998},{},[1999],{"type":28,"value":616},{"title":8,"searchDepth":61,"depth":61,"links":2001},[],"content:guides:csharp:restsharp:receive-a-webhook-event.md","guides/csharp/restsharp/receive-a-webhook-event.md",{"_path":2005,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":623,"description":2006,"language":11,"library":1488,"property":625,"output":626,"related":2007,"default":7,"body":2008,"_type":63,"_id":2034,"_source":65,"_file":2035,"_extension":67},"/guides/csharp/restsharp/save-your-pdf-online-and-get-back-a-url","Learn how to save your PDF online and get back a URL using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to store PDFs in cloud storage and retrieve URLs.",[628,187],{"type":20,"children":2009,"toc":2032},[2010,2015,2019,2028],{"type":23,"tag":24,"props":2011,"children":2012},{},[2013],{"type":28,"value":2014},"In this guide, we'll show you how to save your PDF online and get back a URL using C# and the RestSharp library.",{"type":23,"tag":24,"props":2016,"children":2017},{},[2018],{"type":28,"value":640},{"type":23,"tag":44,"props":2020,"children":2023},{"className":2021,"code":2022,"language":49,"meta":8},[47],"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    // Save PDF to cloud storage and get URL\n    output = new\n    {\n        type = \"url\",\n        url = \"https://your-storage.com/\"\n    }\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",[2024],{"type":23,"tag":36,"props":2025,"children":2026},{"__ignoreMap":8},[2027],{"type":28,"value":2022},{"type":23,"tag":24,"props":2029,"children":2030},{},[2031],{"type":28,"value":654},{"title":8,"searchDepth":61,"depth":61,"links":2033},[],"content:guides:csharp:restsharp:save-your-pdf-online-and-get-back-a-url.md","guides/csharp/restsharp/save-your-pdf-online-and-get-back-a-url.md",{"_path":2037,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":661,"description":2038,"language":11,"library":1488,"property":625,"output":663,"related":2039,"default":7,"body":2040,"_type":63,"_id":2066,"_source":65,"_file":2067,"_extension":67},"/guides/csharp/restsharp/save-your-pdf-to-your-amazon-s3-bucket","Learn how to save your PDF to your Amazon S3 bucket using C# and the RestSharp library. This guide offers detailed steps with code samples in C# and the RestSharp library, showing how to store PDFs directly in AWS S3.",[335,187],{"type":20,"children":2041,"toc":2064},[2042,2047,2051,2060],{"type":23,"tag":24,"props":2043,"children":2044},{},[2045],{"type":28,"value":2046},"In this guide, we'll show you how to save your PDF to your Amazon S3 bucket using C# and the RestSharp library.",{"type":23,"tag":24,"props":2048,"children":2049},{},[2050],{"type":28,"value":676},{"type":23,"tag":44,"props":2052,"children":2055},{"className":2053,"code":2054,"language":49,"meta":8},[47],"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    // Save PDF to Amazon S3 bucket\n    output = new\n    {\n        type = \"s3\",\n        bucket = \"your-bucket-name\",\n        key = \"path/to/document.pdf\"\n    }\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",[2056],{"type":23,"tag":36,"props":2057,"children":2058},{"__ignoreMap":8},[2059],{"type":28,"value":2054},{"type":23,"tag":24,"props":2061,"children":2062},{},[2063],{"type":28,"value":690},{"title":8,"searchDepth":61,"depth":61,"links":2065},[],"content:guides:csharp:restsharp:save-your-pdf-to-your-amazon-s3-bucket.md","guides/csharp/restsharp/save-your-pdf-to-your-amazon-s3-bucket.md",{"_path":2069,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":697,"description":2070,"language":11,"library":1488,"property":699,"output":14,"related":2071,"default":7,"body":2072,"_type":63,"_id":2098,"_source":65,"_file":2099,"_extension":67},"/guides/csharp/restsharp/send-custom-http-headers","Learn how to send custom HTTP headers when converting HTML 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 customize request headers.",[701,17],{"type":20,"children":2073,"toc":2096},[2074,2079,2083,2092],{"type":23,"tag":24,"props":2075,"children":2076},{},[2077],{"type":28,"value":2078},"In this guide, we'll show you how to send custom HTTP headers when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":2080,"children":2081},{},[2082],{"type":28,"value":713},{"type":23,"tag":44,"props":2084,"children":2087},{"className":2085,"code":2086,"language":49,"meta":8},[47],"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    // Send custom HTTP headers\n    headers = new\n    {\n        authorization = \"Bearer token123\",\n        \"user-agent\" = \"MyApp/1.0\"\n    }\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",[2088],{"type":23,"tag":36,"props":2089,"children":2090},{"__ignoreMap":8},[2091],{"type":28,"value":2086},{"type":23,"tag":24,"props":2093,"children":2094},{},[2095],{"type":28,"value":727},{"title":8,"searchDepth":61,"depth":61,"links":2097},[],"content:guides:csharp:restsharp:send-custom-http-headers.md","guides/csharp/restsharp/send-custom-http-headers.md",{"_path":2101,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":734,"description":2102,"language":11,"library":1488,"property":736,"output":14,"related":2103,"default":7,"body":2104,"_type":63,"_id":2130,"_source":65,"_file":2131,"_extension":67},"/guides/csharp/restsharp/using-cookies","Learn how to use cookies when converting HTML 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 manage cookies during conversion.",[701,16],{"type":20,"children":2105,"toc":2128},[2106,2111,2115,2124],{"type":23,"tag":24,"props":2107,"children":2108},{},[2109],{"type":28,"value":2110},"In this guide, we'll show you how to use cookies when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":2112,"children":2113},{},[2114],{"type":28,"value":749},{"type":23,"tag":44,"props":2116,"children":2119},{"className":2117,"code":2118,"language":49,"meta":8},[47],"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    // Send cookies with the request\n    cookies = new\n    {\n        sessionid = \"abc123\",\n        user = \"john_doe\"\n    }\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",[2120],{"type":23,"tag":36,"props":2121,"children":2122},{"__ignoreMap":8},[2123],{"type":28,"value":2118},{"type":23,"tag":24,"props":2125,"children":2126},{},[2127],{"type":28,"value":763},{"title":8,"searchDepth":61,"depth":61,"links":2129},[],"content:guides:csharp:restsharp:using-cookies.md","guides/csharp/restsharp/using-cookies.md",{"_path":2133,"_dir":1486,"_draft":7,"_partial":7,"_locale":8,"title":770,"description":2134,"language":11,"library":1488,"property":772,"output":14,"related":2135,"default":7,"body":2136,"_type":63,"_id":2162,"_source":65,"_file":2163,"_extension":67},"/guides/csharp/restsharp/waiting-for-a-custom-element-to-be-ready","Learn how to wait for a custom element to be ready when converting HTML 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 handle dynamic content.",[518,481],{"type":20,"children":2137,"toc":2160},[2138,2143,2147,2156],{"type":23,"tag":24,"props":2139,"children":2140},{},[2141],{"type":28,"value":2142},"In this guide, we'll show you how to wait for a custom element to be ready when converting HTML to PDF using C# and the RestSharp library.",{"type":23,"tag":24,"props":2144,"children":2145},{},[2146],{"type":28,"value":785},{"type":23,"tag":44,"props":2148,"children":2151},{"className":2149,"code":2150,"language":49,"meta":8},[47],"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    // Wait for a specific element to be ready\n    wait_for = \"#dynamic-content.loaded\"\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",[2152],{"type":23,"tag":36,"props":2153,"children":2154},{"__ignoreMap":8},[2155],{"type":28,"value":2150},{"type":23,"tag":24,"props":2157,"children":2158},{},[2159],{"type":28,"value":799},{"title":8,"searchDepth":61,"depth":61,"links":2161},[],"content:guides:csharp:restsharp:waiting-for-a-custom-element-to-be-ready.md","guides/csharp/restsharp/waiting-for-a-custom-element-to-be-ready.md",1785426825034]