Created
October 24, 2023 14:04
-
-
Save bjoerntx/09cf8aabec15018a8cd7ccee37319c79 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
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