如何在angular 4中导出为pdf

时间:2018-11-11 17:34:59

标签: angular

我有一个要分页导出为pdf的现有表 任何想法如何?  我看到了

https://www.telerik.com/kendo-angular-ui/components/grid/export/pdf-export/

但是看起来这是试用期

也可以在现有表上使用它,还是需要再次构建表

这是我当前的代码

    <div class="p-grid">
  <div class="p-col">
        <div >
        <p-table #table [value]="dashboardDisplay" [rows]="15" [paginator]="true" [responsive]="true" autoLayout ="true">
          <ng-template pTemplate="header">
            <tr>
              <th>feedback #</th>
              <th>Creation date</th>
              <th>Phone number</th>
              <th>UMN</th>
              <th>First name</th>
              <th>Middle name</th>
              <th>Last name</th>
              <th>Category name</th>
              <th>Question</th>
              <th>Answer</th>
            </tr>
          </ng-template>
          <ng-template pTemplate="body" let-dashboardDisplay >
            <tr *ngIf="dashboardDisplay.categoryId==categoryId || categoryId ==0 ">
              <td>{{dashboardDisplay.surveyId}}</td>
              <td>{{dashboardDisplay.creationDate | date}} </td>
              <td>{{dashboardDisplay.phoneNumber}}</td>
              <td>{{dashboardDisplay.umn}}</td>
              <td>{{dashboardDisplay.firstName}}</td>
              <td>{{dashboardDisplay.middleName}}</td>
              <td>{{dashboardDisplay.lastName}}</td>
              <td>{{dashboardDisplay.categoryName }}</td>
              <td>{{dashboardDisplay.question}}</td>
              <td>{{dashboardDisplay.answer}}</td>
            </tr>
          </ng-template>
        </p-table>
    </div>
  </div>
</div>

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

免费的替代方案:PDFKit,但您需要使用纯JS构建表