NeutrinosPlatform / cordova-plugin-document-scanner

cordova plugin for document scan
https://www.neutrinos.co/
MIT License
84 stars 63 forks source link

How i will set url path when i am store this path in a variable #40

Closed praveenppass closed 5 years ago

praveenppass commented 5 years ago

hi i am store path in a variable when success scan and i am getting image url path but when i am store then getting error on below.

Uncaught TypeError: Cannot set property 'img_URL' of null
    at scanSuccess (main.js:82)
    at Object.callbackFromNative 
ChrisTomAlx commented 5 years ago

Could you share your code please?

Cheers, Chris Neutrinos

praveenppass commented 5 years ago

my Ts File...

  scanDocImg: any;
docScanner() {
    let actionSheet = this.actionSheetCtrl.create({
      buttons: [
        {
          text: 'Use Library',
          handler: () => {
            scan.scanDoc(0, scanSuccess, scanError);
          }
        }, {
          text: 'Capture Image',
          handler: () => {
            scan.scanDoc(1, scanSuccess, scanError);
          }
        }, {
          text: 'Cancel',
          role: 'cancel'
        }
      ]
    });
    actionSheet.present();

    function scanSuccess(imageURI) {
      let img_URL = `${imageURI}`;
      if (img_URL) {
        this.scanDocImg = img_URL;
      }
    }
    function scanError(message) {
      console.log(`Failed because: ${message}`);
    }
  }

My Html Page --

 <ion-card *ngIf="scanDocImg">
      <ion-card-header>
        <img [src]="scanDocImg" style="width: 100%;">
      </ion-card-header>
      <ion-card-content>
          <ion-fab>
              <button ion-fab color="light" (click)="share(img_URL)"> <ion-icon name="share"></ion-icon></button>
            </ion-fab>
      </ion-card-content>
    </ion-card>
praveenppass commented 5 years ago

capture

ChrisTomAlx commented 5 years ago

Could you try setting the image src directly from the imgURI. Without the $ and the img_URL variable? I'm not sure about TS but that's how I do it in JS

Cheers, Chris Neutrinos

praveenppass commented 5 years ago

Yes I was useing without $ but both response is same please suggest how I will add in ionic3

ChrisTomAlx commented 5 years ago

So you tried this? this.scanDocImg = imageURI;

And Still you got the same error? But when you console log imageURI you're getting the file location. Am I correct?

Cheers, Chris Neutrinos

ChrisTomAlx commented 5 years ago

I retested on JavaScript and I am able to use the image Id and src to set the image using the imageURI directly as given in the example in the readme.

You can check out this issue for how we used this plugin in ionic 2 (https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/17).

But I think since you are getting the location of the file correctly, the plugin is working as intended. All that needs to be done is to figure out how to display an image in an tag using the imageURI.

Cheers, Chris Neutrinos

praveenppass commented 5 years ago

Yes i am getting in console but when i want to store this value in this.scanDocImg then i getting these issue where i was share image.

ChrisTomAlx commented 5 years ago

@praveenppass

I hope you closed the issue because you solved it. If so I am glad you did but could you leave the solution as a message? It would be helpful to future users!

Cheers, Chris Neutrinos