DynamicPDF ToolkitOne™ RAD Edition Overview (Part 1)

Wed, June 20 2018, 10:34 AM (US Eastern Time)

DynamicPDF is excited to release the RAD Edition of ToolkitOne™. Unlike our PRO Edition of ToolkitOne™ that shares many of the features of our Core Suite in an updated, cross platform API, we focused this product enhancement on rapid application development (hence the name). We also refer to this as rapid PDF development since it is designed to get the PDFs your users need to them in a fast and efficient way. These include:

  • Rapid PDF development using DynamicPDF Designer (ToolkitOne™ Edition)
  • Rapid PDF development using HTML and CSS
  • Creating PDFs from multiple PDFs (merging)

Today, we'll take a look at (1) creating PDFs using HTML and CSS and (2) creating PDFs from multiple PDFs. Be sure to check back on this blog for our discussion (in Part 2) on creating PDFs using DLEX templates from Designer.

Creating PDFs from HTML and CSS

A powerful feature of the RAD edition is its ability to quickly create PDFs using HTML. If you are already delivering reports to your users in HTML, you can quickly and easily use the same processes to create PDFs utilizing the HtmlLayout class. This class takes your HTML, allows you to set headers and footers and returns a paginated Document class. Let's take a look at these elements separately.

The HtmlLayout constructor establishes the HTML to use along with the dimensions of the page through a PageInfo class. Using the PageInfo class you can specify a page size and orientation or use a page from an existing PDF as a background template. A base ref can also be set through the constructor when needed:

Uri htmlSource = new Uri(@"C:\MyHTMLReport.html");
HtmlLayout htmlLayout = new HtmlLayout(htmlSource, new PageInfo(PageSize.Letter, PageOrientation.Portrait));

You can then quickly set left, center, and/or right justify headers and footers on your layout using the header and footer properties. The headers and footers share the same style information as the HTML so they will have the identical appearance. A span tag can also be used to select a CSS class or change the style. Setting the HasPageNumbers property to true, will cause the header or footer element to be parsed for page numbering info (e.g. "Page 1 or 3"):

htmlLayout.Header.Left.Text = "My PDF Report";
htmlLayout.Header.Right.Text = "Report for my User";
htmlLayout.Footer.Center.Text = "Page %%CP%% of %%TP%%";
htmlLayout.Footer.Center.HasPageNumbers = true;

Once everything is all set, simply call the Layout method to return a Document object containing the HTML laid out over as many pages as needed. You can then save it or work with it as you would any other Document object:

Document document = htmlLayout.Layout();
document.Draw(outputFilePath);
Creating PDFs from Multiple PDFs (Merging)

Merging PDFs together is also a simplified process. If you'd like to simply merge two PDFs together, you can use the Document class's static Merge method:

Document document = Document.Merge(@"C:\MyFirstPDF.pdf", @"C:\MySecondPDF.pdf");
document.Draw(outputFilePath);

You can also append PDFs to an existing Document object, or take the Document object you created using HTML above and append PDFs to it:

Uri htmlSource = new Uri(@"C:\MyHTMLReport.html");
HtmlLayout htmlLayout = new HtmlLayout(htmlSource, new PageInfo(PageSize.Letter, PageOrientation.Portrait));
Document document = htmlLayout.Layout();
document.Append(@"C:\MyFirstPDFToAppend.pdf");
document.Append(@"C:\MySecondPDFToAppend.pdf", 1, 3);
document.Draw(outputFilePath);
Wrap Up

We've seen how easy it is to create PDFs using HTML and merge PDFs together using the DynamicPDF ToolkitOne™ RAD Edition. The object model is very flexible and there are of course many other more advanced features like creating PDFs in memory, using HTML from a URL, and disk buffering, all of which is covered in our help docs. Please check back for Part 2 of this post, where we'll explore rapid PDF development using Designer templates (DLEXs) and your business objects.

Tags: , , , , , , , , , ,

Month List