Creating PDFs in C# with Outlined or Invisible Text

Thu, August 30 2012, 1:51 PM (US Eastern Time)

DynamicPDF Generator has lots of predefined page elements which allow you to easily create different types of content, but you may occasionally have a need to do something that is not available in the API by default. Custom page elements is an easy way to extend the API to achieve these results.

We get questions from time to time on how to add outlined text to a PDF. By outlined text I mean text that is not completely filled in with a color but rather is just an outline of the font and nothing filled in the middle of the text.  This is a great situation for using a Custom page element and the C# code below shows how to extend the TextArea page element to add this functionality:

using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class OutlinedTextArea : TextArea
{
    // Member variable to store Border Width
    private float borderWidth = 1.0f;

    // Constructors. Additional ones can be added to model TextArea
    public OutlinedTextArea(string text, float x, float y, float width, float height)
        : base(text, x, y, width, height) { }
    public OutlinedTextArea(string text, float x, float y, float width, float height,
        Font font, float fontSize)
        : base(text, x, y, width, height, font, fontSize) { }

    // Border Width Property added
    public float BorderWidth
    {
        get { return this.borderWidth; }
        set { this.borderWidth = value; }
    }

    // Override Draw Method
    public override void Draw(ceTe.DynamicPDF.IO.PageWriter writer)
    {
        // Enter Graphics Mode
        writer.SetGraphicsMode();
        // Set Stroke Color and Border Width
        writer.SetStrokeColor(base.TextColor);
        writer.SetLineWidth(this.borderWidth);
        // Enter Text Mode
        writer.SetTextMode();
        // Set Text Rendering Mode
        writer.SetTextRenderingMode(TextRenderingMode.Stroke);
        // Call Draw on base class
        base.Draw(writer);
        // Enter Text Mode (in case underline is set to true)
        writer.SetTextMode();
        // Set Text Rendering Mode Back to Fill
        writer.SetTextRenderingMode(TextRenderingMode.Fill);
    }
}

More...

Tags: , , , , , , , , , , ,

DynamicPDF for COM/ActiveX Version 7 BETA Release

Fri, August 17 2012, 1:58 PM (US Eastern Time)

A head's up to all you DynamicPDF COM/ActiveX users out there...we just put the version 7 Beta up on our site for downloading and testing, here.

Version 7 Beta includes DynamicPDF Generator, Merger and ReportWriter (all included in the Core Suite) and like all our installers it includes the documentation and a bunch of ASP, VB6 and VBScript examples.

Take a look at some of the great new features like QR Codes, AES 128 & 256 encryption support, text extraction, full form field flattening and a bunch more.

Email support@cete.com with any questions or issues and thanks for taking part!

Are there any features/improvements that you would want to see in version 8 of DynamicPDF for COM/ActiveX? Let us know with your comments below.

Tags: , ,

Month List