ลบบันทึกย่อจาก PowerPoint ด้วย C# REST API

บทความนี้แนะนำวิธี ลบบันทึกจาก PowerPoint ด้วย C# REST API คุณจะได้เรียนรู้วิธี วิธีลบบันทึกย่อทั้งหมดใน PowerPoint ด้วย C# Low Code API โดยใช้ Cloud SDK ที่ใช้ .NET โดยจะให้โค้ดตัวอย่างสำหรับการลบสไลด์บันทึกย่อ จากนั้นจึงยืนยันการลบบันทึก

ข้อกำหนดเบื้องต้น

ขั้นตอนในการลบบันทึกย่อทั้งหมดออกจาก PowerPoint ด้วย C# REST API

  1. เริ่มต้นไคลเอ็นต์ API โดยใช้คลาส SlidesApi พร้อมข้อมูลรับรองสำหรับการลบบันทึก
  2. อัปโหลดงานนำเสนอพร้อมบันทึกย่อโดยใช้เมธอด UploadFile()
  3. เรียกเมธอด DeleteNotesSlide() โดยใช้ชื่อไฟล์ที่อัปโหลดและหมายเลขสไลด์เป้าหมาย
  4. แสดงข้อความเพื่อแสดงว่าบันทึกย่อถูกลบออกจากสไลด์เป้าหมาย
  5. ดาวน์โหลดงานนำเสนอที่อัปเดตหลังจากลบบันทึกย่อแล้ว

ขั้นตอนเหล่านี้อธิบาย วิธีการลบบันทึกย่อใน PowerPoint ด้วยอินเทอร์เฟซ C# REST อัปโหลดการนำเสนอเป้าหมายไปยังที่เก็บข้อมูลบนคลาวด์และเรียกใช้เมธอด DeleteNotesSlide() โดยระบุชื่อไฟล์และสไลด์เป้าหมาย ทำซ้ำขั้นตอนนี้กับสไลด์ทั้งหมดในงานนำเสนอและบันทึกเอาต์พุตลงบนดิสก์

รหัสเพื่อลบบันทึกย่อทั้งหมดใน PowerPoint ด้วยอินเทอร์เฟซ C # REST

using Aspose.Slides.Cloud.Sdk;
using Aspose.Slides.Cloud.Sdk.Model;
using System;
using System.IO;
namespace PresentationModifier
{
class SlideNotesRemover
{
static void Main(string[] args)
{
// Initialize the API client with credentials
var slidesApi = new SlidesApi("ID", "Secret");
// Define the presentation file name
string presentationFile = "PresentationExample.pptx";
// Upload the presentation to the server
var uploadResponse = slidesApi.UploadFile(presentationFile, new MemoryStream(File.ReadAllBytes(presentationFile)));
// Specify the slide number to modify (changed to slide 2)
int targetSlideNumber = 2;
// Remove the notes slide from the specified slide
Slide updatedSlide = slidesApi.DeleteNotesSlide(presentationFile, targetSlideNumber);
// Check if the notes slide exists after the operation
bool isNotesSlidePresent = updatedSlide.NotesSlide != null;
Console.WriteLine("Notes slide present: " + isNotesSlidePresent);
// Download the updated presentation from the server
Stream updatedFileStream = slidesApi.DownloadFile(presentationFile);
// Save the modified presentation locally
using (var fileStream = new FileStream("ModifiedPresentation.pptx", FileMode.Create, FileAccess.Write))
{
updatedFileStream.CopyTo(fileStream);
}
Console.WriteLine("Presentation updated and saved as 'ModifiedPresentation.pptx'.");
}
}
}

รหัสนี้ได้สาธิต วิธีการลบบันทึกย่อใน PowerPoint ด้วย C# REST Interface คุณสามารถใช้แฟล็ก NotesSlide เพื่อตรวจสอบว่าบางสไลด์มีบันทึกย่ออยู่ก่อนและหลังการลบบันทึกหรือไม่ หากต้องการตรวจสอบการมีอยู่ของสไลด์บันทึกย่อ ให้ใช้เมธอด NotesSlideExists()

บทความนี้ได้สอนเราถึงวิธีการลบบันทึก หากต้องการเพิ่มบันทึกลงในงานนำเสนอ โปรดดูบทความเกี่ยวกับ เพิ่มบันทึกย่อลงในสไลด์ PowerPoint ด้วย C# REST API

 ไทย