Last active
August 26, 2021 16:16
-
-
Save bjoerntx/5496d4f9e4dd5eab51fd3d0b69c07b1a 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
[HttpPost] | |
public string ExportPDF(string document) | |
{ | |
byte[] bPDF; | |
// create temporary ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
// load the document | |
tx.Load(Convert.FromBase64String(document), | |
TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
X509Certificate2 cert = new X509Certificate2( | |
Server.MapPath("~/App_Data/textcontrolself.cer")); | |
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() | |
{ | |
CreatorApplication = "TX Text Control Sample Application", | |
DigitalSignature = new TXTextControl.DigitalSignature(cert, null) | |
}; | |
// save the document as PDF | |
tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDFA, saveSettings); | |
} | |
// return as Base64 encoded string | |
return Convert.ToBase64String(bPDF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment