Posted by & filed under Service announcements.

Next weekend we’re planning a server upgrade, which will bring us on Linode‘s NextGen architecture. Because of this there’s a planned service outage of 5-10 minutes on Saturday, July 6th on 6AM GMT. This is one of the most quiet moments for our service so hopefully nobody will be affected too much.

What does this mean for you?

Besides the fact that our service will not be reachable for a few minutes, this server upgrade will give you as a user even more power and performance. When you take into account that we are already running on an average of less than 10% CPU capacity and 5% of monthly bandwidth, then you know why you can trust that we are accommodated to huge bursts of activities on our service.

With this new upgrade we will get access to new high performance CPUs and we’ll also double the amount of RAM that we’re currently running. Especially the CPU power will be noticeable for users who run very CPU intensive conversions, e.g. of pages with a lot of images and/or lots of JavaScript. The extra RAM will allow us to run more of our hosted pages out of direct memory instead of from disk and that will improve your user experience when you’re surfing our site.

About Linode

We’ve been with Linode since october 2012 now and we have nothing but praise for them. They may not be the absolute cheapest provider out there, but they sure outperform all their competition in performance, support and stability. We have not had an unplanned outage since we are with them.

For this reason we recommend them to our power users, who would like to use our API or SDK in combination with a dedicated VPS. If you are interested in running huge amounts of conversions, then please contact us for a custom quote. Setup can be done in less than a day, since we can easily move our software from Linode to Linode.

Posted by & filed under Service announcements.

Attention to all current and future subscribers: we’re switching to FastSpring as our new payment provider.

We had been with BlueSnap for a while now and – when it was still Plimus – were quite happy with the service and payment fees. Since the merger (or acquisition or whatever it was) things have been going downhill and on top of that BlueSnap changed the fee structure without properly informing us. Because of these things we have decided to take our business elsewhere.

How will this impact me?

Well first of all, if you’re not a customer yet – there’s no impact whatsoever. You can use the same signup process as always and we still take CreditCards and Paypal as payment methods. You can also still make custom deals and special plans for special services. Our business will continue to run undisturbed.

If you’re already a subscribing customer, then we will cancel your subscription at BlueSnap before the new term becomes due and we’ll enter your data in FastSpring. FastSpring will request you to enter your payment data in their system (because both providers are PCI compliant we do NOT have access to your payment data) and from there on it’s business as usual.

Your conversion service will continue to run at high-performance and will not suffer any glitches. If you notice anything strange at our payment or pricing pages, please let us know!

Posted by & filed under HTML to PDF API, HTML to PDF conversion, PDF tooling.

Good news! We’ve just brought the merging functionality, which we recently introduced to the SDK, also to the API. This now allows you to take different sources of HTML and put them together into one big PDF, without having to do any HTML juggling.

The merging functionality is quite useful for a lot of different use cases. Here are some examples of what you could do with it:

  • You can take different (generated) pages of your own (or any other) website and put them together into one big PDF for your customer. This can be useful if you want to send a cover letter as well as a specific part of a brochure in one PDF for example
  • You can merge different page layouts into one PDF. Normally you can only select one page format & orientation when you create a PDF, but by merging different PDFs you can mix the pages in the final PDF up!
  • You now don’t have to worry about fitting your pages anymore. You can just fit any page into one long PDF and then merge the separate PDFs together into one PDF. This prevents content overrunning the page without having to think about CSS page breaking or other tricks you’d normally do.

And of course there are many other use cases where this may be useful.

Merging example

The merging command is very easy to execute. All you need to do is pass the ‘merge’ parameter that states how many of the last PDFs you want to merge.

So if you’d like to merge the last two PDFs you just created, you’d use the following command:

[html light=”true”]http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&merge=2[/html]

Limitations

We can merge PDFs that you have created with the API and/or SDK, but there are a few major limitations:

  1. The API only merge the PDFs in the order that they were created (unlike the SDK)
  2. Because of point 1, you can not change any of the options on the resulting merged PDF, except for setting the encryption parameters. So for example, if you’d like a watermark in the merged PDF, you’d have to set it in the original PDFs that you are merging.
  3. We can only merge the PDFs you created in the last two hours. This is the amount of time we currently cache your PDFs. If you need us to store your PDFs longer, then please contact us.

Other remarks

With this new update to the API we have also introduced some additional parameters. These are footer, header and page offset. They allow you to overwrite the header/footer and page numbering for each PDF that you want to generate, without having to do it in the members area.

Please have a look at the extensive documentation for our HTML to PDF API to learn all about it.

Posted by & filed under HTML to PDF conversion, HTML to PDF SDK.

In certain situations you would like to create a PDF based on multiple URLs or on multiple HTML files. Or you may want to have a different layout for a certain amount of the pages then for the rest of PDF. In that case the new merge functionality comes in handy.

The PDF merge functionality, which is now available in our HTML to PDF SDK, allows you to merge pages from several PDFs together into one new PDF. You can select pages from any PDF that you’ve previously created with our service and we’ll add them together into a single PDF.

This allows you to make e-books, brochures, study books and many more documents with different page formats & sizing throughout the PDF. And all this time you can still do all the things to the individual PDFs that you’re used to do, which means you can control each individual PDF’s layout, header, footer, watermark etc etc. You can even encrypt each PDF individually, but of course you should specify the encryption that you want for the final document.

How does PDF merging work?

The principle of our merging service is quite easy. You just keep on doing what you were already doing before and whenever you want to merge documents, you just execute the ‘MergeFromCache’ command. This tells us how many of your previously created PDFs we have to take and which pages you want to merge from those PDFs.

As you understand from the function title, we take the PDFs from our cache. We currently cache your PDFs for 2 hours and during this time you are free to join them into a new PDF whenever you want. We do not charge you any credits for this, cause you already used credits to do the conversion and we just add merging as an additional service.

Example code

Let’s take a small example to see what kind of things you can do with the merge functionality. Suppose you wanted to take HTML from two different sources, use a portrait layout for one source and a landscape layout for the other. Let’s also assume that the second document is something you’d like to watermark with ‘DRAFT’.

Sounds complicated? With our SDK it’s just a matter of a few lines!

Here we go.

$pdf = new Htm2PdfApi($userid, $apikey);

$pdf->SetPageSize('Letter');                          // 'Letter' is our page format
$pdf->SetPageOrientation('Portrait');                 // first document is in 'Portrait'
$pdf->CreateFromURL('http://www.google.com');         // it's the Google homepage

$pdf->SetPageOrientation('Landscape'); // second one is in 'Landscape'
$pdf->SetWatermarkLocation(200,200); // watermark @ position 200, 200
$pdf->SetWatermarkTransformation(45, 0.5); // rotate and semi-opague
$pdf->SetWatermarkText('DRAFT','arial','#FF0000',80); // write 'DRAFT' in red
$pdf->CreateFromURL('http://www.bbc.co.uk'); // it's the BBC homepage

$pdf->MergeFromCache(2);                              // now let's merge these two
$pdf->Display();                                      // and display the merged PDF!

If you would do this you’d get the following three documents (note that the SDK allows you to use all three of them if you wanted to).

 screen screen
PDF 1 PDF 3 PDF 3

Limitations

As stated earlier, you can only merge PDFs together, which you created with the SDK in the last two hours, because currently we cache those files only for 2 hours. Exceptions can be made, so feel free to contact us when you want to be in the exception category.

Another limitation is that we really merge the PDFs. We can’t do any additional actions on the result (except for encryption). So we can not fit the resulting document to a single page or apply a watermark to it. You will get exactly what you created before, but just cut and pasted together. So if you wanted to have a watermark you have to watermark the individual PDFs you created before.

The only thing we CAN do for you is to apply encryption, password protection and rights management to the resulting document. So in that way you can make sure that your merged document still needs to have a document open password or is protected against printing.

Conclusion

This article showed you the new merge functionality, which is now live for the HTML to PDF SDK. It gives you a lot of power in creating compound documents and e-books and we feel it’s a valuable addition to our service. We are currently planning to add this (in limited form) to our HTML to PDF API as well, so please stay tuned if you’re interested in that service!

Posted by & filed under HTML to PDF conversion.

We just introduced a new feature to all our paid conversion services and that is the use of CSS media types. For those amongst you who don’t know what it is, w3schools explains it really well. Basically you can use them to prepare your website for better viewing depending on the device (or media) that the user is using.

This happens to very useful for you as a (potential) user of our service, because it allows you to define the layout of your PDF in great detail By using the ‘print’ media type in your CSS and subsequently your HTML, you can define precisely how your PDF should look when your page is converted.

A lot of sites are already doing this actually and we’ll show you a simple example of what the difference is. Let’s just look at Wikipedia.org for example. All their pages are automatically displayed different depending on the media type. So if you would convert them to PDF with our service it really depends on which media type you use, what the outcome is.

Example

If we convert the page about the Portable Document Format on Wikipedia.org to PDF, you will get the following depending on whether you use the ‘print’ or ‘screen’ media type.


print
screen
screen

As you can see both look good, but also different! And the ‘print’ example is definitely more geared towards being seen on paper than on a computer display.

Conclusion

As you can see it can make a big difference in terms of layout of the PDF, whether you use the ‘print’ media type or the ‘screen’ media type. Basically you can now determine what you want to show your visitors on your webpage, but also how you want them to see the PDF of the same webpage more specifically.

This functionality is now available for our our ‘save as PDF‘ functionality as well as for the API and the SDK. If you want to know how you can do this for the different services, then please refer to the How it Works section.

Posted by & filed under HTML to PDF conversion.

One of the questions we regularly get is about page breaking. How does Webkit decide when the content is broken up into separate pages and how can you prevent that yourself?

First of all – if you have a lot of content, which normally spans multiple pages, you have a few options. First of all – you can set a different (bigger) page format (like A3, A2 or something) to prevent page breaking all together. Or you could apply the ‘fit to single page’ switch that we have developed. That would render one long page and you wouldn’t have to worry about page breaking at all anymore.

If you choose not to do those things, then you have to take into account that Webkit will start creating page breaks. It does so more or less arbitrarily. “Ouch” I hear you thinking. And that can indeed be uncomfortable.

You have to understand that any rendering engine continuously has to calculate which page can contain which content and has to take a lot of things into account, like the page dimensions and the content dimensions. The content dimensions in turn have many parameters – e.g. div sizing, font sizing, image sizes etc. Especially images will often make a rendering engine break the page before or after.

Now if you would like to be in control of page breaking yourself, you can apply an extra DIV at any point where you’d like to have a page break. You’d style that DIV with a class that incorporates a page break. That class, which we will call break, would look something like this:

<style type="text/css" media="screen,print">
.break {
display: block;
clear: both;
page-break-after: always;
}
</style>

You can see we’re using the page-break-after property to force the page break.

Now if you want to apply this, you’d add a DIV of class break in your HTML content and you’re ready to go.

Example

Suppose you’d like to create a two page PDF, of which the first page only says ‘Hello World!’ and the second page says ‘Goodbye World!’. You can use the following PDF to do so and force the page break with the DIV.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css" media="screen,print">
.break {
display: block;
clear: both;
page-break-after: always;
}
</style>
</head>
<body>
Hello World!
<div class="break"></div>
Goodbye World!
</body>
</html>

If you want to try this, then just copy and paste this HTML in our raw HTML to PDF converter.It will give you a PDF with two pages as intended and you can keep playing around with the content to get more examples yourself.

We hope this helps you create better PDFs and you won’t have to break your head anymore while doing it!

Posted by & filed under HTML to PDF SDK.

This post is intended to be a ‘Quick Start’ for people who want to use our HTML to PDF SDK and are looking for some examples to start with. In our documentation you will also find quite some examples and when you download the library you will notice that it contains a file with example code as well. So hopefully this post is not superfluous.

Our SDK is currently only available in PHP. It consists of a development library file, that you need to include in each PHP file that you want to use our conversion service with. We also recommend that you use a “Try / Catch” block so you can properly catch exceptions, should they occur. It will be very useful in case things go wrong.

Basic usage

The basic invocation of the HTML to PDF SDK is as follows. You first include the SDK library file (currently version 1.4) and then you use a Try / Catch block over the invocation of the service.

require 'htm2pdfapi.php';

Try {
$pdf = new Htm2PdfApi ($userid, $apikey);
....
} catch Exception($error) {
// do something with $error->getMessage() and/or $error->getCode()
}

Of course you should replace $userid and $apikey with the User ID and API key you receive from us when you register.

So far that’s quite simple, right? Now let’s look at some real examples.

Converting a URL to PDF

Let’s take an example where we would like to convert a URL (say http://www.bbc.co.uk) to PDF and let’s add in some custom settings like page size, margins and orientation.

You’d get something like this:

require 'htm2pdfapi.php';

Try {
$pdf = new Htm2PdfApi ($userid, $apikey); // initialize the API

$pdf->SetPageSize('Letter'); // this PDF will have page size 'Letter'
$pdf->SetPageOrientation('Portrait'); // we set the orientation to 'Portrait'
$pdf->SetMargins(5,5,5,5,'mm'); // we want 5mm margins all around

$pdf->CreateFromURL('http://www.bbc.co.uk'); // now execute the conversion

$pdf->Display(); // display the PDF as attachment
} catch Exception($error) {
// do something with $error->getMessage() and/or $error->getCode()
}

Converting raw HTML to PDF

Now you could also just convert raw HTML code to a PDF with the SDK. This is one of the four conversion methods (the others are converting a URL to PDF, converting a file to PDF and converting a custom form to PDF).

Let’s add in some custom watermarking settings as well on top of regular formatting options like page size, margins and orientation.

You’d get something like this:

require 'htm2pdfapi.php';

Try {
$pdf = new Htm2PdfApi ($userid, $apikey); // initialize the API

$pdf->SetPageSize('A4'); // this PDF will have page size 'A4'
$pdf->SetPageOrientation('Landscape'); // we set the orientation to 'Landscape'
$pdf->SetMargins(1,1,1,1,'in'); // we want 1 inch margins all around

$pdf->SetWatermarkLocation(100,100); // Let's put a watermark at (100,100)
// It will say 'DRAFT' in red Tahoma
$pdf->SetWatermarkText('DRAFT','Tahoma','#FF0000', 64);

$pdf->CreateFromHTML('<html>...</html>'); // now execute the conversion

$pdf->DisplayInline(); // display the PDF inline in the browser
} catch Exception($error) {
// do something with $error->getMessage() and/or $error->getCode()
}

Now these are just the most basic of examples that we just showed. The SDK can do much more, so if you’re really ready to get down with it you should absolutely check out the full documentation. And don’t forget – just sign up and get all the benefits now!

Posted by & filed under HTML to PDF API.

In this post we’ll show you a list of examples of using the HTML to PDF API. Each of these examples is intended as addition to the documentation, that explains all options.

The HTML to PDF API works in all programming languages. So you can invoke it in C#, Java, PHP, Ruby, Python, VB.NET or whatever else you want to use – as long as you can send HTTP requests.

In this post we’ll focus on just the calling of the API and not so much the implementation in any programming language. You’ll find documentation throughout the site on all the different langauges – particularly in the HTML to PDF API documentation.

Since we’re using a HTTP request to call the API, it’s just like typing in a URL in your browser window. So all the examples below will work by just entering them in the address bar of your Firefox, Opera, Chrome, Internet Explorer, Safari or whatever browser you have.

Below we’ll show you examples of how you can control the HTML to PDF API call to do more things with it.

Examples of different HTTP requests

To get a single page PDF of https://www.google.com, that’s 300mm wide

https://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=https://www.google.com&width=300

To return a PDF of https://www.bbc.co.uk protected with a password ‘htm2pdf’

https://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=https://www.bbc.co.uk&userpass=htm2pdf

To convert the URL https://www.cnn.com to PDF and setting the top and bottom margins to 20mm

https://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=https://www.cnn.com&top=20&bottom=20&unit=mm

To convert https://www.baidu.com and apply our logo as watermark, rotated at 45 degrees.

https://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=https://www.baidu.com&wm=https://www.htm2pdf.co.uk/img/logo.png&wm_angle=45

Hopefully these examples show you how easy, yet powerful this functionality is. Of course you can also pass a lot of the parameters together. If you want to learn more about it then please check out the HTML to PDF API documentation. If you want to use this in our application or on your website today, then please Join our service.

Posted by & filed under Save as PDF.

In this post we’ll show you a list of examples of using the ‘save as PDF’ functionality. Each of these examples is intended as addition to the documentation, that explains all options.

The goal of our “save as PDF” service is to give website owners the possibility of adding a simple link to their pages and thereby allowing their visitors to save certain pages as PDF. Since we feel that it’s often important to control the sizing, layout and other aspects of the PDF, we’ve added a lot of functionality to this service. Part of this functionality is controlled in the members area, where you can set defaults for your conversions, and the rest is controlled by adding parameters to the link you put on your site.

In the table below we’ll show you examples of how you can control the ‘save as PDF’ link to do more things with it.

Description with HTML code – click to see it work
To get a single page PDF, that’s 300mm wide
<a href=”http://www.htm2pdf.co.uk/display?width=300&unit=mm”>Save as PDF</a>
To return the ‘faq’ page as PDF instead of the current page
<a href=”http://www.htm2pdf.co.uk/display?url=http://www.htm2pdf.co.uk/faq”>Save as PDF</a>
To set the filename of the PDF to ‘saveaspdf.pdf’
<a href=”http://www.htm2pdf.co.uk/display?filename=saveaspdf.pdf”>Save as PDF</a>
To set the top and bottom margins to 0 (mm is default)
<a href=”http://www.htm2pdf.co.uk/display?top=10&bottom=10″>Save as PDF</a>

Hopefully these examples show you how easy, yet powerful this functionality is. Of course you can also pass a lot of the parameters together. If you want to learn more about it then please check out the Save as PDF page. If you want to have this on your website today, then please Join our service.

Posted by & filed under HTML to PDF conversion.

Right now we’re preparing a showcase of our PDF creation possibilities. The idea is to give a quick overview of all the possibilities that are different services offer through a gallery of PDFs.

At the moment we’re thinking of showing examples of the following:

  • page formats like A3, A4, Letter, custom page formats and single page PDF
  • page orientation (portrait vs landscape)
  • character set support (arabic, asian, cyrillic, western etc.)
  • CSS support
  • Javascript support
  • PDF encryption and password protection
  • watermarking and stamping

These are essentially the highlights of our different services. As you may be aware of most of these are included in all our services. Only the encryption and watermarking capabilities are reserved for the HTML to PDF API and SDK.

Please let us know if you have any special requests for the showcase. This can be a specific example of functionality (like page breaking or the use of margins or something), an example of a type of document (invoice, timesheet or whatever you’d like to see) or maybe your own URL?