Showing posts with label Angular. Show all posts
Showing posts with label Angular. Show all posts

jsPDF problem Resolved || Angular, JavaScript save the text, image to pdf.


import * as jsPDF from 'jspdf';

toPdf(abc:string){
var doc = new jsPDF()
 
doc.text(abc, 10, 10)
doc.save('a4.pdf')
}

<div class="my-1">
  <input class="form-control" #todoText />
  <button class="btn btn-primary mt-1">
  Add
  </button>
  <button class="btn btn-primary mt-1" (click)="toPdf(todoText.value)">
    PDF
    </button>
  </div>

First Try

Windows PowerShell

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Home\todo> npm install jspdf
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:


Second Try

PS D:\Home\todo> npm install @types/jspdf
npm WARN ajv-keywords@3.4.1 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 1 package from 5 contributors and audited 41096 packages in 7.924s
found 8 vulnerabilities (3 low, 3 moderate, 2 high)

  run `npm audit fix` to fix them, or `npm audit` for details


___________________

PS D:\Home\todo> ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
                                                                                         
Date: 2020-01-17T06:39:11.440Z
Hash: b734fb7535fc49908081
Time: 8609ms
chunk {main} main.js, main.js.map (main) 14.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 241 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 178 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.54 MB [initial] [rendered]

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'jspdf' in 'D:\Home\todo\src\app'
i 「wdm」: Failed to compile.

Third Try

PS D:\Home\todo> ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
                                                                                         
Date: 2020-01-17T06:39:11.440Z
Hash: b734fb7535fc49908081
Time: 8609ms
chunk {main} main.js, main.js.map (main) 14.2 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 241 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 178 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.54 MB [initial] [rendered]

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'jspdf' in 'D:\Home\todo\src\app'
i 「wdm」: Failed to compile.


Fourth Try  -  Compiled successfully...


PS D:\Home\todo> npm install jspdf@1.4.1 --save
npm WARN ajv-keywords@3.4.1 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ jspdf@1.4.1
added 25 packages from 67 contributors and audited 41208 packages in 10.48s
found 8 vulnerabilities (3 low, 3 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details


____________________________________


PS D:\Home\todo> ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
                                                                                         
Date: 2020-01-17T07:40:48.574Z
Hash: 3fee450eb7ef7d427ce0
Time: 6258ms
chunk {main} main.js, main.js.map (main) 14.3 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 241 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 178 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.85 MB [initial] [rendered]
i 「wdm」: Compiled successfully.

Web API with Angular 8/7/6/5/4

Step 1 : Create Empty Web API application using Visual Studio 13/15/17/19

Step2: In Solutions Explorer > Model> Right Click> Add > Class

Students.cs

public class Students
    {
        public int SId{ get; set; }
        public string SName { get; set; }
        public string Email { get; set; }
        public string Course { get; set; }
    }

Step3: In Solutions Explorer > Controller > Right Click> Add > Controller

StudentController


IList Students = new List()  
        { 
            new Students() 
                { 
                    SId = 1, SName = "Smith", Email = "sm@Delhi.com", Course = "Networking" 
                }, 
                new Students() 
                { 
                    SId = 2, SName = "Jone Doe", Email = "jd@London.co.uk", Course = "Cyber" 
                }, 
                new Students() 
                { 
                    SId = 3, SName = "Kila Mek", Email = "km@white.com", Course = "IT" 
                }, 
                new Students() 
                { 
                    SId = 4, SName = "Ros Lin", Email = "Ros@Goa.in", Course = "Hacking" 
                }, 
                new Students() 
                { 
                    SId = 5, SName = "S Chandra", Email = "som@banglore.in", Course = "Software" 
                }, 
        };
        //get api/student
        public IList GetAllStudents()
        {
            //Return list of all employees   
            return Students;
        }

        //get api/student/5
        public Students GetStudentDetails(int id)
        {
            //Return a single employee detail   
            var Student = Students.FirstOrDefault(e => e.SId == id);
            if (Student == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            return Student;
        } 


Step4: Build and Debug.
 Api Successful Created.....



Now open cmd - Command Prompt



Angular CLI - export 'STEPPER_GLOBAL_OPTIONS' was not found in '@angular/cdk/stepper'

WARNING in ./node_modules/@angular/material/esm5/stepper.es5.js 314:83-105
"export 'STEPPER_GLOBAL_OPTIONS' was not found in '@angular/cdk/stepper'
i 「wdm」: Compiled with warnings.

Hash: 0beb1770994f84cb59ca
Time: 19435ms
chunk {main} main.js, main.js.map (main) 45.6 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 203 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.87 MB [initial] [rendered]



caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`.

Comments

Angular CLI - export 'CDK_TREE_NODE_OUTLET_NODE' was not found


styles.cssBrowserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist



WARNING in ./node_modules/@angular/material/esm5/tree.es5.js 38:63-88
"export 'CDK_TREE_NODE_OUTLET_NODE' was not found in '@angular/cdk/tree'

WARNING in ./node_modules/@angular/material/esm5/tree.es5.js 168:35-60
"export 'CDK_TREE_NODE_OUTLET_NODE' was not found in '@angular/cdk/tree'

WARNING in ./node_modules/@angular/material/esm5/stepper.es5.js 314:83-105
"export 'STEPPER_GLOBAL_OPTIONS' was not found in '@angular/cdk/stepper'
i 「wdm」: Compiled with warnings.


Social Media