PDFkind
Tài liệu cho nhà phát triển: Angular

Trợ lý tải lên

Angular

Giảm dung lượng PDF và ảnh trước khi tải lên trong ứng dụng Angular, chỉ với một thuộc tính trên ô chọn file.

Thêm script vào src/index.html, rồi thêm thuộc tính vào ô chọn file. Hàm xử lý (change) của bạn sẽ nhận file đã giảm dung lượng.

src/index.html
<script src="https://pdfkind.com/embed.js" defer></script>

Ô chọn file

component.html
<input type="file" data-pdfkind-max="5MB" (change)="onFile($event)" />
component.ts
onFile(event: Event) {
  const file = (event.target as HTMLInputElement).files?.[0];
  if (file) this.upload(file);   // file đã giảm dung lượng
}

Tự gọi hàm

TypeScript
declare global { interface Window { PDFkind: { fit(f: File, o: { max: string | number }): Promise<File> } } }

const small = await window.PDFkind.fit(file, { max: '5MB' });

Cập nhật lần cuối 3 tháng 11, 2026 · Câu hỏi: contact@pdfkind.com