# 在 C++ 中擷取與更新簡報資訊

> 使用 C++ 探索 PowerPoint 與 OpenDocument 簡報的投影片、結構與中繼資料，以獲得更快速的洞察與更智慧的內容稽核。

Source: https://docs.aspose.com/slides/zh-hant/cpp/examine-presentation/


## **概觀**

本文說明如何在 Aspose.Slides 中檢查簡報資訊。它解釋如何在不載入完整檔案的情況下判斷簡報的目前格式、讀取其文件屬性，並在需要時更新這些屬性。

這些範例基於 [PresentationInfo](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/presentationinfo/) 與 [DocumentProperties](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/documentproperties/) API，示範了處理簡報中繼資料的典型操作。

## **檢查簡報格式**

在處理簡報之前，您可能想要了解該簡報目前使用的格式（PPT、PPTX、ODP 等）。

您可以在不載入簡報的情況下檢查其格式。請參考以下 C++ 程式碼：

``` cpp
auto info = PresentationFactory::get_Instance()->GetPresentationInfo(u"pres.pptx");
// PPTX
Console::WriteLine(ObjectExt::ToString(info->get_LoadFormat()));

auto info2 = PresentationFactory::get_Instance()->GetPresentationInfo(u"pres.ppt");
// PPT
Console::WriteLine(ObjectExt::ToString(info2->get_LoadFormat()));

auto info3 = PresentationFactory::get_Instance()->GetPresentationInfo(u"pres.odp");
// ODP
Console::WriteLine(ObjectExt::ToString(info3->get_LoadFormat()));
```

## **取得簡報屬性**

以下 C++ 程式碼示範如何取得簡報屬性（有關簡報的資訊）：

``` cpp
auto info = PresentationFactory::get_Instance()->GetPresentationInfo(u"pres.pptx");
auto props = info->ReadDocumentProperties();
Console::WriteLine(ObjectExt::ToString(props->get_CreatedTime()));
Console::WriteLine(props->get_Subject());
Console::WriteLine(props->get_Title());
// ..
```

## **更新簡報屬性**

Aspose.Slides 提供 [PresentationInfo::UpdateDocumentProperties](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/presentationinfo/updatedocumentproperties/) 方法，允許您變更簡報屬性。

假設我們有一個 PowerPoint 簡報，其文件屬性如下所示。

![PowerPoint 簡報的原始文件屬性](input_properties.png)

以下程式碼示範如何編輯某些簡報屬性：

```cpp
auto fileName = u"sample.pptx";

auto info = PresentationFactory::get_Instance()->GetPresentationInfo(fileName);

auto properties = info->ReadDocumentProperties();
properties->set_Title(u"My title");
properties->set_LastSavedTime(DateTime::get_Now());

info->UpdateDocumentProperties(properties);
info->WriteBindedPresentation(fileName);
```

變更文件屬性的結果如下所示。

![PowerPoint 簡報的變更後文件屬性](output_properties.png)

## **實用連結**

若要取得有關簡報及其安全屬性的更多資訊，以下連結可能對您有幫助：

- [檢查簡報是否已加密](https://docs.aspose.com/slides/zh-hant/cpp/password-protected-presentation/#checking-whether-a-presentation-is-encrypted)
- [檢查簡報是否為寫入保護（唯讀）](https://docs.aspose.com/slides/zh-hant/cpp/password-protected-presentation/#checking-whether-a-presentation-is-write-protected)
- [檢查簡報在載入前是否受密碼保護](https://docs.aspose.com/slides/zh-hant/cpp/password-protected-presentation/#checking-whether-a-presentation-is-password-protected-before-loading-it)
- [確認用於保護簡報的密碼](https://docs.aspose.com/slides/zh-hant/cpp/password-protected-presentation/#validating-or-confirming-that-a-specific-password-has-been-used-to-protect-a-presentation).

## **常見問題**

**我該如何檢查字型是否已嵌入以及是哪一些字型？**

在簡報層級查找 [embedded-font information](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/fontsmanager/getembeddedfonts/)，然後將這些條目與 [fonts actually used across content](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/fontsmanager/getfonts/) 的集合進行比對，即可辨識哪些字型對於呈現是關鍵的。

**我該如何快速判斷檔案是否有隱藏投影片以及數量？**

遍歷 [slide collection](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/slidecollection/) 並檢查每張投影片的 [visibility flag](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/slide/get_hidden/)。

**我能偵測是否使用了自訂投影片大小與方向，且是否與預設不同嗎？**

可以。將目前的 [slide size and orientation](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides/presentation/get_slidesize/) 與標準預設值比較；這有助於預測列印與匯出的行為。

**有沒有快速方法查看圖表是否引用外部資料來源？**

可以。遍歷所有 [charts](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides.charts/chart/)，檢查其 [data source](https://reference.aspose.com/slides/zh-hant/cpp/aspose.slides.charts/chartdata/get_datasourcetype/)，並註明資料是內部還是基於連結，亦包括任何斷開的連結。

**我該如何評估可能導致渲染或 PDF 匯出緩慢的「沉重」投影片？**

對每張投影片，統計物件數量並檢查是否有大型影像、透明度、陰影、動畫與多媒體；依此給予大致的複雜度分數，以標示可能的效能瓶頸。
