Skip to content

Instantly share code, notes, and snippets.

@piccaso
Created November 19, 2019 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piccaso/d5ab118fc412772fe963f59aacfc7080 to your computer and use it in GitHub Desktop.
Save piccaso/d5ab118fc412772fe963f59aacfc7080 to your computer and use it in GitHub Desktop.
using gotenberg from dot net (c#)
using var client = new HttpClient {BaseAddress = new Uri("https://localhost:3000/")};
using var content = new MultipartFormDataContent {
{new StringContent(html), "files", "index.html"},
{new StringContent("8.27"), "paperWidth"},
{new StringContent("11.69"), "paperHeight"},
{new StringContent("0"), "marginTop"},
{new StringContent("0"), "marginBottom"},
{new StringContent("0"), "marginLeft"},
{new StringContent("0"), "marginRight"},
{new StringContent("true"), "landscape"}
};
using var response = await client.PostAsync("convert/html", content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment