XRendering SaveAlpha Property. Whether to save the alpha channel into the output. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

 

Type Default Value Read Only Description
[C#] bool

[Visual Basic]
Boolean
  false No Whether to save the alpha channel into the output.

 

   

Notes
 

This property determines whether the Save method includes an alpha channel in the rendered output.

Only some types of output support alpha. These are:

  • PNG
  • BMP
  • TIFF (Grayscale, RGB and CMYK)
  • PSD (Photoshop)
  • Bitmap (via the GetBitmap function)

By including an alpha channel in your output you can identify areas which are transparent and areas on which no drawing has taken place.

 

   

Example
 

The following example shows the effect that this parameter has on PDF rendering. We create a PDF with some text on it. We then render the PDF with an alpha channel and add the transparent image into a new PDF with a blue background. The blue background shows through where the image is transparent.

[C#]
Doc theDoc = new Doc();
// Add some text
theDoc.FontSize = 196;
theDoc.TextStyle.HPos = 0.5;
theDoc.TextStyle.VPos = 0.3;
theDoc.AddText("Hello World");
// Render the PDF with alpha
theDoc.Rendering.SaveAlpha = true;
Bitmap alphaBitmap = theDoc.Rendering.GetBitmap();
// Create a blue PDF
theDoc = new Doc();
theDoc.Color.String = "0 0 255";
theDoc.FillRect();
// Add the transparent Bitmap into the PDF
// so that the underlying blue can show through
theDoc.AddImageBitmap(alphaBitmap, true);
// Save render of pdf
theDoc.Rendering.Save(Server.MapPath("RenderingSaveAlpha.png"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
' Add some text
theDoc.FontSize = 196
theDoc.TextStyle.HPos = 0.5
theDoc.TextStyle.VPos = 0.3
theDoc.AddText("Hello World")
' Render the PDF with alpha
theDoc.Rendering.SaveAlpha = True
Dim alphaBitmap As Bitmap = theDoc.Rendering.GetBitmap()
' Create a blue PDF
theDoc = New Doc
theDoc.Color.String = "0 0 255"
theDoc.FillRect()
' Add the transparent Bitmap into the PDF
' so that the underlying blue can show through
theDoc.AddImageBitmap(alphaBitmap, True)
' Save render of pdf
theDoc.Rendering.Save(Server.MapPath("RenderingSaveAlpha.png"))
theDoc.Clear()


RenderingSaveAlpha.png