Created
February 11, 2022 11:28
-
-
Save bjoerntx/69045d8305ccb1ea335307fd7265e2fb 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
public IActionResult CreatePDF() | |
{ | |
// new non-UI ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// create a selection object | |
TXTextControl.Selection selection = new TXTextControl.Selection() { | |
FontSize = 1000, | |
Text = "Welcome to Text Control", | |
Bold = true, | |
ForeColor = System.Drawing.Color.DarkRed | |
}; | |
// apply the selection | |
tx.Selection = selection; | |
// save the document into a byte array | |
byte[] document; | |
tx.Save(out document, TXTextControl.BinaryStreamType.AdobePDF); | |
// create and return a file | |
MemoryStream stream = new MemoryStream(document); | |
stream.Position = 0; | |
FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf"); | |
fileStreamResult.FileDownloadName = "results.pdf"; | |
return fileStreamResult; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment