2.0.0 • Published 4 years ago

angular-create-pdf v2.0.0

Weekly downloads
134
License
MIT
Repository
github
Last release
4 years ago

angular-create-pdf

angular5+以上的版本可以使用

1、开始使用

  • 安装
  • 使用

安装

npm i angular-create-pdf

使用

AngularCreatePdfModule需添加到使用的module的文件中。此处以AppModule为例:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AngularCreatePdfModule } from 'angular-create-pdf';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AngularCreatePdfModule,
    AppRoutingModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
import { Component, OnInit } from '@angular/core';
import { AngularCreatePdfService } from 'angular-create-pdf';

@Component({
  selector: 'app-pdf-demo',
  template: `
    <div #pdfContainer>
      <p>A cookie associated with a cross-site resource at  was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at  and .</p>
    </div>

    <button (click)="createPdfTem(pdfContainer)">生成PDF</button>
  `
})
export class AppPadDemoComponent {
   constructor(
    private pdfService: AngularCreatePdfService,
  ) { }

  ngOnInit() {    
  }

  public createPdfTem(ele: any) {
    this.pdfService.createPdf(ele, '我的PDF');
  }

}