Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

HTML to PDF - rgba background colors doesn't work

$
0
0
Hi Aspose Team,

i use Aspose.Pdf 9.8.0.0 and try to import a HTML document into a PDF document. All is fine except css rgba colors, i.e. used in "background-color: rgba( 255, 0, 0, 0.2 );". The alpha transparency part in HSLA doesn't work also, i.e.: "background-color: hsla(120,100%,50%,0.2);"

  rgba( 255, 0, 0, 0 )

results in white background (full transparency).

  rgba( 255, 0, 0, 0.1 )

results in full red background (no transparency).

As written in your support document:

  http://www.aspose.com/docs/display/pdfnet/Supported+CSS+features
  (CSS Color Units)

rgba should be supported.

Please see the following code for an example. The resulting file is attached.

Public Sub GeneratePdf()

Dim HtmlContent As String
    HtmlContent = "<html>" &
                  "<head>" &
                  "<style type=""text/css"">" &
                  "div.Red {" &
                  "    background-color: rgba(255, 0, 0, 0.1);" &
                  "    border: 1px solid #d4d4d4;" &
                  "    width: 200px;" &
                  "    height: 100px;" &
                  "}" &
                  "</style>" &
                  "</head>" &
                  "<body>" &
                  "<div class=""Red"">Hello World</div>" &
                  "</body>" &
                  "</html>"

Dim Stream As New MemoryStream( Encoding.UTF8.GetBytes( HtmlContent ) )

Dim HtmlToPdfLoadOptions As New HtmlLoadOptions()
Dim HtmlToPdfDocument    As New Aspose.Pdf.Document( Stream, HtmlToPdfLoadOptions )

    HtmlToPdfDocument.Save( "X:\Folder\HtmlToPdfTest.pdf" )
    HtmlToPdfDocument.Dispose()

    Stream.Close()
    Stream.Dispose()
   
End Sub


Viewing all articles
Browse latest Browse all 3131

Trending Articles