1. Home
  2. /
  3. GroupDocs.Conversion.LowCode
  4. /
  5. Developer Guide
  6. /
  7. Using PDF to MD Converter

Using PDF to MD Converter

This topic shows how to use the PdfToMdConverter with examples that demonstrate common use cases for converting PDF files to Markdown format.

Prerequisites

Refer to the Developer Guide to learn how to set up your environment and run code examples in this section.

You can also check two related topics on Loading Source Documents and Saving Converted Documents to learn how to specify input and output documents.

Basic Example

The following example shows the most common use case for converting PDF document to Markdown. The source PDF file is loaded from a current folder. The converted file is saved to the same folder.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Create a converter for the PDF file
var converter = new PdfToMdConverter("business-plan.pdf");

// Convert PDF to Markdown
converter.Convert("business-plan.md");
Imports System
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Create a converter from file path
        Dim converter As New PdfToMdConverter("business-plan.pdf")

        ' Convert PDF to Markdown
        converter.Convert("business-plan.md")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Create a converter from file path
    let converter = new PdfToMdConverter("business-plan.pdf")

    // Convert PDF to Markdown
    converter.Convert("business-plan.md")
    0

Sample input file: Download business-plan.pdf

Expected output: Download business-plan.md

PDF Load Options

This section covers only the main scenarios. You can also refer to the API references for the PdfLoadOptions for a complete list of options that you can specify.

Convert Protected PDF to Markdown

The following example shows how to convert protected PDF file and save it to unprotected Markdown file.

In case you do not specify password for protected document PasswordRequiredException is going to be thrown.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Provide password through load options
var converter = new PdfToMdConverter("protected.pdf", options =>
{
    options.Password = "12345";
});

// Convert PDF to Markdown
converter.Convert("unprotected.md");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Provide password through load options
        Dim converter As New PdfToMdConverter("protected.pdf", Sub(options)
            options.Password = "12345"
        End Sub)

        ' Convert PDF to Markdown
        converter.Convert("unprotected.md")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Create a converter from file path
    let converter = new PdfToMdConverter("protected.pdf", fun options ->
        options.Password <- "12345"
    )

    // Convert PDF to Markdown
    converter.Convert("unprotected.md")
    0

Sample input: Download protected.pdf (Password: 12345)

Expected output: Download unprotected.md

Flatten Fields in Form-Fillable PDF

The following example shows how to convert a form‑fillable PDF into static content by flattening form fields.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Flatten form fields through load options
var converter = new PdfToMdConverter("form-fields.pdf", options =>
{
    options.FlattenAllFields = true;
});

// Convert PDF to Markdown
converter.Convert("flattened.md");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Flatten form fields through load options
        Dim converter As New PdfToMdConverter("form-fields.pdf", Sub(options)
            options.FlattenAllFields = True
        End Sub)

        ' Convert PDF to Markdown
        converter.Convert("flattened.md")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")
    
    // Apply license
    License.Set(publicKey, privateKey)

    // Flatten form fields through load options
    let converter = new PdfToMdConverter("form-fields.pdf", fun options ->
        options.FlattenAllFields <- true
    )
    
    // Convert PDF to Markdown
    converter.Convert("flattened.md")
    0

Sample input: Download form-fields.pdf (Fillable PDF)

Expected output: Download flattened.md

Convert PDF with Annotations to Markdown without Annotations

By default, annotations are added to the output Markdown file, see this with-annotations.pdf (text HOME BASED PROFESSIONAL SERVICES is highlighted) as an example of PDF file with annotations.

The following example shows how to convert a PDF file that contains annotations and save a Markdown file without annotations.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Hide annotations using HidePdfAnnotations
var converter = new PdfToMdConverter("with-annotations.pdf", options =>
{
    options.HidePdfAnnotations = true;
});

// Convert PDF to Markdown
converter.Convert("no-annotations.md");
Imports System
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey As String = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey As String = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Hide annotations using HidePdfAnnotations
        Dim converter As New PdfToMdConverter("with-annotations.pdf", Sub(options)
                                                                             options.HidePdfAnnotations = True
                                                                         End Sub)

        ' Convert PDF to Markdown
        converter.Convert("no-annotations.md")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main argv =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply license
    License.Set(publicKey, privateKey)

    // Hide annotations using HidePdfAnnotations
    let converter = 
        new PdfToMdConverter("with-annotations.pdf", fun options ->
            options.HidePdfAnnotations <- true
        )

    // Convert PDF to Markdown
    converter.Convert("no-annotations.md")

    0 // return an integer exit code

Sample input: Download with-annotations.pdf (Contains highlight annotations)

Expected output: Download no-annotations.md (Annotations hidden)

Markdown Convert Options

The examples in this section shows how you can adjust the output using MarkdownOptions.

Skip Images when converting PDF to Markdown

By default, images are converted to base64 strings and embedded directly in the Markdown file. You can control this behavior using the ExportImagesAsBase64 property in MarkdownOptions class. When set to false, images are not included into final Markdown file.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Create the converter
var converter = new PdfToMdConverter("business-plan.pdf");

        // Convert to Markdown without embedding images as base64
        converter.Convert("without-images.md", convertOptions =>
        {
            convertOptions.MarkdownOptions.ExportImagesAsBase64 = false;
        });
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Create the converter
        Dim converter As New PdfToMdConverter("business-plan.pdf")

        ' Convert to Markdown without embedding images as base64
        converter.Convert("without-images.md", Sub(convertOptions)
            convertOptions.MarkdownOptions.ExportImagesAsBase64 = False
        End Sub)
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply license
    License.Set(publicKey, privateKey)

    // Create the converter
    let converter = new PdfToMdConverter("business-plan.pdf")

    // Convert to Markdown without embedding images as base64
    converter.Convert("without-images.md", fun convertOptions ->
        convertOptions.MarkdownOptions.ExportImagesAsBase64 <- false
    )

    0

Expected output: Download without-images.md (Images skipped)