> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/conversion/convert-office.md).

# Convert MS Office (Word, Excel, PowerPoint, RTF, MSG, EML) to PDF on Server/Desktop

Convert an MS Office file (docx, pptx, xlsx, rtf, msg, eml) to a PDF document without any external third party dependencies.  Samples offered in Python, Java, C#, dotnet, node.js (JavaScript), php, Ru

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#OfficeConversion" class="button primary">Package: Office Conversion</a><a href="https://showcase.apryse.com/office-to-pdf" class="button primary">Live demo</a>
{% endhint %}

To convert an MS Office file to a PDF document without any external third party dependencies.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert.OfficeToPDF(doc, filename, null);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Start with a PDFDoc (the conversion destination)
PDFDoc doc;

// perform the conversion with no optional parameters
Convert::OfficeToPDF(doc, filename, NULL);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// Start with a PDFDoc (the conversion destination)
doc := NewPDFDoc()

// perform the conversion with no optional parameters
ConvertOfficeToPDF(doc, filename, NewConversionOptions())
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert.officeToPdf(doc, filename, null);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}

<pre class="language-js" data-line-numbers><code class="lang-js">const { PDFNet } = require('@pdftron/pdfnet-node');

async function main() {
  // perform the conversion with no optional parameters
  const buf = await PDFNet.Convert.office2PDFBuffer(filename);

  // end with a PDFDoc (the conversion destination)
  const doc = await PDFNet.PDFDoc.createFromBuffer(buf);
}

PDFNet.runWithCleanup(main, '<code class="expression">visitor.claims.serverKey || "YOUR_LICENSE_KEY"</code>');
</code></pre>

{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// Start with a PDFDoc (the conversion destination)
val doc = PDFDoc()

// perform the conversion with no optional parameters
Convert.officeToPdf(doc, filename, null)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
// Start with a PDFDoc (the conversion destination)
PTPDFDoc* doc = [[PTPDFDoc alloc] init];

// perform the conversion with no optional parameters
[PTConvert OfficeToPDF:doc in_filename:filename options:Nil];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Start with a PDFDoc (the conversion destination)
let doc: PTPDFDoc = PTPDFDoc()

// perform the conversion with no optional parameters
PTConvert.office(toPDF: doc, in_filename: inputPath, options: nil)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
// Start with a PDFDoc (the conversion destination)
$doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert::OfficeToPDF($doc, $filename, NULL);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# Start with a PDFDoc (the conversion destination)
doc = PDFDoc()

# perform the conversion with no optional parameters
Convert.OfficeToPDF(doc, filename, None)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
# Start with a PDFDoc (the conversion destination)
doc = PDFDoc.new()

# perform the conversion with no optional parameters
Convert.OfficeToPDF(doc, filename, nil)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
' Start with a PDFDoc (the conversion destination)
Dim doc As PDFDoc = New PDFDoc

' perform the conversion with no optional parameters
Convert.OfficeToPDF(doc, filename, Nothing)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Convert MS Office files to PDF - Full Sample](/core/get-started/samples/officetopdftest.md) Full sample code which illustrates how to convert MS Office files (Word, Excel, PowerPoint) to PDF. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB.

{% hint style="info" %}
Most MSG and EML conversions require the [HTML2PDF ](/core/learn-more/modules.md#html2pdf-module)module to be installed. No HTML2PDF license is required for the conversions.
{% endhint %}

## Additional font resources

The converter will attempt to make use of any fonts installed on the system. Fonts (or alternatives) can also be provided as described below.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFNet.Initialize();

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader.SetCustomWebFontURL("file:///home/user/webfonts/");

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.EnableDownloads();
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFNet::Initialize();

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader::SetCustomWebFontURL("file:///home/user/webfonts/");

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader::EnableDownloads();
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
PDFNetInitialize()

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloaderSetCustomWebFontURL("file:///home/user/webfonts/")

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloaderEnableDownloads()
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFNet.initialize();

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader.setCustomWebFontURL("file:///home/user/webfonts/");

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.enableDownloads();
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}

<pre class="language-js" data-line-numbers><code class="lang-js">const { PDFNet } = require('@pdftron/pdfnet-node');

const main = async () => {
  // if fonts.json is at /home/user/webfonts/fonts.json
  // this can also be an https URL
  WebFontDownloader.setCustomWebFontURL("file:///home/user/webfonts/");

  // allow PDFNet to access the network to download missing fonts when possible.
  WebFontDownloader.enableDownloads();
}

PDFNet.runWithCleanup(main, '<code class="expression">visitor.claims.serverKey || "YOUR_LICENSE_KEY"</code>').then(function(){ PDFNet.shutdown(); });
</code></pre>

{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
PDFNet.initialize()

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader.setCustomWebFontURL("file:///home/user/webfonts/")

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.enableDownloads()
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
[PTPDFNet Initialize];

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
[PTWebFontDownloader SetCustomWebFontURL:@"file:///home/user/webfonts/"];

// allow PDFNet to access the network to download missing fonts when possible.
[PTWebFontDownloader EnableDownloads];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
PTPDFNet.initialize()

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
PTWebFontDownloader.setCustomWebFontURL("file:///home/user/webfonts/")

// allow PDFNet to access the network to download missing fonts when possible.
PTWebFontDownloader.enableDownloads()
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
PDFNet::Initialize();

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader::SetCustomWebFontURL("file:///home/user/webfonts/");

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader::EnableDownloads();
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
PDFNet.Initialize()

# if fonts.json is at /home/user/webfonts/fonts.json
# this can also be an https URL
WebFontDownloader.SetCustomWebFontURL("file:///home/user/webfonts/")

# allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.EnableDownloads()
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
PDFNet.Initialize()

# if fonts.json is at /home/user/webfonts/fonts.json
# this can also be an https URL
WebFontDownloader.SetCustomWebFontURL("file:///home/user/webfonts/")

# allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.EnableDownloads()
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
PDFNet.Initialize()

' if fonts.json is at /home/user/webfonts/fonts.json
' this can also be an https URL
WebFontDownloader.SetCustomWebFontURL("file:///home/user/webfonts/")

' allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.EnableDownloads()
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Self serving substitute fonts faq](/web/get-started/faq/self-serve-substitute-fonts.md) A more detailed faq guide about creating substitute web fonts set when a font is not embedded in the document or available on the system.

[Self serve font package](https://pdftron.s3.amazonaws.com/downloads/SelfServeWebFontsV2.zip) A curated package of fonts with great coverage of widely used font files. Simply extract and pass the path to the API above.

### User-provided .docx resource document (optional)

The converter can produce good results with no user-supplied fonts at all, but for the highest conversion quality, fonts can be provided in a .docx resource document. This document must be named `pdftron_convert_resources.docx` and can reside in either in the resource directory (use PDFNet.AddResourceSearchPath() to set this value), or at some arbitrary location, specified in the conversion options (set via OfficeToPDFOptions.SetResourceDocPath()). The file should have all the required fonts embedded within it (you can create a file like this by checking the "embed fonts in the file" option from the "Save" preferences within Word )

### Apryse-provided fallback font data (required)

If no appropriate fonts are found on the system or in a resource .docx, then the converter will need to use it's own fallback font data. On desktop/server, this data is built into the library and will be automatically used. On mobile, the data is not part of the binary, but is included in the SDK package as a separate resource file: `pdftron_layout_resources.plugin`. This file can either be placed in the resource directory (set via PDFNet.AddResourceSearchPath()), or in some arbitrary location, specified in the conversion options.

## Font embedding

When the conversion routine is able to find a matching font, it will embed that font in the resulting PDF. Otherwise, the converter will attempt to embed one of the PDF base 14 fonts if there is a close enough match, and failing that, will not embed the font at all.

## Smart embedding

Using pdftron-supplied smart substitution data, the conversion routine can produce PDF documents with fully embedded fonts that are a close match to the originals. To enable this option, either place the file `pdftron_smart_substitution.plugin` (included in the SDK download) in the resource directory (set via PDFNet.AddResourceSearchPath()), or specify it's path directly in the conversion options.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Start with a PDFDoc (the conversion destination)
using (PDFDoc pdfdoc = new PDFDoc())
{
  OfficeToPDFOptions options = new OfficeToPDFOptions();
  options.SetSmartSubstitutionPluginPath(input_path);
  // create a conversion object -- this sets things up but does not yet
  // perform any conversion logic.
  // in a multithreaded environment, this object can be used to monitor
  // the conversion progress and potentially cancel it as well
  DocumentConversion conversion = pdftron.PDF.Convert.StreamingPDFConversion(pdfdoc, input_path + input_filename, options);

  // actually perform the conversion
  // this particular method will not throw on conversion failure, but will
  // return an error status instead
  if (conversion.TryConvert() == DocumentConversionResult.e_document_conversion_success)
  {
    // save the result
    pdfdoc.Save(output_path + output_filename, SDFDoc.SaveOptions.e_linearized);
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Start with a PDFDoc (the conversion destination)
PDFDoc pdfdoc;
OfficeToPDFOptions options;

// set up smart font substitutions to improve conversion results
// in situations where the original fonts are not available
options.SetSmartSubstitutionPluginPath(input_path);

// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
DocumentConversion conversion = Convert::StreamingPDFConversion(pdfdoc, input_path + input_filename, &options);

// actually perform the conversion
// this particular method will not throw on conversion failure, but will
// return an error status instead
while (conversion.GetConversionStatus() == DocumentConversion::eIncomplete)
{
  conversion.ConvertNextPage();
}
if(conversion.GetConversionStatus() == DocumentConversion::eSuccess)
{
  // save the result
  pdfdoc.Save(output_path + output_filename, SDF::SDFDoc::e_linearized, NULL);
}
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// Start with a PDFDoc (the conversion destination)
doc := NewPDFDoc()
options :=  NewOfficeToPDFOptions() 

// set up smart font substitutions to improve conversion results
// in situations where the original fonts are not available
options.SetSmartSubstitutionPluginPath(inputPath)

// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
conversion := ConvertStreamingPDFConversion(pdfdoc, inputPath + inputFileName, options)

// actually perform the conversion
// this particular method will not throw on conversion failure, but will
// return an error status instead
for {
  if (conversion.GetConversionStatus() != DocumentConversionEIncomplete){
    break
  }
  conversion.ConvertNextPage()
}
if(conversion.GetConversionStatus() == DocumentConversionESuccess) {
  // save the result
  pdfdoc.Save(outputPath + outputFileName, uint(SDFDocE_linearized))
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
OfficeToPDFOptions options = new OfficeToPDFOptions();
options.setSmartSubstitutionPluginPath(input_path);

// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
DocumentConversion conversion = Convert.streamingPdfConversion(input_path + inputFilename, options);

// actually perform the conversion
while (conversion.getConversionStatus() == DocumentConversion.e_incomplete) {
  conversion.convertNextPage();
}

if (conversion.tryConvert() == DocumentConversion.e_success) {
  // save the result
  PDFDoc doc = conversion.getDoc();
  doc.save(output_path + outputFilename, SDFDoc.SaveMode.LINEARIZED, null);
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}

<pre class="language-js" data-line-numbers><code class="lang-js">const { PDFNet } = require('@pdftron/pdfnet-node');

const main = async () => {
  const options = new PDFNet.Convert.OfficeToPDFOptions();
  options.setSmartSubstitutionPluginPath(input_path);

  // create a conversion object -- this sets things up but does not yet
  // perform any conversion logic.
  const conversion = await PDFNet.Convert.streamingPdfConversionWithPath(input_path + inputFilename, options);

  // actually perform the conversion
  while (conversion.getConversionStatus() == PDFNet.DocumentConversion.e_Incomplete) {
    conversion.convertNextPage();
  }
  if (conversion.getConversionStatus() == PDFNet.DocumentConversion.e_Success) {
    // save the result
    const doc = await conversion.getDoc();
    doc.save(output_path + outputFilename, PDFNet.SDFDoc.SaveOptions.e_linearized);
  }
}

PDFNet.runWithCleanup(main, '<code class="expression">visitor.claims.serverKey || "YOUR_LICENSE_KEY"</code>').then(function(){ PDFNet.shutdown(); });
</code></pre>

{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val options = OfficeToPDFOptions()
options.smartSubstitutionPluginPath = sLayoutSmartPluginPath

// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
val conversion = Convert.streamingPdfConversion(Utils.getAssetTempFile(INPUT_PATH + inputFilename)!!.absolutePath, options)

// actually perform the conversion
while (conversion.conversionStatus == DocumentConversion.e_incomplete) {
  conversion.convertNextPage()
}
if (conversion.tryConvert() == DocumentConversion.e_success) {
  // save the result
  val doc = conversion.doc
  doc.save(Utils.createExternalFile(outputFilename!!, mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
}
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
// Start with a PDFDoc (the conversion destination)
PTPDFDoc* pdfDoc = [[PTPDFDoc alloc] init];

PTOfficeToPDFOptions* options = [[PTOfficeToPDFOptions alloc] init];
[options SetSmartSubstitutionPluginPath:input_path];

// create a conversion object with optional parameters
PTDocumentConversion* conversion = [PTConvert StreamingPDFConversionWithDoc: pdfDoc in_filename:[NSString stringWithFormat:@"%@/%@", input_path, input_filename options:options];

// convert each page, and report progress
while([conversion GetConversionStatus] == e_ptIncomplete)
{
  [conversion ConvertNextPage];
}
if ([conversion TryConvert] == e_ptSuccess)
{
  //save the result 
  [pdfDoc SaveToFile: [NSString stringWithFormat:@"%@/%@", output_path, output_filename] flags: e_ptlinearized];
}
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Start with a PDFDoc (the conversion destination)
let pdfDoc: PTPDFDoc = PTPDFDoc()

let options: PTOfficeToPDFOptions = PTOfficeToPDFOptions()
options.setSmartSubstitutionPluginPath(pluginPath)

// create a conversion object with optional parameters
let conversion: PTDocumentConversion = PTConvert.streamingPDFConversion(with: pdfDoc, in_filename: inputPath, options: options)

// convert each page, and report progress
while conversion.getStatus() == e_ptIncomplete {
  conversion.convertNextPage()
}

if conversion.tryConvert() == e_ptSuccess {
  //save the result
  pdfDoc.save(toFile: "\(outputPath)", flags: e_ptremove_unused.rawValue)
}
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
// Start with a PDFDoc (the conversion destination)
$pdfdoc = new PDFDoc();
$options = new OfficeToPDFOptions(); //ConversionOptions();

// set up smart font substitutions to improve conversion results
// in situations where the original fonts are not available
$options->SetSmartSubstitutionPluginPath($input_path);

// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
$conversion = Convert::StreamingPDFConversion($pdfdoc, $input_path.$input_filename, $options);

// actually perform the conversion
// this particular method will not throw on conversion failure, but will
// return an error status instead
while ($conversion->GetConversionStatus() == DocumentConversion::eIncomplete)
{
  $conversion->ConvertNextPage();
}
if($conversion->GetConversionStatus() == DocumentConversion::eSuccess)
{
  // save the result
  $pdfdoc->Save($output_path . $output_filename, SDFDoc::e_linearized, NULL);
}
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# Start with a PDFDoc (the conversion destination)
pdfdoc =  PDFDoc()
options =  OfficeToPDFOptions() 

# set up smart font substitutions to improve conversion results
# in situations where the original fonts are not available
options.SetSmartSubstitutionPluginPath(input_path)

# create a conversion object -- this sets things up but does not yet
# perform any conversion logic.
# in a multithreaded environment, this object can be used to monitor
# the conversion progress and potentially cancel it as well
conversion = Convert.StreamingPDFConversion(pdfdoc, input_path + input_filename, options)

# actually perform the conversion
# this particular method will not throw on conversion failure, but will
# return an error status instead
while (conversion.GetConversionStatus() == DocumentConversion.eIncomplete):
  conversion.ConvertNextPage()

if(conversion.GetConversionStatus() == DocumentConversion.eSuccess):
  # save the result
  pdfdoc.Save(output_path + output_filename, SDFDoc.e_linearized)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
# Start with a PDFDoc (the conversion destination)
pdfdoc = PDFDoc.new()
options = OfficeToPDFOptions.new() 

# set up smart font substitutions to improve conversion results
# in situations where the original fonts are not available
inputFile = $inputPath 
options.SetSmartSubstitutionPluginPath(inputFile)

# create a conversion object -- this sets things up but does not yet
# perform any conversion logic.
# in a multithreaded environment, this object can be used to monitor
# the conversion progress and potentially cancel it as well
inputFile = $inputPath + input_filename
conversion = Convert.StreamingPDFConversion(pdfdoc, inputFile, options)

# actually perform the conversion
# this particular method will not throw on conversion failure, but will
# return an error status instead
while (conversion.GetConversionStatus() == DocumentConversion::EIncomplete)
  conversion.ConvertNextPage()
end

if(conversion.GetConversionStatus() == DocumentConversion::ESuccess)
  # save the result
  outputFile = $outputPath + output_filename
  pdfdoc.Save(outputFile, SDFDoc::E_linearized)
end
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Using pdfdoc As PDFDoc = New PDFDoc
  Dim options As OfficeToPDFOptions = New OfficeToPDFOptions

  ' set up smart font substitutions to improve conversion results
  ' in situations where the original fonts are not available
  options.SetSmartSubstitutionPluginPath(input_path)

  ' # create a conversion object -- this sets things up but does not yet
  ' perform any conversion logic.
  ' in a multithreaded environment, this object can be used to monitor
  ' the conversion progress and potentially cancel it as well
  Using conversion As DocumentConversion = pdftron.PDF.Convert.StreamingPDFConversion(pdfdoc, input_path + input_filename, options)

    ' actually perform the conversion
    ' this particular method will not throw on conversion failure, but will
    ' return an error status instead
    While conversion.GetConversionStatus() = DocumentConversionResult.e_document_conversion_incomplete
      conversion.ConvertNextPage()
    End While

    If conversion.TryConvert() = DocumentConversionResult.e_document_conversion_success Then
      ' save the result
      pdfdoc.Save(output_path + output_filename, SDFDoc.SaveOptions.e_linearized)
    End If
  End Using
End Using
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/conversion/convert-office.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
