Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Development and suggestions about third part tool integration.
Cordova, Xamarin, Basic4Android topics are listed here.
  • Page:
  • 1

TOPIC:

Using annotations with Cordova plugin 7 years 1 month ago #11994

  • davosp
  • davosp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
I've been trying to use annotations and other features with cordova plugin vuit i get an alert that says: "This document is readonly" when i try to use annotations

This is my controller:
var app = {
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },

    onDeviceReady: function() {
        var parentElement = document.getElementById('deviceready');
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        document.getElementById('loadpdf').addEventListener(
            'click',
            function(e) {
                RadaeePDFPlugin.openFromAssets({
                    url: 'www/A1. Manual.pdf',
                    password: ''
                }, function(message) {
                    console.log('Success: ' + message);
                }, function(err) {
                    console.log('Failure: ' + err);
                });          
            }
        );

        if (device.platform === 'Android') 
        {
            xhr = new XMLHttpRequest();
            xhr.open('GET', './A1. Manual.pdf', true);
            xhr.responseType = 'blob';

            xhr.onload = function() {
                var blob;

                if (this.status === 200) {
                    blob = new Blob([this.response], { type: 'application/pdf'});

                    window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
                        dir.getFile('A1. Manual.pdf', { create: true, exclusive: false }, function(file) {
                            file.createWriter(function(fileWriter) {
                                fileWriter.onwriteend = function() {
                                    console.log('Successful file write: ' + file.toURL());
                                };

                                fileWriter.onerror = function(e) {
                                    console.log('Failed file write: ' + e.toString());
                                };

                                fileWriter.write(blob);
                            });
                        });
                    });
                } else {
                    console.log('problem: ' + this.status);
                }
            } ;

            xhr.send();   
        } else {
            // iOS
            RadaeePDFPlugin.activateLicense({
                licenseType: 2,
                company: "Radaee",
                email: "radaee_com@yahoo.cn",
                key: "89WG9I-HCL62K-H3CRUZ-WAJQ9H-FADG6Z-XEBCAO"
            }, function(message) {
                console.log('Activated license');
            }, function(message) {
                console.log('License Activation failed');
            });
        }
    }
};

app.initialize();

Please Log in or Create an account to join the conversation.

Using annotations with Cordova plugin 7 years 1 month ago #11999

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
You are using openFromAssets, and files opened from Assets cannot be modified.

You need to copy your file to the device, and use open instead:
RadaeePDFPlugin.open(
    {
        url: "", //The path of the pdf to open, ex: "file:///mnt/sdcard/Download/Test.pdf"
        password: "" //password if needed
    },
    function(message) {
         console.log("Success: " + message);
    },
    function(err){
        console.log("Failure: " + err);
    });

Please Log in or Create an account to join the conversation.

Last edit: by nermeen.

Using annotations with Cordova plugin 7 years 1 month ago #12010

  • davosp
  • davosp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
I tried to build for my iPhone but i can't because the bundle id must be com.radaee.pdf.PDFViewer and it doesn't let me build the app for devices, so i just can test the app on iOS simulator. Is there any way to test on my iPhone?

Please Log in or Create an account to join the conversation.

Using annotations with Cordova plugin 7 years 1 month ago #12016

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Have you set your team in General tab of Xcode project settings?

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum