Write Text To PDF
View as MarkdownDemonstrates writing text as PDF text.
Code Snippet
using (var writer = new PdfWriter("TextToPDF.pdf"))
{
int width = 350;
int height = 200;
using (var graphics = writer.GetGraphics())
{
// Text objects will be saved as a PDF text with embedded fonts.
// The only type of text that can't be saved as text is DoublePath text.
writer.TextOutputMode = PdfTextOutputMode.Text;
writer.AddPage(width, height, RgbColor.White);
var font = graphics.CreateFont("Arial", 18f);
// Plain text
var plainText = new PlainText("plain text", font, new SolidBrush(RgbColor.Black), 95f, 41f, TextAlignment.Center);
graphics.DrawText(plainText);
// Round text
var roundText = new Aurigma.GraphicsMill.Drawing.Art.RoundText("round text", font)
{
Center = new System.Drawing.PointF(width / 2.0f, height / 2.0f),
Bend = 0.5f,
};
graphics.DrawText(roundText);
}
}
Output
TextToPDF.pdf
DownloadTextToPDF.png
Used APIs
- Aurigma.GraphicsMill.Codecs.PdfTextOutputMode
- Aurigma.GraphicsMill.Codecs.PdfWriter
- Aurigma.GraphicsMill.Codecs.PdfWriter.AddPage(Single,Single,Color)
- Aurigma.GraphicsMill.Codecs.PdfWriter.GetGraphics
- Aurigma.GraphicsMill.Codecs.PdfWriter.TextOutputMode
- Aurigma.GraphicsMill.Drawing.Art.ArtText.Center
- Aurigma.GraphicsMill.Drawing.Art.RoundText
- Aurigma.GraphicsMill.Drawing.Art.RoundText.Bend
- Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)
- Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)
- Aurigma.GraphicsMill.Drawing.PlainText
- Aurigma.GraphicsMill.Drawing.SolidBrush
- Aurigma.GraphicsMill.Drawing.TextAlignment