Free Support Forum -

Aspose html to pdf not able give style on image for round radius

We have created html which has dynamic data over profile picture we are adding round border radius but when it is converted to pdf using Aspose.html then that round becomes square border over image,

Here is code for converting html to pdf

  /// <summary>
    /// This method convert HTML to PDF byte[]
    /// </summary>
    /// <param name="htmlContent">Content of the HTML.</param>
    /// <param name="IsCertificate">if set to <c>true</c> [is certificate].</param>
    /// <returns></returns>
    public static byte[] HTMLToPdf(byte[] htmlContent, bool IsCertificate = true, bool isPaymentReceipt = false)
        Stream inputstream = new MemoryStream(htmlContent);
        // File name for resultant PDF file
        // Create PdfRendering Options object
        var pdf_options = new Aspose.Html.Rendering.Pdf.PdfRenderingOptions();

        // The PageSetup also provides different properties i.e. FirstPage, LastPage, LeftPage, RightPage and they are used to setup (PageSize, Margin) for every page. 
        // In most cases, usage of setup any page is enough, but in some complicated cases, you may need to fine tune page settings. It can be done either by CSS styles or by using rendering options.
        // the size for drawing is in pixels
        var width = Aspose.Html.Drawing.Unit.FromMillimeters(297);
        var height = Aspose.Html.Drawing.Unit.FromMillimeters(420);
        var pageSizeA3 = new Aspose.Html.Drawing.Size(width, height);

        pdf_options.PageSetup.AnyPage = new Aspose.Html.Drawing.Page(pageSizeA3);
        pdf_options.PageSetup.AdjustToWidestPage = true;

        Stream outputStream = new MemoryStream();

        // Instantiate PdfDevice object while passing PdfRenderingOptions and resultant file path as arguments
        using (var pdf_device = new Aspose.Html.Rendering.Pdf.PdfDevice(pdf_options, outputStream))
        // Create HtmlRenderer object
        using (var renderer = new Aspose.Html.Rendering.HtmlRenderer())
        // Create HtmlDocument instance while passing path of already created HTML file
        using (var html_document = new Aspose.Html.HTMLDocument(inputstream, string.Empty))
            // Render the output using HtmlRenderer
            renderer.Render(pdf_device, html_document);

        var alteredoutputStream = ApplyDocumentProperties(outputStream, IsCertificate, isPaymentReceipt);

        byte[] buff = null;
        var br = new BinaryReader(alteredoutputStream);
        alteredoutputStream.Position = 0;
        var numBytes = alteredoutputStream.Length;

        buff = br.ReadBytes((int)numBytes);

        return buff;

Here is code line (portion) of html profile pic with round radius,

  • ProfileImage is variable here with image’s base 64 string
    <div style='display:inline-block; vertical-align: middle; margin-right: 1.5rem; border-radius: 50px 50px 50px 50px;-webkit-border-radius: 50px 50px 50px 50px;-moz-border-radius: 50px 50px 50px 50px; overflow: hidden; width: 2.6rem; height: 2.6rem; line-height: 2.6rem; text-align: center; text-transform: uppercase;'><img src='" + ProfileImage + "' style='width: 100%; vertical-align: top; object-fit: cover; position: relative; height: 100%;border-radius: 50px 50px 50px 50px;-webkit-border-radius: 50px 50px 50px 50px;-moz-border-radius: 50px 50px 50px 50px;overflow: hidden;'></div>

Please help us in resolving this ASAP or let us know if more information is required.


Would you please make sure to use Aspose.HTML for .NET 20.9 at your side. In case issue still persists, please share complete sample .html file which we can use to replicate the issue in our environment. This way it can be addressed properly. We also tried to test the scenario with partial HTML code that you provided but it could not get performed as HTML was not rendered correctly in the browser as well.

We can’t share full entire html file due to privacy concerns though suggested version works fine with our scenario. Can you suggest any work around for version 19.7 to make this work.


We are afraid that we cannot offer any workaround for 19.7 version of the API as issue does not exist in the latest version. The support is provided on the basis of latest version of the API and we always recommend to use it as it contains more fixes and improvements.