Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

JavaScript Sample code

Details about using the Muhimbi PDF Converter Services Online from JavaScript, can be found below.

If a cloud-based service is not suitable to your needs (e.g. for security or regulatory reasons), and you have the ability to deploy software to your own (Windows) server, then check out the Muhimbi PDF Converter Services.


Table of contents


Prerequisites

There are very few prerequisites to run these samples. A modern browser and an internet connection (to fetch jQuery and talk to the REST API) is all that is needed.


Client libraries

Unlike our sample code for other languages, the JavaScript samples do not depend on pre-generated client libraries. JavaScript can deal with REST / JSON natively. Adding pre-generated client libraries will just complicated matters.

You are naturally free to take our Swagger API definition file, load it into editor.swagger.io, and generate JavaScript clients.

The steps are as follows:

  1. Open editor.swagger.io
  2. From the File menu select Import URL
  3. Enter https://github.com/raw/Muhimbi/PDF-Converter-Services-Online/master/swagger/v1/muhimbi-pdf-online-swagger.json
  4. From the Generate Client menu select the language of your choice.

Sample code

Sample code, and related files, for the various facilities provided by this service can be found below. It is recommended to copy all samples to your local system using one of the following options:

  • Git: Use the following command to clone the entire repository to your system. This will download all files associated with this repository, and is most likely overkill, but it is the only easy way to download files using Git. Once downloaded, you can find the examples under the clients/v1/javascript/samples folder.

    git clone https://github.com/Muhimbi/PDF-Converter-Services-Online/

  • SVN: A common trick to download only part of a Git repository is to use svn. Download only the JavaScript sample code using the following command.

    svn export https://github.com/Muhimbi/PDF-Converter-Services-Online/trunk/clients/v1/javascript

  • ZIP: Download a ZIP archive of the entire repository. Once downloaded, you can find the examples under the clients/v1/javascript/samples folder.


An example is provided for each individual REST endpoint. A full overview can be found below.

Sample Description
convert Convert a single file to PDF or other supported output format.
convert_html Convert an HTML fragment, or URL, to PDF.
merge_to_pdf Combine multiple files, and URLs, into a single PDF.
merge_to_pdf (SharePoint) Combine multiple SharePoint files (by path), and URLs, into a single PDF.
ocr_pdf Convert a scan, fax or other image into a searchable PDF.
ocr_text Use OCR to extract text from a scan, fax or other image.
secure_pdf Apply security settings, passwords and restrictions to a PDF.
split_pdf Split a large PDF into smaller PDFs.
watermarking
   text_watermark Add a simple text watermark to a PDF file.
   rtf_watermark Add a rich text (RTF) based watermark to a PDF file.
   image_watermark Add an image based watermark to a PDF file.
   qr_code_watermark Add a QR Code to a PDF file.
   pdf_watermark Add a PDF based watermark to a PDF file.
   ellipse_watermark Add an ellipse based watermark to a PDF file.
   line_watermark Add a line based watermark to a PDF file.
   rectangle_watermark Add a rectangle based watermark to a PDF file.
   composite_watermark Add a number of different watermarks to a PDF file in a single operation.

API / Documentation

Although the API is largely self-describing, from time to time it may be easier to consult the full API documentation. An overview of the entire object model can be found in the Wiki.


If you have any questions or comments then please contact our friendly support desk.