Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 23, 2020 07:11
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 bjoerntx/0491846a64eddad0daf46f927d956f48 to your computer and use it in GitHub Desktop.
Save bjoerntx/0491846a64eddad0daf46f927d956f48 to your computer and use it in GitHub Desktop.
[Route("api/[controller]")]
[ApiController]
public class DocumentController : ControllerBase
{
[HttpGet]
[Route("CreatePdf")]
public ActionResult<string> CreatePdf(string Html)
{
using (TXTextControl.ServerTextControl tx =
new TXTextControl.ServerTextControl())
{
byte[] data;
tx.Create();
// load the Html content
tx.Load(Html, TXTextControl.StringStreamType.HTMLFormat);
// save the document as PDF
tx.Save(out data, TXTextControl.BinaryStreamType.AdobePDF);
return Convert.ToBase64String(data); // return PDF as base64 string
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment