PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2008 VS 2005 CLR 2.0

How To Set Transparency Levels For PDF Elements

Render text, shapes, and images in PDF with varying levels of transparency.
By M. V. Niranjan

PDF format offers a great depth of features that you can use to spruce up your PDF documents. For this article, I will focus on rendering text, shapes, and images that appear translucent on a PDF document using Gnostice PDFOne .NET.

To change the level of transparency of PDF elements, you just need to specify the alpha value of the color used by the pen and brush objects of PDFPage, which are used to stroke and fill PDF elements such as text and shapes.

Color.FromArgb Method(Int32, Color)

public static Color FromArgb(
  int alpha,
  Color baseColor
);

When the alpha value is 0, the PDF element will rendered completely transparent i.e., it will not be visible even though it is present in the PDF. When the alpha value is set to 255, the PDF element appears totally opaque. The corollary then is that we need to vary the alpha value as required, specify the color, and then render the PDF element.

PDFPage page = new PDFPage();

// Sets alpha value for brush color
page.Brush.Color = Color.FromArgb(30, Color.Blue);
// Writes translucent text
page.WriteText("This is transparent text", 1, 2.5f);


// Changes alpha value for brush color
page.Brush.Color = Color.FromArgb(
                           40, Color.YellowGreen);
// Draws a translucent ellipse
page.DrawEllipse(Pens.Black, 
                 new RectangleF(1, 3.5f, 2, 1), 
                 true, true);

// Changes alpha value of brush color again
page.Brush.Color = Color.FromArgb(
                           10, Color.Empty);                    
// Draws a translucent image
page.DrawImage("image.bmp", 
               new RectangleF(1, 4.5f, 2, 1));

You have learned how to set transparency levels for text, shapes, and images in PDF. Now, with some imagination and/or practice, you will be able create translucent PDF elements along with smartly-positioned overlays. Your PDF documents may then sport an elegant and attractive look.

Translucent text in PDF Translucent shapes in PDF Translucent images in PDF
---o0O0o---

Downloads:

---o0O0o---

Our Developer Tools
eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers

PDFOne (for Java™)

A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications.

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

Privacy | Legal | Feedback | Newsletter | Resellers © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).