Convert from HTML to PDF in CSharp VB and ASP.NET with a Free 3rd Party Library

Converting from html to pdf is not an easy task. There are some tools that can do that, but most of them cost thousands of dollars. SelectPdf offers a Community Edition (FREE) of the powerful Html To Pdf Converter for .NET that can be found in the full featured pdf library.

3.6 Star
52,991 times
Add to favorites
E-mail Twitter Digg Facebook

Solution explorer

<%@ Page Title="" Language="vb" MasterPageFile="~/Samples.Master" AutoEventWireup="true" CodeBehind="page-breaks.aspx.vb" Inherits="SelectPdf.Samples.SelectPdf.Samples.page_breaks" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>SelectPdf Free Html To Pdf Converter for .NET VB.NET / ASP.NET - Control Page Breaks with Html to Pdf Converter</title>
    <meta name="description" content="SelectPdf Free Html To Pdf Converter - Control Page Breaks with Html to Pdf Converter Sample for VB.NET / ASP.NET. Pdf Library for .NET with full sample code in C# and VB.NET." itemprop="description">
    <meta name="keywords" content="page breaks, custom page break, keep together, pdf library, sample code, html to pdf, pdf converter" itemprop="keywords">
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
        <article class="post type-post status-publish format-standard hentry">
            <header class="entry-header">
                <h1 class="entry-title">SelectPdf Free Html To Pdf Converter - Control Page Breaks with Html to Pdf Converter - VB.NET / ASP.NET Sample</h1>
            <!-- .entry-header -->

            <div class="entry-content">
                    This sample shows how to use SelectPdf html to pdf converter to convert a raw html code to pdf and also how to control the page breaks from the html code.
                    <br />
                    <br />
                    To insert a page break in pdf, the html code must have an element with the style <i>page-break-before: always</i> or <i>page-break-after: always</i>. 
                    Before or after that specific element, a page break will be inserted into the generated pdf document. The element can be anything (image, table, table row, div, text, etc).
                    <br />
                    <br />
                    To instruct a certain section from the content to remain on the same page in the generated pdf document, an element with the style <i>page-break-inside: avoid</i> must be used.
                    Html Code:<br />
                    <asp:TextBox ID="TxtHtmlCode" runat="server" Width="90%" Text="" TextMode="MultiLine" Height="150px"></asp:TextBox><br />
                    <br />
                    Base Url:<br />
                    <asp:TextBox ID="TxtBaseUrl" runat="server" Width="90%" Text=""></asp:TextBox>
                <div class="col-clear"></div>
                    <asp:Button ID="BtnCreatePdf" runat="server" Text="Create PDF" OnClick="BtnCreatePdf_Click" CssClass="mybutton" />
            <!-- .entry-content -->
        <!-- #post -->