- Add a link to PDF with an external destination
- Add a link with an internal destination to PDF
- Add a note to PDF
- Add barcodes to PDF
- Add bookmarks to PDF
- Add footer to PDF
- Add simple html text to PDF
- Add hyperlink to PDF
- Add Long Term Validation (LTV) data to an existing signature
- Add multiline text to a PDF document
- Add a rubber stamp annotation with a custom icon
- Add single-line text to PDF
- Add Stamp to PDF
- Add tags to existing PDF
- Add text field to PDF
- Add a Diagonal Watermark to PDF in C# - TallComponents - PDF Library
- pdfkit5 - detailed changes to the API - Tall Components
- Append two or more existing PDF files
- Change the color inside a PDF
- Change the formatting of a numeric field
- Change page orientation PDF
- Clip PDF page content in C#
- .NET Core console app on MacOS
- Convert PDF to plain text
- Convert SVG to PDF
- Create a text annotation in PDF with rich text
- Create formfields in PDF documents
- Create a new digitally signed PDF document
- Create rectangles with rounded corners
- Create tagged PDF
- Create text with decorations
- How to create a tiling for shapes in PDF
- Crop content on a PDF page
- Determine the content bounding box
- Determine if a PDF only contains images
- Digitally sign a PDF form in C# or VB.NET
- Disable submit button after submitting
- How to downscale all images in a PDF
- Download and convert image to PDF
- How to downscale all images in a PDF
- Vector graphics in PDF
- Fill XFA form and export XDP data
- Fill and save dynamic XFA form
- Merge XDP data with dynamic XFA form
- Dynamic XFA
- How to embed files in a PDF document
- Embed TrueType font in PDF
- EMF to PDF as vector image
- Export FDF from PDF form
- Extract embedded files from PDF
- Extract glyph boxes from PDF
- Extract glyphs and sort by reading order
- Extract graphics from PDF
- Extract images from PDF
- Fill in a template PDF document
- Fill PDF form
- Fit image to PDF page
- Flatten Markup Annotation
- Flatten PDF form
- How to generate and export certificates
- How do I extract page destinations from bookmarks?
- Highlight fields in PDF
- How to add autosized text to PDF
- How to sign and verify updates to a PDF document
- Import FDF into PDF
- Licensing and .NET Standard
- Merge PDF files in C# .NET
- How to mirror PDF pages and other shapes
- Layout text with MultilineTextShape
- pdfkit5 and .NET Core
- pdfkit5 .NET Standard API
- Read and write meta data from PDF
- Read PDF tags
- How to reduce PDF file size
- Reduce PDF size
- Remove graphics from PDF
- Remove PDF security settings
- Replace field with image
- Resize PDF pages
- Rotate a PDF page
- How to scale content of PDF
- Search text in PDF
- PDF Viewer Preferences
- Create a custom signature handler to sign and verify PDF documents
- Split PDF pages in C# and VB.NET
- Tagged PDF
- TIFF to PDF C#
- Translate PDF page content
- Use multiple licenses
- Use TrueType font collections
- Write Document to HttpResponse
- Use pdfkit5 with a Xamarin.Forms app
- pdfkit5 and Xamarin
Create text with decorations
Create a document with text with decorations like gradient color, shadow, emboss and glow
Gradients
With CreatePaths of the TALLcomponents PDF kit you can get the paths of any glyph of any font (these paths are the outline information, it is used to draw a glyph). Using these paths, you can use the pen and brush to add some decoration to what normally be just a plain text. In this example a pen and a gradient brush is used to give text a little more color:
Color colorPen = new RgbColor(0, 100, 0);
Color colorTop = new RgbColor(240, 230, 140);
Color colorBottom = new RgbColor(85, 107, 47);
Brush brush = new AxialGradientBrush(colorBottom , colorTop, 0, 0, 0, size);
Pen pen = new Pen(colorPen, 1);
FreeHandShape charAsShape = new FreeHandShape { Pen = pen, Brush = brush };
charAsShape.Paths.AddRange(usedFont.CreatePaths('b', size));
Dim colorPen As Color = New RgbColor(0, 100, 0)
Dim colorTop As Color = New RgbColor(240, 230, 140)
Dim colorBottom As Color = New RgbColor(85, 107, 47)
Dim brush As Brush = New AxialGradientBrush(colorBottom, colorTop, 0, 0, 0, size)
Dim pen As New Pen(colorPen, 1)
Dim charAsShape As New FreeHandShape() With { _
Key .Pen = pen, _
Key .Brush = brush _
}
charAsShape.Paths.AddRange(usedFont.CreatePaths("b"C, size))
Shadow
Of course, these paths can be added twice to the PDF document, so that there are to glyphs on top of each other. If the bottom one is scaled a bit, moved a little to right down and painted with shadow colors the result will be a text with shadows like:
Apply a transformation on the paths of the glyphs this way:
// scale and position the bottom glyph that is the shadow
charAsShape.Transform = new TransformCollection
{
new ScaleTransform(1.04, 1.04),
new TranslateTransform(2, 3)
};
' scale and position the bottom glyph that is the shadow
charAsShape.Transform = New TransformCollection() From { _
New ScaleTransform(1.04, 1.04), _
New TranslateTransform(2, 3) _
}
Emboss
You can create an emboss effect with three glyphs on top of each other:
- First draw a background rectangle around the text using the text color.
- Then oversize the text by using a dark fat pen, this will be the shadow part.
- Next, overwrite parts of the shadow with highlight color, slightly moved down-right.
- Finally draw the actual text on top with solid color.
What you get is:
Glow
With many glyphs on top of each other you can create a glow effect. Draw several layes of the same text, the lower layers are increasingly fattened (using a thicker pensize), and are increasingly more transparent:
ShapeCollection shapes = new ShapeCollection(0, 0, 100, 50);
double[] Opacities = { 255, 128, 64, 32, 16, 8, 4 };
const double overSizeStep = 1.4;
double offsetY = usedFont.BaselineOffset * fontsize;
double offsetX = 4;
foreach (char c in text)
{
FreeHandPathCollection glyphPaths = usedFont.CreatePaths(c, fontsize);
for (int i = 6; i >= 0; i--)
{
FreeHandShape charStack = new FreeHandShape();
if (i == 0) charStack.Brush = new SolidBrush(colorText);
charStack.Opacity = Opacities[i];
charStack.Pen = new Pen(colorGlow, 1 + (i * overSizeStep));
charStack.Pen.MiterLimit = 4;
charStack.Paths.AddRange(glyphPaths);
charStack.Transform = new TranslateTransform(offsetX, offsetY);
shapes.Add(charStack);
}
offsetX += usedFont.CalculateWidth(c.ToString(), fontsize);
}
Dim shapes As New ShapeCollection(0, 0, 100, 50)
Dim Opacities As Double() = {255, 128, 64, 32, 16, 8, _
4}
Const overSizeStep As Double = 1.4
Dim offsetY As Double = usedFont.BaselineOffset * fontsize
Dim offsetX As Double = 4
For Each c As Char In text
Dim glyphPaths As FreeHandPathCollection = usedFont.CreatePaths(c, fontsize)
For i As Integer = 6 To 0 Step -1
Dim charStack As New FreeHandShape()
If i = 0 Then
charStack.Brush = New SolidBrush(colorText)
End If
charStack.Opacity = Opacities(i)
charStack.Pen = New Pen(colorGlow, 1 + (i * overSizeStep))
charStack.Pen.MiterLimit = 4
charStack.Paths.AddRange(glyphPaths)
charStack.Transform = New TranslateTransform(offsetX, offsetY)
shapes.Add(charStack)
Next
offsetX += usedFont.CalculateWidth(c.ToString(), fontsize)
Next
Inverse
Of course it does not have to end here. You can draw a rectangle around the the glyphs and experiment with the FillRule, this way you get a opaque box with transparent text in it:
ShapeCollection shapes = new ShapeCollection(0, 0, 100, 50);
int size = 48;
Font font = Font.HelveticaBold;
Color colorPen = new RgbColor(0, 100, 0);
Color colorTop = new RgbColor(240, 230, 140);
Color colorBottom = new RgbColor(85, 107, 47);
Pen pen = new Pen(colorPen, 1);
Brush brush = new AxialGradientBrush(colorBottom, colorTop, 0, 0, 0, Size);
double offsetX = 0;
double offsetY = font.BaselineOffset * size;
RectangleShape outline = new RectangleShape(0, 0, width, height);
outline.Pen = new Pen(colorPen);
foreach (char c in "seethrough")
{
double width = font.CalculateWidth(c.ToString(), size);
double height = font.CalculateHeight(c.ToString(), size, width);
FreeHandShape charAsShape = new FreeHandShape { Brush = brush };
FreeHandPath glyphbox = new FreeHandPath(true);
glyphbox.Segments.Add(new FreeHandStartSegment(0, -offsetY));
glyphbox.Segments.Add(new FreeHandLineSegment(width + 0.5, -offsetY));
glyphbox.Segments.Add(new FreeHandLineSegment(width + 0.5, size));
glyphbox.Segments.Add(new FreeHandLineSegment(0, size));
charAsShape.Paths.Add(glyphbox);
charAsShape.Paths.AddRange(font.CreatePaths(c, size));
charAsShape.Transform = new TransformCollection() { new TranslateTransform(offsetX, offsetY)};
charAsShape.FillRule = FillRule.EvenOdd;
shapes.Add(charAsShape);
offsetX += width;
}
shapes.Add(outline);
Dim shapes As New ShapeCollection(0, 0, 100, 50)
Dim size__1 As Integer = 48
Dim font__2 As Font = Font.HelveticaBold
Dim colorPen As Color = New RgbColor(0, 100, 0)
Dim colorTop As Color = New RgbColor(240, 230, 140)
Dim colorBottom As Color = New RgbColor(85, 107, 47)
Dim pen As New Pen(colorPen, 1)
Dim brush As Brush = New AxialGradientBrush(colorBottom, colorTop, 0, 0, 0, Size)
Dim offsetX As Double = 0
Dim offsetY As Double = font__2.BaselineOffset * size__1
Dim outline As New RectangleShape(0, 0, width, height)
outline.Pen = New Pen(colorPen)
For Each c As Char In "seethrough"
Dim width As Double = font__2.CalculateWidth(c.ToString(), size__1)
Dim height As Double = font__2.CalculateHeight(c.ToString(), size__1, width)
Dim charAsShape As New FreeHandShape() With { _
Key .Brush = brush _
}
Dim glyphbox As New FreeHandPath(True)
glyphbox.Segments.Add(New FreeHandStartSegment(0, -offsetY))
glyphbox.Segments.Add(New FreeHandLineSegment(width + 0.5, -offsetY))
glyphbox.Segments.Add(New FreeHandLineSegment(width + 0.5, size__1))
glyphbox.Segments.Add(New FreeHandLineSegment(0, size__1))
charAsShape.Paths.Add(glyphbox)
charAsShape.Paths.AddRange(font__2.CreatePaths(c, size__1))
charAsShape.Transform = New TransformCollection() From { _
New TranslateTransform(offsetX, offsetY) _
}
charAsShape.FillRule = FillRule.EvenOdd
shapes.Add(charAsShape)
offsetX += width
Next
shapes.Add(outline)