Importing PNG files with transparency

6 posts, 0 answers
  1. Shaun
    Shaun avatar
    31 posts
    Member since:
    Jul 2011

    Posted 30 Jan 2015 Link to this post

    I am struggling to get PNG files with transparency to import into a PDF. I have tried several different PNG files with no look. The transparent background section either comes out as black or blurred.

    Please see the code I have been experimenting with below.

    --------------------------------

    Dim FormatProvider As New PdfFormatProvider
    FormatProvider.ExportSettings.ImageQuality = ImageQuality.High
    Dim Document As New RadFixedDocument
    Dim Page As RadFixedPage = Document.Pages.AddPage()
    Page.Size = New Size(PageWidth, PageHeight)
    Editor = New FixedContentEditor(Page)

    'Method 1
    Editor.Position.Translate(0, 0)
    Dim imageStreamSource As New FileStream("Logo1.png", FileMode.Open, FileAccess.Read, FileShare.Read)
    Dim decoder As New PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
    Dim bitmapSource As BitmapSource = decoder.Frames(0)
    Editor.DrawImage(bitmapSource.ToImageSource)

    'Method 2
    Editor.Position.Translate(0, 200)
    Using source As FileStream = File.Open("Logo2.png", FileMode.Open)
        Dim imageSource As New Resources.ImageSource(source)
        Editor.DrawImage(imageSource)
    End Using

    'Method 3
    Editor.Position.Translate(0, 400)
    Dim bitmap As New BitmapImage()
    bitmap.BeginInit()
    bitmap.UriSource = New Uri("Logo3.png")
    bitmap.EndInit()
    Editor.DrawImage(bitmap.ToImageSource)

    Dim filename As String = "test.pdf"
    Using DocStream As New FileStream(filename, FileMode.Create)
        FormatProvider.Export(Document, DocStream)
    End Using

    -----------------------------------

    Any advice would be very much appreciated. I am finding the RadPDFProcessing tool extremely useful in a dynamic product brochure project i am working on but i need to be able to use transparent images. If its not possible to use a PNG file is the another file format i could import to the PDF that allows for transparency?




  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 02 Feb 2015 Link to this post

    Hello Shaun,

    Thank you for contacting us.

    Transparent images are not supported by RadPdfProcessing. We have this in our back log and hopefully we will be able to implement it for one of the next few releases.

    Hope this answers your question.

    Regards,
    Kammen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Shaun
    Shaun avatar
    31 posts
    Member since:
    Jul 2011

    Posted 03 Feb 2015 in reply to Kammen Link to this post

    Thanks for the update Kammen. I am a little disappointed transparent images aren't supported as it is a rather major flaw in RadPdfProcessing, especially considering the vast amount of other features which are included. I am guessing this won't be ready in time for the official release that's supposed to be out in Q1? If you require any help testing this feature in the future when it gets added please feel free to contact me.

    Regards,

    Shaun
  4. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 04 Feb 2015 Link to this post

    Hello Shaun,

    No, it won't be released for Q1. We will do our best to include it in the SP1 but we cannot promise you anything as there are other features with higher priority that we need to implement as well.

    Regards,
    Kammen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Shaun
    Shaun avatar
    31 posts
    Member since:
    Jul 2011

    Posted 04 Feb 2015 in reply to Kammen Link to this post

    Hi Kammen,

    In the mean time I am looking at using jpg/bmp with the same background colour as I have set for the page. The problem is on saving the document some compression seems to be taking place. I have used;

    FormatProvider.ExportSettings.ImageQuality = ImageQuality.High

    On screen the pdf seems to look ok, but on printing there is a clear difference in the shading. This results in an obvious box where the image is. Inspecting the pdf reveals the jpg/bmp colours have altered slightly. #444444 = #434544 and #4F8CC0=4C8DBD. This may not seem like much of a difference but on the print out its really, really obvious.

    Is there anyway to turn off the image compression completely? I am aware this might effect file size.

    Regards,

    Shaun
  6. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 05 Feb 2015 Link to this post

    Hi Shaun,

    Unfortunately this is not supported by RadPdfProcessing. All images are automatically compressed to JPEG. We will consider adding this as an option but I cannot give you a time frame when it will be released.

    We are sorry for the inconvenience.

    Regards,
    Kammen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top