{"@attributes":{"version":"2.0"},"channel":{"title":"Documentation \u2013 Convert a Document in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document\/","description":"Recent content in Convert a Document in C++ on Documentation","generator":"Hugo -- gohugo.io","language":"en","item":[{"title":"Cpp: Convert a Document to PDF in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-pdf\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-pdf\/","description":"\n        \n        \n        <p>The ability to easily and reliably convert documents from one format to another is a key feature of Aspose.Words. One of the most popular formats for converting is PDF \u2013 a fixed\u2011layout format, which preserves the original appearance of a document during its rendering on various platforms. The \u201crendering\u201d term is used in Aspose.Words to describe the process of converting a document into a file format that is paginated or has the concept of pages.<\/p>\n<h2 id=\"convert-a-word-document-to-pdf\">Convert a Word Document to PDF<\/h2>\n<p>Conversion from Word to PDF is a rather complex process that requires several stages of calculation. Aspose.Words layout engine mimics the way Microsoft Word\u2019s page layout engine works, making PDF output documents look as close as possible to what you can see in Microsoft Word.<\/p>\n<p>With Aspose.Words you can programmatically convert a document from DOC or DOCX format to PDF without using Microsoft Office. This article explains how to perform this conversion.<\/p>\n\n\n<div class=\"alert alert-primary\" role=\"alert\">\n\nNote that the number of pages in a document affects the conversion time.\n<\/div>\n\n<h3 id=\"converting-doc-or-docx-to-pdf\">Converting DOCX or DOC to PDF<\/h3>\n<p>Converting from the DOC or DOCX document format into the PDF format in Aspose.Words is very easy and can be accomplished with just two lines of code that:<\/p>\n<ol>\n<li>Load your document into a\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/document\/\">Document<\/a>\u00a0object using one of its constructors by specifying the document name with its format extension.<\/li>\n<li>Invoke one of the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/document\/save\/\">Document.Save<\/a>\u00a0methods\u00a0on the\u00a0<strong>Document<\/strong>\u00a0object and specify the desired output format as PDF by entering a\u00a0file name with the \u201c.PDF\u201d extension.<\/li>\n<\/ol>\n<p>The following code example shows how to convert a document from DOCX into PDF using the <code>Save<\/code> method:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/b9784b73e288805e08fba6e3fc5ae2af.js?file=docx-to-pdf.h\"><\/script>\n\n<p>You can download the template file of this example from\u00a0<a href=\"https:\/\/github.com\/aspose-words\/Aspose.Words-for-C\/tree\/master\/Examples\">Aspose.Words GitHub<\/a>.<\/p>\n\n\n<div class=\"alert alert-primary\" role=\"alert\">\n\n<p>Sometimes it is necessary to specify additional options, which can affect the result of saving a document as a PDF. These options can be specified using the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/pdfsaveoptions\/\">PdfSaveOptions<\/a>\u00a0class, containing properties that determine how the PDF output will be displayed.<\/p>\n<p>Note that with the same technique, you can convert any flow\u2011layout format document to PDF format.<\/p>\n\n<\/div>\n\n<h3 id=\"converting-to-various-pdf-standards\">Convert to Different PDF Standards<\/h3>\n<p>Aspose.Words provides the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/pdfsaveoptions\/get_compliance\/\">PdfCompliance<\/a> enumeration to support the conversion of DOC or\u00a0DOCX into various PDF format standards (such as PDF 1.7, PDF 1.5, etc.).<\/p>\n<p>The following code example demonstrates how to convert a document to PDF 1.7 using\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/pdfsaveoptions\/\">PdfSaveOptions<\/a>\u00a0with compliance to PDF17:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/b9784b73e288805e08fba6e3fc5ae2af.js?file=conversion-to-pdf17.h\"><\/script>\n\n<h2 id=\"convert-an-image-to-pdf\">Convert Images to PDF<\/h2>\n<p>Converting to PDF is not restricted by\u00a0Microsoft Word document formats. Any format supported by Aspose.Words, including programmatically created, can also be converted to PDF. For example, we can convert single\u2011page images, such as JPEG, PNG, BMP, EMF, or WMF, as well as multi\u2011page images, such as TIFF and GIF, to PDF.<\/p>\n<p>The following code example shows how to convert JPEG and TIFF images to PDF:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/b9784b73e288805e08fba6e3fc5ae2af.js?file=image-to-pdf.h\"><\/script>\n\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/b9784b73e288805e08fba6e3fc5ae2af.js?file=convert-image-to-pdf.h\"><\/script>\n\n<p>To make this code work, you need to add references to Aspose.Words and <code>System.Drawing<\/code> to your project.<\/p>\n<h2 id=\"see-also\">See Also<\/h2>\n<ul>\n<li>The article\u00a0<a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/rendering\/\">Rendering<\/a>\u00a0for more information on the fixed\u2011page and flow\u2011layout formats<\/li>\n<li>The article\u00a0<a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/converting-to-fixed-page-format\/#what-is-a-page-layout\">Converting to Fixed\u2011page Format<\/a>\u00a0for more information on the page layout<\/li>\n<li>The article\u00a0<a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/specify-rendering-options-when-converting-to-pdf\/\">Specify Rendering Options When Converting to PDF<\/a>\u00a0for more information on using the <code>PdfSaveOptions<\/code> class<\/li>\n<\/ul>\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q:<\/strong> How do I convert a DOCX file to PDF using Aspose.Words for C++?<br>\n<strong>A:<\/strong> Load the DOCX into an <code>Aspose::Words::Document<\/code> object and call its <code>Save<\/code> method with a file name ending in \u201c.pdf\u201d. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span> <span class=\"n\">doc<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;input.docx&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;output.pdf&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q:<\/strong> How can I create a PDF that complies with a specific standard such as PDF\/A\u20111b or PDF\/X\u20114?<br>\n<strong>A:<\/strong> Use <code>Aspose::Words::Saving::PdfSaveOptions<\/code> and set its <code>Compliance<\/code> property to the desired <code>PdfCompliance<\/code> value, then pass the options to <code>Document::Save<\/code>. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfSaveOptions<\/span> <span class=\"n\">options<\/span><span class=\"p\">;<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">set_Compliance<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfCompliance<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfA1b<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;output_pdfa.pdf&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q:<\/strong> How can I protect the generated PDF with a password?<br>\n<strong>A:<\/strong> Configure the <code>EncryptionDetails<\/code> of <code>PdfSaveOptions<\/code> with a user password (and optionally an owner password) and assign an encryption algorithm. Then save the document with those options. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfSaveOptions<\/span> <span class=\"n\">options<\/span><span class=\"p\">;<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">get_EncryptionDetails<\/span><span class=\"p\">().<\/span><span class=\"n\">set_UserPassword<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;myPassword&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">get_EncryptionDetails<\/span><span class=\"p\">().<\/span><span class=\"n\">set_EncryptionAlgorithm<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfEncryptionAlgorithm<\/span><span class=\"o\">::<\/span><span class=\"n\">Aes256<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;protected.pdf&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q:<\/strong> How can I control image quality or compression when converting images to PDF?<br>\n<strong>A:<\/strong> Set <code>ImageCompression<\/code> (e.g., <code>PdfImageCompression::Jpeg<\/code>) and <code>JpegQuality<\/code> (0\u2011100) on <code>PdfSaveOptions<\/code>. This reduces file size while preserving visual quality. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfSaveOptions<\/span> <span class=\"n\">options<\/span><span class=\"p\">;<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">set_ImageCompression<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PdfImageCompression<\/span><span class=\"o\">::<\/span><span class=\"n\">Jpeg<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">set_JpegQuality<\/span><span class=\"p\">(<\/span><span class=\"mi\">80<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;images.pdf&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q:<\/strong> How do I combine several images (e.g., a multi\u2011page TIFF) into a single PDF document?<br>\n<strong>A:<\/strong> Load each image as a separate <code>Document<\/code> (or use <code>ImageLoadOptions<\/code> for multi\u2011page images) and append them to a master document using <code>Document::AppendDocument<\/code>. Finally, save the master document as PDF. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span> <span class=\"n\">master<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span> <span class=\"n\">imgDoc<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;page1.tiff&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">master<\/span><span class=\"p\">.<\/span><span class=\"n\">AppendDocument<\/span><span class=\"p\">(<\/span><span class=\"n\">imgDoc<\/span><span class=\"p\">,<\/span> <span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">ImportFormatMode<\/span><span class=\"o\">::<\/span><span class=\"n\">KeepSourceFormatting<\/span><span class=\"p\">);<\/span>\n<span class=\"c1\">\/\/ repeat for additional pages...\n<\/span><span class=\"c1\"><\/span><span class=\"n\">master<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;combined.pdf&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<\/ol>\n\n      "},{"title":"Cpp: Convert Word to Excel in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-excel\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-excel\/","description":"\n        \n        \n        <p>Converting documents from one format to another is the flagship feature of Aspose.Words. You can convert documents in any available <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/loadformat\/\">load format<\/a> also to XLSX format.<\/p>\n<h2 id=\"convert-a-document-to-xlsx\">Convert a Document to XLSX<\/h2>\n<p>Converting a document to XLSX is a rather complicated process. To save your document to XLSX format using Aspose.Words, use the <strong>XlsxSaveOptions<\/strong> class and the new <code>Xlsx<\/code> element in the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/saveformat\/\">SaveFormat<\/a> enumeration. As mentioned above, you can save the document in any load format supported by Aspose.Words to XLSX.<\/p>\n<p>The following code example shows how to save PDF to XLSX:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">MyDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;Pdf Document.pdf&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"n\">ArtifactsDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;BaseConversions.PdfToXlsx.xlsx&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div>\n<h2 id=\"find-and-replace-when-saving-to-xlsx\">Find and Replace When Saving to XLSX<\/h2>\n<p>Also using Aspose.Words, you can find a specific string or regular expression in your document and replace it with the matching one you need. Then you can also save the result to XLSX format.<\/p>\n<p>The following code example shows how to perform find and replace operation and save result to XLSX:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"k\">auto<\/span> <span class=\"n\">builder<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">DocumentBuilder<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">doc<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">builder<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Writeln<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Ruby bought a ruby necklace.&#34;<\/span><span class=\"p\">);<\/span>\n\n<span class=\"c1\">\/\/ We can use a &#34;FindReplaceOptions&#34; object to modify the find-and-replace process.\n<\/span><span class=\"c1\"><\/span><span class=\"k\">auto<\/span> <span class=\"n\">options<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">FindReplaceOptions<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"c1\">\/\/ Set the &#34;MatchCase&#34; flag to &#34;true&#34; to apply case sensitivity while finding strings to replace.\n<\/span><span class=\"c1\">\/\/ Set the &#34;MatchCase&#34; flag to &#34;false&#34; to ignore character case while searching for text to replace.\n<\/span><span class=\"c1\"><\/span><span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_MatchCase<\/span><span class=\"p\">(<\/span><span class=\"nb\">true<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_Range<\/span><span class=\"p\">()<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Replace<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Ruby&#34;<\/span><span class=\"p\">,<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;Jade&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"n\">ArtifactsDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;BaseConversions.FindReplaceXlsx.xlsx&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div>\n<h2 id=\"specify-compression-level-when-saving-to-xlsx\">Specify Compression Level When Saving to XLSX<\/h2>\n<p>You can also specify the compression level when saving using the <strong>CompressionLevel<\/strong> property.<\/p>\n<p>The following code example shows how to specify the compression level when saving to XLSX format:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">MyDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;Document.docx&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"k\">auto<\/span> <span class=\"n\">saveOptions<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">XlsxSaveOptions<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"n\">saveOptions<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_CompressionLevel<\/span><span class=\"p\">(<\/span><span class=\"n\">CompressionLevel<\/span><span class=\"o\">::<\/span><span class=\"n\">Maximum<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"n\">ArtifactsDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;BaseConversions.CompressXlsx.xlsx&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">saveOptions<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div>\n<h2 id=\"see-also\">See Also<\/h2>\n<ul>\n<li>Documentation section\u00a0<a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/protect-or-encrypt-a-document\/\">Protect or Encrypt a Document<\/a>\u00a0for more information about protecting and encrypting a document<\/li>\n<li>The article\u00a0<a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/find-and-replace\/\">Find and Replace<\/a>\u00a0for more more information about finding and replacing the content you want<\/li>\n<\/ul>\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q:<\/strong> How can I convert a PDF document to Excel (XLSX) using Aspose.Words for C++?<br>\n<strong>A:<\/strong> Load the PDF with the <code>Document<\/code> class and call <code>Save<\/code> specifying an XLSX file name. Aspose.Words automatically detects the source format and writes the spreadsheet. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">MyDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;Pdf Document.pdf&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"n\">ArtifactsDir<\/span> <span class=\"o\">+<\/span> <span class=\"sa\">u<\/span><span class=\"s\">&#34;Result.xlsx&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q:<\/strong> Can I perform find\u2011and\u2011replace on a document before saving it as Excel?<br>\n<strong>A:<\/strong> Yes. Use <code>FindReplaceOptions<\/code> together with <code>Range::Replace<\/code> to modify the document content, then save the updated document to XLSX. The same code shown in the \u201cFind and Replace When Saving to XLSX\u201d section applies.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How do I control the compression level of the generated XLSX file?<br>\n<strong>A:<\/strong> Create an <code>XlsxSaveOptions<\/code> instance, set its <code>CompressionLevel<\/code> property (e.g., <code>CompressionLevel::Maximum<\/code>), and pass the options to <code>Document::Save<\/code>. This reduces file size at the cost of longer save time.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Do I need a license to convert documents to Excel, and how do I apply it in C++?<br>\n<strong>A:<\/strong> A license is required for production use to remove evaluation watermarks and enable full functionality. Load the license file with the <code>License<\/code> class before any document operations:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">license<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">License<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"n\">license<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">SetLicense<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Path\/To\/Aspose.Words.CPP.lic&#34;<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><p>After setting the license, all conversion features work without restrictions.<\/p>\n<\/li>\n<\/ol>\n\n      "},{"title":"Cpp: Convert a Document to HTML, MHTML or EPUB","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-html-mhtml-or-epub\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-html-mhtml-or-epub\/","description":"\n        \n        \n        <p>Documents in HTML and MHTML\u00a0flow-layout formats are also very popular and can be used on any web platform. For that reason, converting documents to HTML and MHTML is an important feature of Aspose.Words.<\/p>\n<p>EPUB (short for &ldquo;Electronic Publication&rdquo;) is an HTML-based format commonly used for electronic book distribution. This format is fully supported in Aspose.Words for exporting electronic books that are compatible with most reading devices.<\/p>\n<h2 id=\"convert-a-document\">Convert a Document<\/h2>\n<p>For simple conversion to HTML, MHTML, or EPUB,\u00a0one of the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/document\/save\/\">Save<\/a>\u00a0method overloads is used. You can save the document to a file or stream and explicitly set the output document\u00a0save format or define it from the file name extension.<\/p>\n<p>The following example shows how to convert DOCX to HTML with specifying a save format:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToHTML-ConvertDocxToHtml.cpp\"><\/script>\n\n<p>To convert a document to MHTML or EPUB, use <code>SaveFormat::Mhtml<\/code> or <code>SaveFormat::Epub<\/code> respectively.<\/p>\n<h2 id=\"convert-a-document-with-round-trip-information\">Convert a Document with Round-trip Information<\/h2>\n<p>The HTML format does not support many Microsoft Word features, and if we need to restore a document model as close to the original as possible, we need to save some extra information within the HTML file. Such information is also called &ldquo;round-trip information&rdquo;. For this purpose, Aspose.Words\u00a0provides an ability to export round-trip information when saving to HTML, MHTML, or EPUB using the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_exportroundtripinformation\/\">ExportRoundtripInformation<\/a>\u00a0property. Saving the round-trip information allows restoring document properties such as tabs, comments, headers, and footers during the loading documents of the listed formats back into a\u00a0<strong>Document<\/strong>\u00a0object.<\/p>\n<p>The default value is\u00a0<strong>true<\/strong>\u00a0for HTML and\u00a0<strong>false<\/strong>\u00a0for MHTML and EPUB:<\/p>\n<ul>\n<li>When\u00a0<strong>true<\/strong>, the round\u2011trip information is exported as - aw - * CSS properties of the corresponding HTML\u00a0elements<\/li>\n<li>When\u00a0<strong>false<\/strong>, there is no round\u2011trip information to be output into produced files<\/li>\n<\/ul>\n<p>The following code example shows how to export round\u2011trip information when converting a document from DOCX into HTML:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToHTML-ConvertDocumentToHtmlWithRoundtrip.cpp\"><\/script>\n\n\n\n<div class=\"alert alert-primary\" role=\"alert\">\n\nYou can download the template file of this example\u00a0from\u00a0<a href=\"https:\/\/github.com\/aspose-words\/Aspose.Words-for-C\/tree\/master\/Examples\">Aspose.Words GitHub<\/a>.\n<\/div>\n\n<h2 id=\"specify-save-options-when-conversion-to-html\">Specify Save Options when Conversion to HTML<\/h2>\n<p>Aspose.Words allows converting a Word document to HTML using default or custom save options.\u00a0Few examples of custom save options are described below.<\/p>\n<h3 id=\"specify-a-folder-for-saving-resources\">Specify a Folder for Saving Resources<\/h3>\n<p>Using Aspose.Words we can specify a physical folder where all resources, such as images, fonts, and external CSS, are saved when a document is converted to HTML. By default, this is an empty string.<\/p>\n<p>Specifying the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_resourcefolder\/\">ResourceFolder<\/a>\u00a0property is the simplest way to set the folder where all resources should be written. We can use individual properties, such as\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_fontsfolder\/\">FontsFolder<\/a>\u00a0which saves fonts to the specified folder and\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_imagesfolder\/\">ImagesFolder<\/a>\u00a0which saves images to a specified folder.\u00a0When a relative path is specified,\u00a0<strong>FontsFolder<\/strong>\u00a0and\u00a0<strong>ImagesFolder<\/strong>\u00a0refer to the folder where the code assembly is located,\u00a0<strong>ResourceFolder<\/strong>\u00a0and\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_cssstylesheetfilename\/\">CssStyleSheetFileName<\/a>\u00a0refer to the output folder where the HTML document is located.<\/p>\n<p>In this example,\u00a0<strong>ResourceFolder<\/strong>\u00a0specifies the relative path. This path refers to the output folder where the HTML document is saved.\u00a0The value of the\u00a0<strong>ResourceFolderAlias<\/strong>\u00a0property is used to create URLs for all resources.<\/p>\n<p>The following code example shows how to work with these properties:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToHTML-ExportResourcesUsingHtmlSaveOptions.cpp\"><\/script>\n\n<p>Using the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_resourcefolderalias\/\">ResourceFolderAlias<\/a>\u00a0property, we can also specify the name of the folder used to construct URIs of all resources written into an HTML document. This is the simplest way to specify how URIs should be generated for all resource files. The same information can be specified for images and fonts separately via\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_imagesfolderalias\/\">ImagesFolderAlias<\/a>\u00a0and\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_fontsfolderalias\/\">FontsFolderAlias<\/a>\u00a0properties, respectively.<\/p>\n<p>However, there is no individual property for CSS. The behavior of the\u00a0<strong>FontsFolder<\/strong>,\u00a0<strong>FontsFolderAlias<\/strong>,\u00a0<strong>ImagesFolder<\/strong>,\u00a0<strong>ImagesFolderAlias<\/strong>\u00a0and\u00a0<strong>CssStyleSheetFileName<\/strong>\u00a0properties are not changed. Note that the\u00a0<strong>CssStyleSheetFileName<\/strong>\u00a0property is used both for specifying folder name and file name.<\/p>\n<ul>\n<li><strong>ResourceFolder<\/strong> has lower priority than folders specified via <strong>FontsFolder<\/strong>, <strong>ImagesFolder<\/strong>, and <strong>CssStyleSheetFileName<\/strong>. If the folder specified in the <strong>ResourceFolder<\/strong> does not exist, it will be created automatically.<\/li>\n<li><strong>ResourceFolderAlias<\/strong> has a lower priority than <strong>FontsFolderAlias<\/strong> and <strong>ImagesFolderAlias<\/strong>. If <strong>ResourceFolderAlias<\/strong> is empty, the value of the <strong>ResourceFolder<\/strong> property will be used to create resource URIs. If <strong>ResourceFolderAlias<\/strong> is set to &ldquo;.&rdquo; (dot), resource URIs will only contain file names without specifying a path.<\/li>\n<\/ul>\n<h3 id=\"export-base64-encoding-fontsresources\">Export Base64 Encoding Fonts\u00a0Resources<\/h3>\n<p>Aspose.Words provides an ability to\u00a0specify whether font resources should be embedded into HTML in Base64 encodings. To perform this, use the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_exportfontsasbase64\/\">ExportFontsAsBase64<\/a>\u00a0property\u00a0\u2013 this is an extension of the\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/get_exportfontresources\/\">ExportFontResources<\/a>\u00a0property. By default,\u00a0its value is\u00a0<strong>false<\/strong>,\u00a0and fonts are written into separate files.\u00a0But if\u00a0this option is set to\u00a0<strong>true<\/strong>, fonts will be embedded into the document&rsquo;s CSS in Base64 encoding. The\u00a0<strong>ExportFontsAsBase64<\/strong>\u00a0property only affects HTML format and does not affect EPUB and MHTML.<\/p>\n<p>The following code example shows how to export Base64\u2011encoded fonts to HTML:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToHTML-ExportFontsAsBase64.cpp\"><\/script>\n\n<h2 id=\"specify-save-options-when-conversion-to-epub\">Specify Save Options when Conversion to EPUB<\/h2>\n<p>Aspose.Words allows converting a Word document into EPUB format using default or custom save options.\u00a0You can specify a number of options by passing an instance of\u00a0<a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/htmlsaveoptions\/\">HtmlSaveOptions<\/a>\u00a0to the <code>Save<\/code> method.<\/p>\n<p>The following code example shows how to converts a Word document to EPUB with specifying some custom save options:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToEPUB-ConvertDocumentToEPUB.cpp\"><\/script>\n\n\n\n<div class=\"alert alert-primary\" role=\"alert\">\n\nYou can download the template file of this example\u00a0from\u00a0<a href=\"https:\/\/github.com\/aspose-words\/Aspose.Words-for-C\/tree\/master\/Examples\">Aspose.Words GitHub<\/a>.\n<\/div>\n\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q:<\/strong> How do I convert a DOCX file to HTML using Aspose.Words for C++?<br>\n<strong>A:<\/strong> Load the document with <code>Document doc(&quot;input.docx&quot;);<\/code> and call <code>doc.Save(&quot;output.html&quot;, SaveFormat::Html);<\/code>. This uses the default <code>HtmlSaveOptions<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How can I preserve Word\u2011specific features (round\u2011trip information) when saving to HTML?<br>\n<strong>A:<\/strong> Create an <code>HtmlSaveOptions<\/code> object, set <code>options.set_ExportRoundtripInformation(true);<\/code>, and pass it to <code>Document::Save<\/code>. This embeds additional CSS that allows the document to be re\u2011loaded with tabs, comments, headers, and footers restored.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Where can I specify the folder for images, fonts, and other resources generated during HTML conversion?<br>\n<strong>A:<\/strong> Use <code>HtmlSaveOptions options;<\/code> then set <code>options.set_ResourceFolder(&quot;Resources&quot;);<\/code>, <code>options.set_ImagesFolder(&quot;Resources\/Images&quot;);<\/code>, and <code>options.set_FontsFolder(&quot;Resources\/Fonts&quot;);<\/code>. The folders are created automatically if they do not exist.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How do I embed fonts directly into the HTML file as Base64 strings?<br>\n<strong>A:<\/strong> Set <code>options.set_ExportFontsAsBase64(true);<\/code> on an <code>HtmlSaveOptions<\/code> instance before saving. This causes font files to be encoded in Base64 and placed inside the generated CSS, eliminating external font files.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> What is the recommended way to convert a document to EPUB with custom options?<br>\n<strong>A:<\/strong> Although EPUB uses <code>HtmlSaveOptions<\/code>, you pass the same options to <code>Document::Save<\/code> with <code>SaveFormat::Epub<\/code>. For example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">HtmlSaveOptions<\/span> <span class=\"n\">options<\/span><span class=\"p\">;<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">set_ExportFontResources<\/span><span class=\"p\">(<\/span><span class=\"nb\">true<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">set_ExportImagesAsBase64<\/span><span class=\"p\">(<\/span><span class=\"nb\">true<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">Document<\/span> <span class=\"nf\">doc<\/span><span class=\"p\">(<\/span><span class=\"s\">&#34;input.docx&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">doc<\/span><span class=\"p\">.<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"s\">&#34;output.epub&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">SaveFormat<\/span><span class=\"o\">::<\/span><span class=\"n\">Epub<\/span><span class=\"p\">,<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div><p>This lets you control font embedding, image handling, and other EPUB\u2011specific settings.<\/p>\n<\/li>\n<\/ol>\n\n      "},{"title":"Cpp: Convert a Document to MHTML and Send It by Email","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-mhtml-and-send-it-by-email\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-mhtml-and-send-it-by-email\/","description":"\n        \n        \n        <p>Aspose.Words can convert any document to the MHTML (Web Archive) format. This makes it convenient to use Aspose.Words and <code>Aspose.Email<\/code> together. You can load a predefined document in any supported format, such as DOC, OOXML, or RTF, into Aspose.Words, fill it with data, save the resulting document as MHTML, and then send it by e\u2011mail using <code>Aspose.Email<\/code>.<\/p>\n<p>The following code example shows how to convert any document to MHTML and send it by email:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToHTML-ConvertDocumentToMhtmlAndEmail.cpp\"><\/script>\n\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q: Which input document formats can be converted to MHTML?<\/strong><br>\n<strong>A:<\/strong> Aspose.Words for C++ supports all formats that the library can load, including DOC, DOCX, OOXML, RTF, HTML, EPUB, and many others. Any document that can be opened with <code>Aspose::Words::Document<\/code> can be saved as MHTML using the <code>Save<\/code> method with <code>SaveFormat::Mhtml<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Q: Do I need a separate license for Aspose.Email when sending the MHTML file?<\/strong><br>\n<strong>A:<\/strong> Yes. Converting the document to MHTML uses Aspose.Words, while sending the e\u2011mail uses Aspose.Email. Both products require their own valid licenses. Apply each license before using the corresponding API (e.g., <code>Aspose::Words::License<\/code> for Words and <code>Aspose::Email::License<\/code> for Email).<\/p>\n<\/li>\n<li>\n<p><strong>Q: How can I set the e\u2011mail subject, body, and attachment programmatically in C++?<\/strong><br>\n<strong>A:<\/strong> Use the <code>Aspose::Email::MailMessage<\/code> class. Create a <code>MailMessage<\/code>, set <code>Subject<\/code> and <code>Body<\/code>, then add the MHTML file as an attachment with <code>MailMessage::Attachments-&gt;Add<\/code>. Finally, send the message with <code>SmtpClient<\/code>. Example:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">SharedPtr<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Email<\/span><span class=\"o\">::<\/span><span class=\"n\">MailMessage<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">msg<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Email<\/span><span class=\"o\">::<\/span><span class=\"n\">MailMessage<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"n\">msg<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_Subject<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Converted Document&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">msg<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_Body<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Please find the converted MHTML document attached.&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">msg<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_Attachments<\/span><span class=\"p\">()<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Add<\/span><span class=\"p\">(<\/span><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Email<\/span><span class=\"o\">::<\/span><span class=\"n\">Attachment<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;document.mhtml&#34;<\/span><span class=\"p\">));<\/span>\n<\/code><\/pre><\/div><\/li>\n<li>\n<p><strong>Q: Can I embed images in the MHTML output so they appear correctly in the e\u2011mail?<\/strong><br>\n<strong>A:<\/strong> Yes. When saving to MHTML, Aspose.Words automatically embeds all images as base\u201164 data URIs inside the file. The resulting MHTML can be opened directly in a browser or attached to an e\u2011mail without additional handling.<\/p>\n<\/li>\n<li>\n<p><strong>Q: What should I do if the conversion throws an \u201cUnsupported file format\u201d exception?<\/strong><br>\n<strong>A:<\/strong> Verify that the source file\u2019s extension matches a format supported by Aspose.Words and that the file is not corrupted. If the file is in a proprietary format, consider converting it to a supported format (e.g., DOCX) before loading it with Aspose.Words. Also ensure you are using the latest version of the library, as newer releases add support for additional formats.<\/p>\n<\/li>\n<\/ol>\n\n      "},{"title":"Cpp: Convert a Document to Markdown in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-markdown\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-markdown\/","description":"\n        \n        \n        <p>Markdown is a popular format used to markup text and its further converting to HTML, PDF, DOCX, or other formats. Many developers choose this format for writing documentation, preparing articles for publication on blogs, describing projects, and so on.<\/p>\n<p>Markdown is so popular because it is easy to work with this format, as well as it can be quite simply converted to other formats. For this reason, Aspose.Words provides the ability to convert a document in <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/\">any supported load format<\/a> to Markdown and vice versa \u2013 Aspose.Words also supports the most popular <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/saveformat\/\">save formats<\/a>.<\/p>\n<p>Now the functionality for working with the Markdown format is being actively developed to provide you with more opportunities for convenient and comfortable work with documents.<\/p>\n<h2 id=\"convert-a-document\">Convert a Document<\/h2>\n<p>To convert a document to Markdown, you just need to load a document in any supported format or create a new one programmatically. Then you need to save the document to Markdown format.<\/p>\n<p>The following code example shows how to convert DOCX to Markdown:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToMarkdown-SaveAsMD.cpp\"><\/script>\n\n<p>You can also specify the physical folder in which you want to save images when exporting a document to Markdown format. By default, Aspose.Words saves images in the same folder where the document file is saved, but you can override this behavior using the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/markdownsaveoptions\/get_imagesfolder\/\">ImagesFolder<\/a> property.<\/p>\n<p>Specifying a folder via <strong>ImagesFolder<\/strong> is also useful if you save a document to a stream and Aspose.Words does not have a folder for saving images.<\/p>\n<p>If the specified <strong>ImagesFolder<\/strong> does not exist, it will be created automatically.<\/p>\n<p>The following code example shows how to specify a folder for images when saving a document to a stream:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToMarkdown-SetImagesFolder.cpp\"><\/script>\n\n<h2 id=\"specify-save-options-when-converting-to-markdown\">Specify Save Options when Converting to Markdown<\/h2>\n<p>Aspose.Words provides the ability to use the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/markdownsaveoptions\/\">MarkdownSaveOptions<\/a> class to work with advanced options when saving a document to Markdown format. Most properties are inheriting or overloading properties that already exist within other <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/\">Aspose.Words.Saving<\/a> Namespace classes. In addition to them, a number of properties that are specific for Markdown format have also been added. For example, the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/markdownsaveoptions\/get_tablecontentalignment\/\">TableContentAlignment<\/a> property to control the alignment of content in tables, or <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/iimagesavingcallback\/\">ImageSavingCallback<\/a> and <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/markdownsaveoptions\/get_imagesfolder\/\">ImagesFolder<\/a> to control how images are saved upon converting a document to Markdown format.<\/p>\n<h2 id=\"supported-markdown-features\">Supported Markdown Features<\/h2>\n<p>Aspose.Words currently supports the following Markdown features, which mostly follow the <code>CommonMark<\/code> specification in the Aspose.Words API and are represented as appropriate styles or direct formatting:<\/p>\n<ul>\n<li>Headings are paragraphs with Heading 1 \u2013 Heading 6 styles<\/li>\n<li>Blockquotes are paragraphs with \u201cQuote\u201d in the style name<\/li>\n<li>IndentedCode are paragraphs with &ldquo;IndentedCode&rdquo; in the style name<\/li>\n<li>FencedCode are paragraphs with &ldquo;FencedCode&rdquo; in the style name<\/li>\n<li>InlineCode are runs with &ldquo;InlineCode&rdquo; in the <code>Font<\/code> style name<\/li>\n<li>Horizontal rules are paragraphs with the <code>HorizontalRule<\/code> shape<\/li>\n<li>Bold emphasis<\/li>\n<li>Italic emphasis<\/li>\n<li>StrikeThrough formatting<\/li>\n<li>Lists are numbered or bulleted paragraphs<\/li>\n<li>Tables are represented with the <code>Table<\/code> class<\/li>\n<li>Links are represented as the <code>FieldHyperlink<\/code> class<\/li>\n<\/ul>\n<p>The following example shows how to create a document with some styles and save it to Markdown:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertDocumentToMarkdown-SupportedMarkdownFeatures.cpp\"><\/script>\n\n<p>The result of this code example is shown below.<\/p>\n<p><img src=\"markdown-example.png\" alt=\"markdown-example-aspose-words-cpp\"><\/p>\n<h2 id=\"useful-tips\">Useful Tips<\/h2>\n<p>There are several nuances and interesting cases, having learned which you can work with Markdown files more flexibly and conveniently. For example, there is the ability to use:<\/p>\n<ul>\n<li>SetextHeading that allows you to create multi-line headings in Markdown, while regular headings in Markdown can only be single-line. SetextHeading is based on a &ldquo;Heading N&rdquo; style, and its level can only be 1 or 2. If N in &ldquo;Heading N&rdquo; is greater than or equal to 2, then the corresponding SetextHeading is based on &ldquo;Heading 2&rdquo;, otherwise on &ldquo;Heading 1&rdquo;.<\/li>\n<li>Different markers for the first level of bulleted lists (&quot;-&quot;, &ldquo;+&rdquo; or &ldquo;*&rdquo;, the default marker is \u201c-\u201d.) and different types of numbering for ordered lists (&quot;.&quot; or &ldquo;)&rdquo;, the default marker is &ldquo;.&quot;).<\/li>\n<\/ul>\n\n      "},{"title":"Cpp: Convert a Document to an Image in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-an-image\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-document-to-an-image\/","description":"\n        \n        \n        <p>Sometimes it is required to get an image instead of documents in other formats, such as DOCX or PDF. For example, you need to add a preview of any document page to your website or application, or create a &ldquo;scan&rdquo; of a document to send an invoice. This is when you may need to convert a document in any <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/loadformat\/\">supported load format<\/a> to an image, again, in any <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/saveformat\/\">supported save format<\/a>.<\/p>\n<h2 id=\"convert-to-image-format\">Convert to Image Format<\/h2>\n<p>As with all conversion examples already described, you need to create a new document or load an existing one in any supported format, make the necessary changes, and save it in any available image format, for example, JPEG, PNG, or BMP.<\/p>\n<p>The following code example shows how to convert DOCX to JPEG:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=Examples-DocsExamples-source-File%20Formats%20and%20Conversions-Base%20conversions-DocxToJpeg.h\"><\/script>\n\n<h2 id=\"specify-save-options-when-converting-to-an-image\">Specify Save Options when Converting to an Image<\/h2>\n<p>Aspose.Words provides you with the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/\">ImageSaveOptions<\/a> class, which gives more control over how documents are saved in various image formats. Some properties of this class inherit or overload properties of base classes such as <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/fixedpagesaveoptions\/\">FixedPageSaveOptions<\/a> or <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/saveoptions\/\">SaveOptions<\/a>, but there are also options specific to saving images.<\/p>\n<p>It is possible to specify the pages to be converted to image format using the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_pageset\/\">PageSet<\/a> property. For example, it can be applied if you only need a preview for the first or for a definite page.<\/p>\n<p>It is also possible to control the output image quality and pixel format using the following properties \u2013 <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/set_horizontalresolution\/\">HorizontalResolution<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_verticalresolution\/\">VerticalResolution<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/set_resolution\/\">Resolution<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/set_scale\/\">Scale<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_pixelformat\/\">PixelFormat<\/a>, as well as set up image color settings, using the following properties \u2013 <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_imagebrightness\/\">ImageBrightness<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_imagecolormode\/\">ImageColorMode<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_imagecontrast\/\">ImageContrast<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_papercolor\/\">PaperColor<\/a>.<\/p>\n<p>There are also properties that apply to a certain format, for example, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_jpegquality\/\">JpegQuality<\/a> or <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/imagesaveoptions\/get_tiffcompression\/\">TiffCompression<\/a>.<\/p>\n<p>The following code example shows how to create a preview of the first document page with applying some additional settings:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/d55d8631947d283b1f0da99afa06c492.js?file=cpp-Loading-and-Saving-ConvertWordDocument-ConvertDocumentToImage.cpp\"><\/script>\n\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q:<\/strong> How do I convert a Word document to a JPEG image using Aspose.Words for C++?<br>\n<strong>A:<\/strong> Load the document with <code>System::SharedPtr&lt;Aspose::Words::Document&gt; doc = System::MakeObject&lt;Aspose::Words::Document&gt;(u&quot;input.docx&quot;);<\/code>, create an <code>ImageSaveOptions<\/code> object, set <code>SaveFormat<\/code> to <code>SaveFormat::Jpeg<\/code>, and call <code>doc-&gt;Save(u&quot;output.jpg&quot;, saveOptions);<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Can I convert only selected pages of a document to images?<br>\n<strong>A:<\/strong> Yes. Use the <code>PageSet<\/code> property of <code>ImageSaveOptions<\/code>. For example, <code>saveOptions-&gt;set_PageSet(System::MakeObject&lt;Aspose::Words::Saving::PageSet&gt;(1, 1));<\/code> converts only page\u202f1.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Which options let me control the resolution and quality of the saved image?<br>\n<strong>A:<\/strong> <code>HorizontalResolution<\/code>, <code>VerticalResolution<\/code>, and <code>Resolution<\/code> control DPI. <code>JpegQuality<\/code> (0\u2011100) adjusts JPEG compression, while <code>TiffCompression<\/code> sets TIFF compression type. Adjust these on the <code>ImageSaveOptions<\/code> instance before saving.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How can I change the pixel format or color mode of the output image?<br>\n<strong>A:<\/strong> Set <code>PixelFormat<\/code> (e.g., <code>PixelFormat::Format24bppRgb<\/code>) and <code>ImageColorMode<\/code> (e.g., <code>ImageColorMode::Grayscale<\/code>) on the <code>ImageSaveOptions<\/code> object to modify the image\u2019s color representation.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How do I generate separate image files for every page in a document?<br>\n<strong>A:<\/strong> Loop through the page count, update <code>PageSet<\/code> for each page, and call <code>Save<\/code> with a distinct file name, e.g.:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">SharedPtr<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;input.docx&#34;<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">SharedPtr<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">ImageSaveOptions<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">options<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">ImageSaveOptions<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">SaveFormat<\/span><span class=\"o\">::<\/span><span class=\"n\">Png<\/span><span class=\"p\">);<\/span>\n<span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_PageCount<\/span><span class=\"p\">();<\/span> <span class=\"o\">++<\/span><span class=\"n\">i<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_PageSet<\/span><span class=\"p\">(<\/span><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">PageSet<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">i<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">,<\/span> <span class=\"mi\">1<\/span><span class=\"p\">));<\/span>\n    <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">String<\/span> <span class=\"n\">fileName<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">String<\/span><span class=\"o\">::<\/span><span class=\"n\">Format<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;page_{0}.png&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">i<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">);<\/span>\n    <span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"n\">fileName<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre><\/div><p>This creates one image per page with the specified format and options.<\/p>\n<\/li>\n<\/ol>\n\n      "},{"title":"Cpp: Convert a Multi-page Document to an Image in C++","link":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-multi-page-document-to-an-image\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/convert-a-multi-page-document-to-an-image\/","description":"\n        \n        \n        <p>Aspose.Words for C++ allows users to export multi-page documents to raster images. This can be useful for generating previews, archives, or visual representations of documents for non-editable use.<\/p>\n<h2 id=\"what-formats-support-multi-page-export\">What Formats Support Multi-page Export?<\/h2>\n<p>Aspose.Words supports multi-page export to the following raster image formats:<\/p>\n<ul>\n<li>Jpeg<\/li>\n<li>Gif<\/li>\n<li>Png<\/li>\n<li>Bmp<\/li>\n<li>Tiff<\/li>\n<li>WebP<\/li>\n<\/ul>\n<h2 id=\"how-to-export-a-multi-page-document-to-an-image\">How to Export a Multi-page Document to an Image<\/h2>\n<p>The feature of exporting a multi-page document to an image is implemented using the <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/\">MultiPageLayout<\/a> class \u2013 you can specify how the pages should be organized when saving to an image:<\/p>\n<ul>\n<li><a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/singlepage\/\">SinglePage<\/a> \u2013 save only the first of the specified pages<\/li>\n<li><a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/grid\/\">Grid<\/a> \u2013 arrange the pages in a grid, left-to-right and top-to-bottom, while specifying the number of columns<\/li>\n<li><a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/horizontal\/\">Horizontal<\/a> \u2013 arrange the pages horizontally side-by-side, left-to-right, in a single output<\/li>\n<li><a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/vertical\/\">Vertical<\/a> \u2013 arrange the pages vertically one below the other in a single output<\/li>\n<li><a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/tiffframes\/\">TiffFrames<\/a> \u2013 arrange each page as a separate frame in a multi-frame TIFF image, applies only to TIFF image formats<\/li>\n<\/ul>\n<p>The following code example shows how to save a multi-page DOCX document as JPEG image with Horizontal layout:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Rendering.docx&#34;<\/span><span class=\"p\">);<\/span>\n\n<span class=\"k\">auto<\/span> <span class=\"n\">options<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">ImageSaveOptions<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">SaveFormat<\/span><span class=\"o\">::<\/span><span class=\"n\">Jpeg<\/span><span class=\"p\">);<\/span>\n<span class=\"c1\">\/\/ Set up Horizontal layout.\n<\/span><span class=\"c1\"><\/span><span class=\"n\">options<\/span><span class=\"p\">.<\/span><span class=\"n\">MultiPageLayout<\/span> <span class=\"o\">=<\/span> <span class=\"n\">MultiPageLayout<\/span><span class=\"p\">.<\/span><span class=\"n\">Horizontal<\/span><span class=\"p\">(<\/span><span class=\"mi\">10<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;ImageSaveOptions.GridLayout.jpg&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div>\n<p>You can also customize the output file page appearance \u2013 specify <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/get_backcolor\/\">BackColor<\/a>, <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/get_bordercolor\/\">BorderColor<\/a>, and <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words.saving\/multipagelayout\/get_borderwidth\/\">BorderWidth<\/a>.<\/p>\n<p>The following code example shows how to save a multi-page DOCX document as PNG image with Grid layout:<\/p>\n<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"k\">auto<\/span> <span class=\"n\">doc<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Document<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;Rendering.docx&#34;<\/span><span class=\"p\">);<\/span>\n\n<span class=\"k\">auto<\/span> <span class=\"n\">options<\/span> <span class=\"o\">=<\/span> <span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">MakeObject<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">ImageSaveOptions<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">SaveFormat<\/span><span class=\"o\">::<\/span><span class=\"n\">Jpeg<\/span><span class=\"p\">);<\/span>\n<span class=\"c1\">\/\/ Set up a grid layout with:\n<\/span><span class=\"c1\">\/\/ - 3 columns per row.\n<\/span><span class=\"c1\">\/\/ - 10pts spacing between pages (horizontal and vertical).\n<\/span><span class=\"c1\"><\/span><span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_PageLayout<\/span><span class=\"p\">(<\/span><span class=\"n\">Aspose<\/span><span class=\"o\">::<\/span><span class=\"n\">Words<\/span><span class=\"o\">::<\/span><span class=\"n\">Saving<\/span><span class=\"o\">::<\/span><span class=\"n\">MultiPageLayout<\/span><span class=\"o\">::<\/span><span class=\"n\">Grid<\/span><span class=\"p\">(<\/span><span class=\"mi\">3<\/span><span class=\"p\">,<\/span> <span class=\"mf\">10.0f<\/span><span class=\"p\">,<\/span> <span class=\"mf\">10.0f<\/span><span class=\"p\">));<\/span>\n\n<span class=\"c1\">\/\/ Customize the background and border.\n<\/span><span class=\"c1\"><\/span><span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_PageLayout<\/span><span class=\"p\">()<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_BackColor<\/span><span class=\"p\">(<\/span><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">Drawing<\/span><span class=\"o\">::<\/span><span class=\"n\">Color<\/span><span class=\"o\">::<\/span><span class=\"n\">get_LightGray<\/span><span class=\"p\">());<\/span>\n<span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_PageLayout<\/span><span class=\"p\">()<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_BorderColor<\/span><span class=\"p\">(<\/span><span class=\"n\">System<\/span><span class=\"o\">::<\/span><span class=\"n\">Drawing<\/span><span class=\"o\">::<\/span><span class=\"n\">Color<\/span><span class=\"o\">::<\/span><span class=\"n\">get_Blue<\/span><span class=\"p\">());<\/span>\n<span class=\"n\">options<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">get_PageLayout<\/span><span class=\"p\">()<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">set_BorderWidth<\/span><span class=\"p\">(<\/span><span class=\"mf\">2.0f<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">doc<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">Save<\/span><span class=\"p\">(<\/span><span class=\"sa\">u<\/span><span class=\"s\">&#34;ImageSaveOptions.GridLayout.png&#34;<\/span><span class=\"p\">,<\/span> <span class=\"n\">options<\/span><span class=\"p\">);<\/span>\n<\/code><\/pre><\/div>\n<hr>\n<h2 id=\"faq\">FAQ<\/h2>\n<ol>\n<li>\n<p><strong>Q:<\/strong> How can I export each page of a document as a separate image file?<br>\n<strong>A:<\/strong> Use the <code>SinglePage<\/code> layout together with the <code>PageRange<\/code> property of <code>ImageSaveOptions<\/code>. Set <code>PageRange<\/code> to the desired page number and call <code>Save<\/code> inside a loop for all pages.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Can I create a multi\u2011frame TIFF where each page becomes a separate frame?<br>\n<strong>A:<\/strong> Yes. Set <code>options-&gt;set_MultiPageLayout(Aspose::Words::Saving::MultiPageLayout::TiffFrames());<\/code> and use <code>SaveFormat::Tiff<\/code>. Each document page will be stored as an individual frame in the resulting TIFF file.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How do I control the resolution (DPI) of the exported images?<br>\n<strong>A:<\/strong> Use <code>options-&gt;set_Resolution(int dpi);<\/code>. For example, <code>options-&gt;set_Resolution(300);<\/code> will generate 300\u202fDPI images, which is useful for high\u2011quality prints.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> Is it possible to export only a subset of pages, e.g., pages 2\u20115?<br>\n<strong>A:<\/strong> Yes. Set the <code>PageRange<\/code> property: <code>options-&gt;set_PageRange(Aspose::Words::Saving::PageRange(2, 5));<\/code>. The export will include only the specified pages using the chosen layout.<\/p>\n<\/li>\n<li>\n<p><strong>Q:<\/strong> How can I change the background color of the exported image pages?<br>\n<strong>A:<\/strong> Access the layout object via <code>options-&gt;get_PageLayout()<\/code> and call <code>set_BackColor<\/code>. Example: <code>options-&gt;get_PageLayout()-&gt;set_BackColor(System::Drawing::Color::get_White());<\/code>. This color fills the area around each page when using grid\u2011type layouts.<\/p>\n<\/li>\n<\/ol>\n\n      "},{"title":"Cpp: File Formats and Conversions","link":"https:\/\/docs.aspose.com\/words\/cpp\/file-formats-and-conversions\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","guid":"https:\/\/docs.aspose.com\/words\/cpp\/file-formats-and-conversions\/","description":"\n        \n        \n        \n\n<div class=\"alert alert-primary\" role=\"alert\">\n\n<p><strong>Try online<\/strong><\/p>\n<p>You can try the conversion functionality by using our <a href=\"https:\/\/products.aspose.app\/words\/conversion\">Free online converter<\/a> tool.<\/p>\n\n<\/div>\n\n<p>The ability to quickly and reliably convert various document formats with a high degree of precision is Aspose.Words&rsquo;s flagship feature. This is often a good enough reason to choose Aspose.Words for C++.<\/p>\n<p>With Aspose.Words you can convert documents from any supported load format to any supported save format using just two lines of code:<\/p>\n<ol>\n<li>Load a document from a file or stream<\/li>\n<li>Save it to any supported format<\/li>\n<\/ol>\n<p>The following code example shows how to convert a document:<\/p>\n<script type=\"application\/javascript\" src=\"https:\/\/gist.github.com\/aspose-words-gists\/b9784b73e288805e08fba6e3fc5ae2af.js?file=docx-to-pdf.h\"><\/script>\n\n<p>For more details on loading, converting, and saving documents, see the <a href=\"https:\/\/docs.aspose.com\/words\/words\/cpp\/loading-saving-and-converting\/\">Loading, Saving and Converting<\/a> section.<\/p>\n<h2 id=\"high-fidelity\">High Fidelity<\/h2>\n<p>One of the main goals of Aspose.Words is to provide high-fidelity conversion between document formats. We use the word \u201chigh-fidelity\u201d to describe conversions where the output document retains all the content and formatting of the original.<\/p>\n<p>Modern word processing document formats are complex and include hundreds of features. Sometimes, when a vendor claims that their solution supports a particular document format \u2013 it means only the basic features of the format are supported. For example, Microsoft Word documents have advanced features such as footnotes, text boxes, auto shapes, OLE objects, fields, and advanced formatting attributes. Many of these elements are often ignored in document processing libraries, but not in Aspose.Words.<\/p>\n<h3 id=\"greater-extent-of-format-support\">Greater Extent of Format Support<\/h3>\n<p>The indisputable advantage of Aspose.Words is the great extent of support for most of the well-known formats. It is hard or impossible to find the same level of support for many important features elsewhere.<\/p>\n<p>When purchasing a solution supporting a particular format, find out about the level at which the features of this format are supported. To test, create a complex file and run it through the proposed solution. You will often find that many document elements and formatting will be lost. For example, for the DOC format, shapes, textboxes, fields, columns, OLE objects, revisions, right-to-left text usually suffer.<\/p>\n<p>Aspose.Words Document Object Model (DOM) was designed with Microsoft Word document formats in mind. Therefore, our level of support for those formats, such as DOC, DOCX, RTF, or WordprocessingML, is unprecedented. Conversion in any direction between these formats is high-fidelity.<\/p>\n<p>When running a complex document through Aspose.Words, enjoy the unmatched completeness of format implementation.<\/p>\n<h3 id=\"conversion-examples-between-popular-formats\">Conversion Examples between Popular Formats<\/h3>\n<p>Below are examples of conversions between some popular formats. You can evaluate how accurately Aspose.Words copes with the task.<\/p>\n<hr>\n<p><em>DOC to RTF \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<p><img src=\"high-quality-conversions-1.png\" alt=\"doc-to-rtf-aspose-words-cpp-1\" style=\"width:500px; vertical-align: top\"\/> <img src=\"high-quality-conversions-2.png\" alt=\"doc-to-rtf-aspose-words-cpp-2\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<p><em>DOC to PDF \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<p><img src=\"high-quality-conversions-1.png\" alt=\"doc-to-pdf-aspose-words-cpp-1\" style=\"width:500px; vertical-align: top\"\/> <img src=\"high-quality-conversions-3.png\" alt=\"doc-to-pdf-aspose-words-cpp-2\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<p><em>DOC to ODT \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<p><img src=\"high-quality-conversions-1.png\" alt=\"doc-to-odt-aspose-words-cpp-1\" style=\"width:500px; vertical-align: top\"\/> <img src=\"high-quality-conversions-4.png\" alt=\"doc-to-odt-aspose-words-cpp-2\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<p><em>DOC to XPS \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<p><img src=\"xml-paper-specification-xps-2.png\" alt=\"xml-paper-specification-xps_2\" style=\"width:500px; vertical-align: top\"\/> <img src=\"xml-paper-specification-xps-3.png\" alt=\"xml-paper-specification-xps_3\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<p><em>DOC to JPEG \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<img src=\"image-formats-tiff-png-bmp-emf-jpeg-gif-9.png\" alt=\"doc-to-jpeg-aspose-words-cpp-1\" style=\"width:1000px; vertical-align: top\"\/>\n<hr>\n<p><em>RTF to TXT \u2013\u00a0high-fidelity conversion:<\/em><\/p>\n<p><img src=\"plain-text-txt-2.png\" alt=\"rtf-to-txt-aspose-words-cpp-1\" style=\"width:500px; vertical-align: top\"\/> <img src=\"plain-text-txt-3.png\" alt=\"rtf-to-txt-aspose-words-cpp-2\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<p>Although all of the converters in Aspose.Words are great, sometimes you will not be able to get the same appearance for documents in different formats.<\/p>\n\n\n<div class=\"alert alert-primary\" role=\"alert\">\n\nNote that in such situations, Aspose.Words has the conversion marked &ldquo;high-fidelity&rdquo; and the output document will be the same as after converting via Microsoft Word.\n<\/div>\n\n<p>For example, there is no simple one-to-one match between all the features of HTML and Microsoft Word documents. There are no headers\/footers, sections, fields, and tabs in HTML. Conversely, not all CSS attributes and rules can be mapped to a Microsoft Word document.<\/p>\n<p>Below is an example of conversions from DOC to HTML.<\/p>\n<hr>\n<p>DOC to HTML \u2013\u00a0high-fidelity conversion:<\/p>\n<p><img src=\"high-quality-conversions-1.png\" alt=\"doc-to-html-aspose-words-cpp-1\" style=\"width:500px; vertical-align: top\"\/> <img src=\"high-quality-conversions-5.png\" alt=\"doc-to-html-aspose-words-cpp-2\" style=\"width:500px; vertical-align: top\"\/><\/p>\n<hr>\n<h2 id=\"high-scalability\">High Scalability<\/h2>\n<p>Scalable server-side scenarios use Aspose.Words mainly because of its simple and clean design \u2013 Aspose.Words supports multithreading. <a href=\"https:\/\/reference.aspose.com\/words\/cpp\/aspose.words\/document\/\">Document<\/a> objects are independent of each other, and as long as only one thread can modify a document at a time (a typical requirement for any collection class), multiple threads can process any number of documents at the same time.<\/p>\n<h2 id=\"high-performance\">High Performance<\/h2>\n<p>Aspose.Words demonstrates high performance when loading and saving documents. In testing, a DOC file over 5Mb in size was loaded in less than 1 second and then saved in less than 1 second on a P4 3GHz machine. Smaller files can be processed at thousands-per-minute speeds.<\/p>\n<p>On several occasions, our customers have reported to us that they could not believe the speed of Aspose.Words. They stepped over the line of code that was loading a huge document into the debugger, and it was so instantaneous that they could not believe the file was loaded into the <strong>Document<\/strong> object.<\/p>\n\n      "}]}}