移动应用程序是使用angularJs开发的离子1 . 现有应用程序为选定图像生成pdf文件,但需要将图像添加到现有pdf文件 . 图像转换为base64字符串并使用JSPDF生成pdf .

从本地存储中选择图像

$scope.addImages = function (options) {

    var options = {
        quality: 10,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        allowEdit: true,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 1024,
        targetHeight: 768,
        popoverOptions: CameraPopoverOptions
    };

    $cordovaCamera.getPicture(options).then(function(imageData) {

        //Convert image to Base64
        function convertImgToBase64(url, callback, outputFormat){
            var canvas = document.createElement('CANVAS'),
                ctx = canvas.getContext('2d'),
                img = new Image;
            img.crossOrigin = 'Anonymous';

            img.onload = function(){
                var dataURL;
                canvas.height = img.height;
                canvas.width = img.width;
                ctx.drawImage(img, 0, 0);
                dataURL = canvas.toDataURL(outputFormat);
                callback.call(this, dataURL);
                canvas = null;
            };
            img.src = url;
        }

        $ionicLoading.show({
            content: 'Loading..',
            animation: 'fade-in',
            showBackdrop: true,
            maxWidth: 200,
            showDelay: 0
        });

        convertImgToBase64(imageData, function(base64Img){
            // Base64DataURL
            $scope.images.push(base64Img);
            $ionicLoading.hide();

        });
    }, function(err) {
        alert(err);
    });
};

用于文件选择的插件

cordova-plugin-custom-filechooser 1.0.1“自定义文件选择器”

customFileChooser.open('application/pdf',function (uri){

       alert(uri);

}, function(err){
      console.log(err);
});

这给出了.pdf的本地路径URI .

请帮我将图像添加到离子1中的现有pdf中 .