แบบรูป STP

การส่งออกไฟล์ STP ไปยัง PNG

Aspose.CAD สำหรับ Javascript ใน Angular ช่วยให้นักพัฒนาสามารถส่งออกไฟล์ STP เป็นรูปแบบ PNG ได้ วิธีการแปลง STP เป็น PNG ทำงานดังนี้:

  1. โหลดไฟล์แบบรูป STP โดยใช้วิธี Image.load
  2. เรียกใช้ Image.save โดยส่งวัตถุของ PngOptions เป็นพารามิเตอร์ที่สอง

ตัวอย่างโค้ด

โค้ดด้านล่างแสดงให้เห็นว่า วิธีการเดียวกันนี้สามารถทำได้โดยใช้ Aspose.CAD สำหรับ JavaScript

async onFileSelected(event) {
const file: File = event.target.files[0]; //file.stp
file.arrayBuffer().then(async buff => {
let x = new Uint8Array(buff);
this.imgFile = await Image.load(x);
var exportedFile = await Image.save(this.imgFile, new PngOptions());
var blob = new Blob([exportedFile], { type: 'application/octet-stream' });
});
}