HTML to PDF with PDF Office Component

Pdf

HTML to PDF

With just a few lines of code, your application is now ready to save web pages into PDF documents.

What is HTML?

  • HTML (short for HyperText Markup Language or "Hypertext Markup Language") is a markup language designed to create web pages. Together with CSS and JavaScript, HTML creates a technical trilogy for the World Wide Web. HTML is defined as a simple application of SGML and is used in organizations that need complex publishing requirements. HTML has become an Internet standard maintained by the World Wide Web Consortium (W3C). The latest official version of HTML is HTML 4.01 (1999). Later, the developers replaced it with XHTML. Currently, HTML is being developed with the latest HTML5 version and promises to bring a new interface to the Web.
  • By using dynamic HTML or Ajax, developers can be created and processed by a large number of tools, from a simple text editor - which we can import from the very first line. - for complex WYSIWYG publishing tools. HTML document) is connected. And so, the link on the Web is called Hypertext. As the name suggests, HTML is a markup language, meaning you use HTML to mark text documents with Tags to tell the browser how to structure it to display on the screen.
  • Currently, HTML is a must for the programmers around the world and almost holds the unique position of the most used format in the world. This problem is not too surprising because it's easy to see that HTML can easily be found on all websites today.

What is PDF?

  • PDF (short for Portable Document Format) is a reasonably standard text file format of Adobe Systems. Similar to the Word (.doc) format, PDF supports raw text (text) along with fonts, graphic images, sounds, and many other effects. However, displaying PDF documents does not depend on the working environment of the user (machine configuration, software, and operating system).

Why PDF?

  • As mentioned above, displaying PDF documents does not depend on the working environment of the user, so this is considered the most significant advantage of PDF. Unlike Word documents, a PDF document, in most cases, will be displayed the same in different work environments. Because of this advantage, PDF format has become famous for the publication of books, newspapers, or other documents via the Internet.
  • To read the PDF file on your computer, you must have software that supports this format. Popular software today is Adobe Reader or Foxit Reader.
  • Surely, PDF files have many advantages, and here are some of the most common benefits that you refer to.
  • As a technology software, the first requirement is safety and security, we can say that the PDF file has high security and a variety of options for users to choose.
  • The range of support on most devices from computers to mobile devices.
  • The PDF file also features regular documents; the PDF format can also display completely the same in all different working environments.
  • And notably, the file size is usually quite small.

When PDF?

  • In the 1990s, when information technology was not developed as it is today, there were many inadequacies in the issue of image data transmission, content, documents with large file images that could not be transmitted. Also, computers and devices were not as modern as they are today, they could handle only a small part, so at that time, an invention needed to solve the problems that people. As a result, software developers have started using links to other resources on the computer. To reduce the amount of content, you need to transfer or save to your computer.
  • And that is the reason for the advent of PDF.
  • However, the popularity of the PDF format at the beginning was relatively slow. Early versions of PDF did not support external hyperlinks, reducing its usefulness on the web. The increased file size compared to plain text also means that the time it takes to download a PDF document will be longer, which is also a problem with slow modems of the time.
  • Adobe soon offered the Acrobat Reader (now Adobe Reader) for free and continues to support the prototype PDF format. Eventually, PDF became the standard format for printable documents on the web.
  • The PDF format has been changed many times and is currently under development.

Problems

  • Because of these significant advantages, PDF has become an indispensable and always-sought format of hundreds of thousands of different text editors worldwide. An undeniable proof is that the number of references, ebooks, etc. on the Internet is growing at a dizzying pace, covering a wide variety of different fields. Training programs at hundreds of thousands of universities also tend to shift from documents and papers from original formats such as Word, Wordx, etc. to modern PDF form. The above helps PDF to prove its unique position.
  • Along with that, HTML has become a must-have drafting ecosystem on the Internet. Understanding and mastering HTML is almost a must for every developer who wants to work with the Web platform. Moreover, it would be a waste not to be able to access the vast resources available on the Internet for a straightforward reason that it is impossible to manipulate HTML format.
  • As a modern user, following the trends, you will want to convert and work with both PDF and HTML as the main formats for all your documents. However, the problem will arise from here when there is no useful tool for converting and performing complex manipulations between the two forms. And it will only get worse when you want your application to have features related to the two forms.

Introducing PdfProLib - A fast, accurate library that easy to integrate into any .NET application

Designed by hundreds of C# experts, PdfProLib HTML to PDF offers a vast ecosystem of highly customizable, serving all software development needs.

  • Flexibility is the name of the game, PdfProLib HTML to PDF is adaptable and supports a huge number of platforms, compatible with every project: MVC, Windows Forms, ASP.NET, and WPF applications or Windows Azure Cloud services to convert URLs, HTML strings and streams, SVG vector graphics to a PDF document, raster image or SVG vector image.
  • This tool is the best option for converting HTML websites into PDF files or images. We can also use it to create reports in PDF format created from partner HTML versions, making it easy to maintain a report template while some forms are available to end-users.

Advanced Features

PdfProLib HTML to PDF brings you a diverse and advanced feature library, maximum support for all operations.

  • Support latest HTML5 standards
  • Supports CSS3
  • Convert to raster and SVG images
  • Recognizes page breaks in attributes and styles
  • Supports internal and external links
  • Supports Unicode, Right-to-left direction
  • Merges converted PDF documents into a single file
  • Optimized for both single and multi-thread conversions
  • Support for .NET Full Framework, Xamarin iOS, Mac, Android, Mono, .NET CF, and .NET Core, Standard (will be available soon)
  • Royalty-free redistribution
  • Supports .NET 2.0, 3.5, 4.0, 4.5, 4.6, and 4.7.

Example

The OfficeComponent PDF lets you add the capability to convert any HTML webpage to PDF documents by just adding a few lines of code. The HtmlToPdfConverter class allows you to set several advanced conversion options. We take advantage of that class with the following code snippet:

  • C# Version:
        // Create a new converter. 
        var c = new HtmlToPdfConverter() 
        { 
            ViewportWidth = Width, 
            ViewportHeight = Height, 
            PageSize = PageSize, 
            PageMargin = Margin, 
            Portrait = Portrait, 
            Delay = ConversionDelay, 
            Timeout = Timeout, 
            SinglePage = SinglePage 
        };
        // Convert URL 
        c.ConvertAsync(Url, outputPath, OnConversionComplete);
  • VB Version:
            'Create a new converter.'
            Dim c = New HtmlToPdfConverter() With 
            {
                .ViewportWidth = Width, 
                .ViewportHeight = Height, 
                .PageSize = PageSize, 
                .PageMargin = Margin, 
                .Portrait = Portrait, 
                .Delay = ConversionDelay, 
                .Timeout = Timeout, 
                .SinglePage = SinglePage
            }

If you wish to convert an HTML string to PDF, use the following line of code instead:

C# Version:

    // Convert the specified HTML string. 
    c.ConvertStringAsync(HtmlString, HtmlStringBaseUrl, outputPath, OnConversionComplete);

VB Version:

    'Convert URL'
    c.ConvertAsync(Url, outputPath, AddressOf OnConversionComplete)

The full source code of this example is available in our PDF package.

A live demo for converting HTML to PDF is also available on our site. If you also need PDF functionality, check out our PDF online demos.

45-Day Money Back Guarantee

We will refund your full money in 45 days
if you are not satisfied with our products

Buy Now
You have successfully subcribed to our mailing list.
Dont miss out Get update on new articles and other opportunities Subscribe