Set extra time after loading page in seconds for launching all JavaScript on page

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfVision (in SautinSoft.PdfVision.dll) Version: 5.1.2.13

Syntax

      
 C#  Visual Basic 
public float HtmlTimeOutForScripts { get; set; }
Public Property HtmlTimeOutForScripts As Single

Remarks

This property will be helpful to convert Web-pages containing a lot of Javascript which require extra time to render page. For example, to convert pages with google maps set this property to 2-3 seconds.

Default value: 2.5 seconds.



If your Web-page doesn't have Javascript you may increase converting speed by setting this property to 0.

Examples

CopyHow to convert HTML string to PDF bytes in C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Convert HTML string to PDF bytes.
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();

            //v.Serial = "XXXXXXXXXXXXXXX";

            // Set "Edge mode" to support all modern CSS.
            SautinSoft.PdfVision.TrySetBrowserModeEdgeInRegistry();

            //specify converting options
            v.PageStyle.PageSize.Auto();
            //v.PageStyle.PageMarginLeft.Inch(1);
            //v.ImageStyle.Heightmm(150);
            //v.ImageStyle.WidthInch(10);

            //Specify top and bottom page margins
            v.PageStyle.PageMarginTop.Mm(5f);
            v.PageStyle.PageMarginBottom.Mm(5f);

            string html = "<html><body><p style=\"text-align: center; font-size: 45px;\">Hello my Friend!</p></body></html>";

            // Convert HTML string to PDF bytes.
            byte[] pdf = v.ConvertHtmlStringToPDFStream(html);

            // Save PDF data to a file and open it for demonstration purposes.
            if (pdf != null)
            {

                FileInfo pdfFile = new FileInfo(@"Result.pdf");

                using (FileStream fs = new FileStream(pdfFile.FullName, FileMode.Create, FileAccess.Write))
                {
                    fs.Write(pdf, 0, pdf.Length);                 
                }
                System.Diagnostics.Process.Start(pdfFile.FullName);
            }
        }
    }
}
CopyHow to convert HTML string to PDF bytes in VB.Net
Imports System.IO

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            ' Convert HTML string to PDF bytes.
            Dim v As New SautinSoft.PdfVision()

            'v.Serial = "XXXXXXXXXXXXXXX";


            ' Set "Edge mode" to support all modern CSS.
            SautinSoft.PdfVision.TrySetBrowserModeEdgeInRegistry()

            'specify converting options
            v.PageStyle.PageSize.Auto()
            'v.PageStyle.PageMarginLeft.Inch(1);
            'v.ImageStyle.Heightmm(150);
            'v.ImageStyle.WidthInch(10);


            'Specify top and bottom page margins
            v.PageStyle.PageMarginTop.Mm(5.0F)
            v.PageStyle.PageMarginBottom.Mm(5.0F)

            Dim html As String = "<html><body><p style=""text-align: center; font-size: 45px;"">Hello my Friend!</p></body></html>"

            ' Convert HTML string to PDF bytes.
            Dim pdf() As Byte = v.ConvertHtmlStringToPDFStream(html)

            ' Save PDF data to a file and open it for demonstration purposes.
            If pdf IsNot Nothing Then

                Dim pdfFile As New FileInfo("Result.pdf")

                Using fs As New FileStream(pdfFile.FullName, FileMode.Create, FileAccess.Write)
                    fs.Write(pdf, 0, pdf.Length)
                End Using
                System.Diagnostics.Process.Start(pdfFile.FullName)
            End If
        End Sub
    End Class
End Namespace

See Also