Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 24, 2023 14:04
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/09cf8aabec15018a8cd7ccee37319c79 to your computer and use it in GitHub Desktop.
Save bjoerntx/09cf8aabec15018a8cd7ccee37319c79 to your computer and use it in GitHub Desktop.
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.FontSettings.EmbeddableFontsOnly = true;
tx.FontSettings.AdaptFontEvent = false;
tx.AdaptFont += Tx_AdaptFont;
TXTextControl.Selection selection = new TXTextControl.Selection();
selection.Text = "Hello, PDF/A!";
selection.FontSize = 360;
selection.FontName = "Celtic Garamond the 2nd";
selection.ForeColor = System.Drawing.Color.Red;
tx.Selection = selection;
try
{
tx.Save("output.pdf", TXTextControl.StreamType.AdobePDFA);
} catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
void Tx_AdaptFont(object sender, TXTextControl.AdaptFontEventArgs e)
{
if (e.FontName == "Celtic Garamond the 2nd")
{
e.AdaptedFontName = "Arial";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment