翻譯|使用教程|編輯:胡濤|2023-05-04 09:41:08.067|閱讀 115 次
概述:本文將介紹如何使用 C++ 將 Word 文檔轉(zhuǎn)換為多頁(yè) TIFF 圖像,歡迎查閱~
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Aspose.Words 是一種高級(jí)Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔,而無需在跨平臺(tái)應(yīng)用程序中直接使用Microsoft Word。此外,
Aspose API支持流行文件格式處理,并允許將各類文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
您可能需要對(duì) Word 文檔(例如 DOCX、DOC、RTF 等)執(zhí)行的一項(xiàng)有用操作是轉(zhuǎn)換為圖像文件。例如,如果您必須以可讀和可打印但不可編輯的格式呈現(xiàn)您的 Word 文檔(例如,為了在 Web 上發(fā)布)。您可以使用的一種簡(jiǎn)單方法是轉(zhuǎn)換為多頁(yè) TIFF 文件。請(qǐng)參考以下文章了解如何使用 Aspose.Words for C++ 將 Word 文檔轉(zhuǎn)換為 TIFF 格式:
將 Word 文檔轉(zhuǎn)換為多頁(yè) TIFF 圖像
// For complete examples and data files, please go to //github.com/aspose-words/Aspose.Words-for-.NET // Save the document as multipage TIFF. doc.Save(dataDir + "TestFile Multipage TIFF_out.tiff");
現(xiàn)在可以使用 Aspose.Words for C++ API 從圖像創(chuàng)建 PDF 文檔。以下文章中提到的代碼示例顯示了使用 Aspose.Words for C++ 是多么容易。該代碼允許將單幀圖像(例如 JPEG、PNG、BMP、EMF 或 WMF)以及多幀 TIFF 圖像和 GIF 轉(zhuǎn)換為 PDF。
將圖像轉(zhuǎn)換為 PDF
將灰度圖像中包含的信息從 256 級(jí)灰度減少為黑白 2 級(jí)并將其轉(zhuǎn)換為二值圖像的過程就是二值化。當(dāng)文檔轉(zhuǎn)換為 TIFF 文件格式時(shí),您可以使用 ImageSaveOptions.ThresholdForFloydSteinbergDithering 屬性控制 TIFF 二值化的閾值。該屬性的默認(rèn)值為 128。值越高,圖像越暗。以下代碼示例顯示如何使用此屬性來控制 TIFF 二值化的閾值。
System::SharedPtr<ImageSaveOptions> options = System::MakeObject<ImageSaveOptions>(SaveFormat::Tiff); options->set_TiffCompression(TiffCompression::Ccitt3); options->set_ImageColorMode(ImageColorMode::Grayscale); options->set_TiffBinarizationMethod(ImageBinarizationMethod::FloydSteinbergDithering); options->set_ThresholdForFloydSteinbergDithering(254); System::String outputPath = outputDataDir + u"ImageColorFilters.ExposeThresholdControlForTiffBinarization.tiff"; doc->Save(outputPath, options);
下面的代碼示例演示了如何通過將 PixelFormat 設(shè)置為 Format1bppIndexed 將圖像保存為每像素一位。
System::SharedPtr<ImageSaveOptions> opt = System::MakeObject<ImageSaveOptions>(SaveFormat::Png); opt->set_PageIndex(1); opt->set_ImageColorMode(ImageColorMode::BlackAndWhite); opt->set_PixelFormat(ImagePixelFormat::Format1bppIndexed); System::String outputPath = outputDataDir + u"ImageColorFilters.SaveImageToOnebitPerPixel.png"; doc->Save(outputPath, opt);
DocSaveOptions 類用于在將文檔保存為 DOC 或 DOT 格式時(shí)指定其他選項(xiàng)。使用此類,您可以為加密文檔設(shè)置密碼,并在保存文檔時(shí)忽略 RoutingSlip 數(shù)據(jù)。下面給出的代碼示例顯示了如何設(shè)置密碼以使用 RC4 加密方法加密文檔。
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"Document.doc"); System::SharedPtr<DocSaveOptions> docSaveOptions = System::MakeObject<DocSaveOptions>(); docSaveOptions->set_Password(u"password"); System::String outputPath = outputDataDir + u"WorkingWithDoc.EncryptDocumentWithPassword.doc"; doc->Save(outputPath, docSaveOptions);
OoXMLSaveOptions 類提供了一個(gè)機(jī)會(huì)來保存任何使用密碼加密的文檔。使用此類,您可以在保存文檔時(shí)使用 OoxmlSaveOptions.Password 屬性設(shè)置密碼。下面的代碼示例演示了如何設(shè)置密碼并將文檔保存為 DOCX 格式。
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"Document.doc"); System::SharedPtr<OoxmlSaveOptions> ooxmlSaveOptions = System::MakeObject<OoxmlSaveOptions>(); ooxmlSaveOptions->set_Password(u"password"); System::String outputPath = outputDataDir + u"WorkingWithOoxml.EncryptDocxWithPassword.docx"; doc->Save(outputPath, ooxmlSaveOptions);
以上便是如何使用 C++ 將 Word 文檔轉(zhuǎn)換為多頁(yè) TIFF 圖像 ,要是您還有其他關(guān)于產(chǎn)品方面的問題,歡迎咨詢我們,或者加入我們官方技術(shù)交流群。
歡迎下載|體驗(yàn)更多Aspose產(chǎn)品
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn