# How do I preserve transparency channel when converting PDF to 	PNG/TIF?

**URL:** <https://community.apryse.com/t/how-do-i-preserve-transparency-channel-when-converting-pdf-to-png-tif/681>\
**Category:** Apryse SDK\
**Created:** [July 24, 2008, 10:41pm UTC](https://community.apryse.com/t/how-do-i-preserve-transparency-channel-when-converting-pdf-to-png-tif/681 "2008-07-24T22:41:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Gravesdale](https://community.apryse.com/letter_avatar_proxy/v4/letter/a/ba8739/32.png) [@Aaron\_Gravesdale](https://community.apryse.com/u/Aaron_Gravesdale)\
**Post date:** [July 24, 2008, 10:41pm UTC](https://community.apryse.com/t/how-do-i-preserve-transparency-channel-when-converting-pdf-to-png-tif/681/1 "2008-07-24T22:41:42Z")

</div>

Q: When I generate a PNG image from a PDF that has transparent areas,  
the PNG is white where it should be transparent.  
-----  
A: Assuming that you would like to treat the page as transparent  
backdrop instead of a opaque white color, call  
PDFDraw.SetPageTransparent(true) before rendering the page. (by  
default, PDFNet assumes opaque white color as a page backdrop). For  
example:

PDFDoc doc = new PDFDoc("in.pdf");  
doc.InitSecurityHandler();  
Page page = doc.GetPage(1);

pdfdraw.SetDPI(92);

// To export the image as PNG with transparency:  
pdfdraw.SetPageTransparent(true);

pdfdraw.Export(page, "my.png");

// or  
// System.Drawing.Bitmap bmp = pdfdraw.GetBitmap(page);  
// bmp.Save("my.png", System.Drawing.Imaging.ImageFormat.Png);

------  
The following the relevant documentation for  
PDFDraw::SetPageTransparent():

/\*\*  
\* Sets the page color to transparent.  
\*  
\* @default By default, PDFDraw assumes that the page is imposed  
directly on an  
\* opaque white surface. Some applications may need to impose the page  
on a different  
\* backdrop. In this case any pixels that are not covered during  
rendering will  
\* be transparent.  
\*  
\* @param is\_transparent Set to 'true' if the page's backdrop should  
be transparent;  
\* If is\_transparent is false, the page's backdrop will be a opaque  
white surface.  
\*  
\* @note If page transparency is enabled, the alpha channel will be  
preserved when  
\* the image is exported as PNG, TIFF, or RAW.  
\*/  
void SetPageTransparent(bool is\_transparent)

You can download the latest version of PDFNet SDK from the downloads  
page: [http://www.pdftron.com/downloads.html](http://www.pdftron.com/downloads.html).
