We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing PdfPageSize in Export service causes 'Failed to convert web pages'


I have an export service to convert html to pdf which works correctly. I changed it slightly to switch page sizes so the user can print envelopes and this causes the Failed to Convert error. If I don't change the page size then everything works properly.

public class ExportService
        public MemoryStream CreatePdf( string html, bool envelope )
            //Initialize HTML to PDF converter.

            BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

            if (envelope)
                blinkConverterSettings.PdfPageSize = PdfPageSize.A10;
                blinkConverterSettings.ViewPortSize = new Size(800, 0);
                blinkConverterSettings.PdfPageSize = PdfPageSize.Letter;

            var m = new Syncfusion.Pdf.Graphics.PdfMargins
                Left = 50,
                Right = 50
            blinkConverterSettings.Margin = m;
            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter
                ConverterSettings = blinkConverterSettings
            //Convert URL to PDF.
            var document = htmlConverter.Convert(html, "");
            var stream = new MemoryStream();
            return stream;

2 Replies

SN Santhiya Narayanan Syncfusion Team February 7, 2023 11:53 AM UTC

We were able to reproduce the reported issue with provided details on our end. Currently, we are validating on this and we will update the further details shortly.

SN Santhiya Narayanan Syncfusion Team February 9, 2023 02:26 PM UTC

We have checked the reported issue with provided code snippet and the issue is reproduced only with A10 Page Size. The issue is occur due to the used margin values in the code snippet. The resolution of the A10 paper size is 74 x 105 px. In provided code snippet you have set the left and right value of the margin as 50. So the issue is happening due to margin value 100 (Added both left and right margin) is higher than the Page width 74. We can set the margin value upto 36 while setting the both right and left margin values to have some remaining space to render the content with A10 Pdf page size. So kindly use the margin values always less than the Pdf Page size to resolve this error.

Live Chat Icon For mobile
Up arrow icon