HTML to PDF API with CSS2 and Java. Script. Convert HTML to PDF in C#/Java/PHP/Ruby/Python/. NET/Perl etc. Our HTML to PDF API allows you to convert HTML to PDF files with great ease, power and performance. You can use it manually and in any programming language. You will get a lot of different settings to optimize your conversion and make sure the PDF looks exactly the way YOU want it. Some of the use cases for our API are: You want to generate PDF forms like proposals / invoices / timesheets etc. You want to generate PDFs from data in a database and you know how to create regular web pages from the database. You want to generate reports as PDFYou want to not only display a PDF, but also save it as a local file and then choose what you want to do with it. You want to create PDFs from different sources and merge them into one bigger PDF New! You want to create professional PDFs and use your own stationary as background New! Here’s how easy it is: suppose you’d like to convert the web page http: //www. PDF. You would just send the following HTTP request to get the PDF: http: //api. Note All the examples below show the examples based on HTTP GET, but you can also use HTTP POST to access our API! If you want to see how you do this in C# / Java / PHP / Ruby / Python / VB. Perl then click here to go directly to the coding examples. We have established a network of GLOBAL servers, which allows you to choose a server close to you to do the conversion so the PDF is served to you with the lowest latency possible. Choose the API call of your choice for the data center closest to you. Data center. API call. Europe (London, UK)http: //europe. USA (Atlanta, USA)http: //usa. Asia (Tokio, Japan)http: //asia. Basic function parameters. The following choices represent the basic functions you can execute with the API – you can either convert from a URL or raw HTML, or you can MERGE previous conversions together into one file. New! Raw HTML code that you’d like to have converted. We recommend you POST the data to our API whenever you want to use raw HTML code, because appending this to the query string has limitations to the length of the HTML code. Also – when you don’t POST the data you should make sure to encode the HTML properly. Parameter. Descriptionurl. URL of the web page that you’d like have converted. Note that you must properly escape the ampersands (& ) if you want to pass additional query parameters (more info in our blog). The URL must also include the whole domain including the . After two hours we delete your PDFs from our cache and they can no longer be merged. Layout parameters. By default the PDF will be created with the conversion settings you set in the members area.
There you can set page format, margins, header & footer and other important settings. We allow you to override most of these in each conversion. You can do so with the parameters in the tables below. Parameter. Descriptionfilename. Filename for the PDFpagesize. Set page size like A3, A4, Letter etc. Please refer to the list of allowed page sizesorientation. Specify portrait or landscape orientationwidth. Custom width of the PDFheight. Custom height of the PDF, if you specify the width, but not the height, then we fit the whole page into a one page PDF by auto- adjusting the height of the PDF. Left marginright. Right margintop. Top marginbottom. Bottom marginunit. Unit for size & margin settings. We’ll use mm in case you don’t specify a unit. Page numbering etc is explained in the members area. Page numbering etc is explained in the members area. This should be a valid URL (starting with http: // or https: //) – to a location where you defined your header HTML. Page numbering etc is explained in the members area. This should be a valid URL (starting with http: // or https: //) to a location where you defined your footer HTML. Page numbering etc is explained in the members area. Page offset, which is used to adjust page numbering in your header and footer. Please also have a look at your members area for more details. Set the CSS media type so you can influence better how your content is converted to PDF. We currently support the values print and screen. If you don’t specify one, we take the one you’ve set in the members area. The default there is screen. See w. 3schools for more information on CSS media types. Print will normally give you a more print- friendly layout. If you set this to y we will return a URL to the PDF on our server instead of the actual PDF. This allows you to generate the PDF, without having to use bandwith to serve it to your visitors. Use this parameter to render your PDF with Java. Script on or off. How to convert HTML to PDF using iText. This is my code to convert HTML to PDF. Written in 100% pure Java, ported to managed.NET code. HTML-to-PDF conversion with Java or JSP taglib.NET port of PD4ML. HTML-to-RTF conversion for Java and.NET. Use this parameter to set the time in milliseconds that we take to complete Java. Script processing. Note on measurements: in case you only specify a height then we’ll ignore it; In case you only specify a width we’ll assume you want a single page PDF. In case you specify one or more margins, but not all, we’ll assume the others to be 0. Encryption and password protection. You can also use encryption settings to encrypt the PDF we generate and – if you want – you can protect it with a password or use rights management to control which things the user is allowed to do with the PDF. The below table lists all the options you can pass for this. Parameter. Descriptionencryption. The level of encryption for the PDF. You can choose the following values: 4. RC4 encryption. 1. RC4 encryption, requires Acrobat reader 5 or later. AES encryption, requires Acrobat reader 7 or later. AES encryption, requires Acrobat reader X or laterownerpass. The master password that controls all encryption & rights settings for the PDF. The password a user needs to open the PDF. If set, Acrobat Reader will prevent users from printing the PDF. If set, Acrobat Reader will prevent users from copying content from the PDF. If set, Acrobat Reader will prevent users from modifying the PDF. Watermarking and stamping your PDFIn some cases you’d like to watermark your PDF, e. The below table lists all the options you can pass for this. Note that we consider stamping the same as watermarking, because if you use an opacity of 1 (fully opague) your watermark will come out like a stamp. Parameter. Descriptionwm. The full URL where we can find the image you want to use as watermark. Please make sure the image is really there. This is a “real” number between 0 and 1. If you want it twice as wide, set this to 2. If you want it half as high, set this to 0. Stationary aka (full) page background New! If you want your company’s PDFs to have your own stationary as background – then look no further. The API allows you to set your own stationary (or page background) for the pages of the PDF. You can use the same image for all the pages, or you can have a different image for the first page, the last page and all pages in between. The image will be set as background, so all items you have in your HTML will appear over it. Note that non- transparent images or CSS background- color will be rendered OVER this. As opposed to watermarks, which start (by default) in the top left corner of the CONTENT area, stationary starts at the top left corner of the full page. That’s also why we call it stationary as it resembles a real piece of paper. Parameter. Descriptionbg. The full URL where we can find the image you want to use as stationary for the first page. Please make sure the image is really there. If you don’t specify bg. ALL your pages. bg. The URL where we can find the image you want to use as stationary for the pages in between the first and last page. The URL where we can find the image you want to use as stationary for the last page of your PDF. This is a “real” number between 0 and 1. This then sets positioning and angle of rotation to 0. This then sets positioning and angle of rotation to 0. Authorization – converting content in your members area or authorization protocols. We understand that you can have content, which is only accessible to your private users, and still want to have it converted to PDF. We can surely help you with this. We first of all would recommend you to POST the data to our servers in the form of raw HTML in case you don’t want it to be accessed from outside your servers. We can also access your content over basic HTTP authentication with the parameters below. Furthermore we can utilize any other authorization protocol to access your content as long as you give us the specifics. Please contact us for more details. Parameter. Descriptionhttpuser. The user name you want us to use for the authenticationhttppass. The password you want us to use for the authentication. We’ve made examples that show you how to use the HTML to PDF API for URL to PDF conversion in all major programming languages below. If you feel we need to add examples or if you think there’s a better way of doing things, then please give us a shout out! It is very easy to convert a URL to PDF in PHP with our API. Just get the result of our URL with the PHP function get. In that case you just add the parameters that you found in the tables above. Say you want to convert http: //www. PDF with width 3. You’ve subscribed to our service and your API key is abcde. Therefore you want to send the following HTTP request: http: //api. You can use the following code in PHP to realize this. Just get the result of our URL with the Ruby class Net: :HTTP. Say you want to convert http: //www. PDF. You’ve subscribed to our service and your API key is abcde. This means you would want to send the following HTTP request: http: //api. You can use the following code in Ruby to accomplish this and get the PFD saved as . Just get the result of our URL with the C# Web. Client method. Say you want to convert http: //www. PDF. You’ve subscribed to our service and your API key is abcde. Therefore you want to send the following HTTP request: http: //api. You can use the following code in C# to accomplish this and save the PDF as . Just get the result of our URL with the VB. Web. Client. Let’s say as an example you want to convert http: //www.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |