The plugin is exposed via the cordova.plugins.image2pdf
object, which converts an image file into a PDF file.
cordova plugin add https://github.com/mbackschat/cordova-plugin-image2pdf.git
Converts the image at the given file path to a PDF file.
- source image file path (String)
- if relative then "
<mainBundle:resourcePath>/www
" is prepended ~
gets expanded. Example."~/tmp/input.jpg"
- if relative then "
- target PDF file path (String)
- if relative then "
~/tmp
" is prepended ~
gets expanded. Example."~/tmp/output.pdf"
- if relative then "
- onSuccess callback is called without parameters
- onError callback is called with error code (Int)
- error code == 1: Image file not found,
- error code == 2: PDF file write error
// source: www/test.jpg
// target: ~/tmp/test.pdf
cordova.plugins.image2pdf.convert("test.jpg", "test.pdf",
function () { console.log("Done") },
function (code) { console.log("Error code " + code) })
- iOS
- Supported image file formats: .png, .tiff/.tif, .jpeg/.jpg, .gif, .bmp/.BMPf, .ico, .cur, .xbm
See also Apple documentation.
- Supported image file formats: .png, .tiff/.tif, .jpeg/.jpg, .gif, .bmp/.BMPf, .ico, .cur, .xbm