- Dynamic XFA
- pdfkit5 and Xamarin
- Use multiple licenses
- Replace field with image
- Import FDF into PDF
- Embed TrueType font in PDF
- Determine if a PDF only contains images
- Download and convert image to PDF
- Use TrueType font collections
- Determine the content bounding box
- Highlight fields in PDF
- Add hyperlink to PDF
- Add Stamp to PDF
- How do I extract page destinations from bookmarks?
- Convert SVG to PDF
- Extract glyph boxes from PDF
- Fill in a template PDF document
- Extract graphics from PDF
- Flatten Markup Annotation
- Fill and save dynamic XFA form
- Clip PDF page content in C#
- How to scale content of PDF
- Use pdfkit5 with a Xamarin.Forms app
- Create tagged PDF
- Add single-line text to PDF
- Change the formatting of a numeric field
- Add bookmarks to PDF
- Convert PDF to plain text
- TIFF to PDF C#
- Add a note to PDF
- Add a link with an internal destination to PDF
- Create formfields in PDF documents
- Extract embedded files from PDF
- Remove graphics from PDF
- Fit image to PDF page
- Split PDF pages in C# and VB.NET
- Add tags to existing PDF
- pdfkit5 - detailed changes to the API - Tall Components
- Add a link to PDF with an external destination
- Translate PDF page content
- How to sign and verify updates to a PDF document
- Create a new digitally signed PDF document
- EMF to PDF as vector image
- Layout text with MultilineTextShape
- Add multiline text to a PDF document
- .NET Core console app on MacOS
- How to add autosized text to PDF
- How to generate and export certificates
- Write Document to HttpResponse
- Create rectangles with rounded corners
- Add barcodes to PDF
- Append two or more existing PDF files
- pdfkit5 and .NET Core
- Create a text annotation in PDF with rich text
- Rotate a PDF page
- Add text field to PDF
- Change the color inside a PDF
- How to embed files in a PDF document
- Merge XDP data with dynamic XFA form
- How to mirror PDF pages and other shapes
- Add a Diagonal Watermark to PDF in C# - TallComponents - PDF Library
- Read PDF tags
- How to reduce PDF file size
- Tagged PDF
- Read and write meta data from PDF
- Add footer to PDF
- Create a custom signature handler to sign and verify PDF documents
- Export FDF from PDF form
- Create text with decorations
- Fill XFA form and export XDP data
- Vector graphics in PDF
- Resize PDF pages
- Change page orientation PDF
- Reduce PDF size
- Crop content on a PDF page
- Extract glyphs and sort by reading order
- PDF Viewer Preferences
- Extract images from PDF
- Disable submit button after submitting
- How to downscale all images in a PDF
- Remove PDF security settings
- Merge PDF files in C# .NET
- Flatten PDF form
- Licensing and .NET Standard
- How to downscale all images in a PDF
- Fill PDF form
- pdfkit5 .NET Standard API
- Add a rubber stamp annotation with a custom icon
- Add Long Term Validation (LTV) data to an existing signature
- How to create a tiling for shapes in PDF
- Search text in PDF
- Digitally sign a PDF form in C# or VB.NET
- Add simple html text to PDF
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)