Created
June 23, 2020 07:11
-
-
Save bjoerntx/0491846a64eddad0daf46f927d956f48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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