Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active June 30, 2020 11:39
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/600adf61d5deaf3e07e44423d112e9b2 to your computer and use it in GitHub Desktop.
Save bjoerntx/600adf61d5deaf3e07e44423d112e9b2 to your computer and use it in GitHub Desktop.
[HttpPost]
public string ExportPDF(string document)
{
byte[] bPDF;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load(Convert.FromBase64String(document),
TXTextControl.BinaryStreamType.InternalUnicodeFormat);
X509Certificate2 cert = new X509Certificate2
(Server.MapPath("~/App_Data/textcontrolself.pfx"),
"yourpassword");
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings()
{
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