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.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply the licenseLicense.Set(publicKey,privateKey);// Create a converter for the PDF filevarconverter=newPdfToMdConverter("business-plan.pdf");// Convert PDF to Markdownconverter.Convert("business-plan.md");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply the license
License.Set(publicKey,privateKey)' Create a converter from file path
DimconverterAsNewPdfToMdConverter("business-plan.pdf")' Convert PDF to Markdown
converter.Convert("business-plan.md")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newPdfToMdConverter("business-plan.pdf")// Convert PDF to Markdown
converter.Convert("business-plan.md")0
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.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Provide password through load optionsvarconverter=newPdfToMdConverter("protected.pdf",options=>{options.Password="12345";});// Convert PDF to Markdownconverter.Convert("unprotected.md");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Provide password through load options
DimconverterAsNewPdfToMdConverter("protected.pdf",Sub(options)options.Password="12345"EndSub)' Convert PDF to Markdown
converter.Convert("unprotected.md")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newPdfToMdConverter("protected.pdf",funoptions->options.Password<-"12345")// Convert PDF to Markdown
converter.Convert("unprotected.md")0
The following example shows how to convert a form‑fillable PDF into static content by flattening form fields.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Flatten form fields through load optionsvarconverter=newPdfToMdConverter("form-fields.pdf",options=>{options.FlattenAllFields=true;});// Convert PDF to Markdownconverter.Convert("flattened.md");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Flatten form fields through load options
DimconverterAsNewPdfToMdConverter("form-fields.pdf",Sub(options)options.FlattenAllFields=TrueEndSub)' Convert PDF to Markdown
converter.Convert("flattened.md")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Flatten form fields through load options
letconverter=newPdfToMdConverter("form-fields.pdf",funoptions->options.FlattenAllFields<-true)// Convert PDF to Markdown
converter.Convert("flattened.md")0
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.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Hide annotations using HidePdfAnnotationsvarconverter=newPdfToMdConverter("with-annotations.pdf",options=>{options.HidePdfAnnotations=true;});// Convert PDF to Markdownconverter.Convert("no-annotations.md");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKeyAsString=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKeyAsString=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Hide annotations using HidePdfAnnotations
DimconverterAsNewPdfToMdConverter("with-annotations.pdf",Sub(options)options.HidePdfAnnotations=TrueEndSub)' Convert PDF to Markdown
converter.Convert("no-annotations.md")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmainargv=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Hide annotations using HidePdfAnnotations
letconverter=newPdfToMdConverter("with-annotations.pdf",funoptions->options.HidePdfAnnotations<-true)// Convert PDF to Markdown
converter.Convert("no-annotations.md")0//returnanintegerexitcode
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.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Create the convertervarconverter=newPdfToMdConverter("business-plan.pdf");// Convert to Markdown without embedding images as base64converter.Convert("without-images.md",convertOptions=>{convertOptions.MarkdownOptions.ExportImagesAsBase64=false;});
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Create the converter
DimconverterAsNewPdfToMdConverter("business-plan.pdf")' Convert to Markdown without embedding images as base64
converter.Convert("without-images.md",Sub(convertOptions)convertOptions.MarkdownOptions.ExportImagesAsBase64=FalseEndSub)EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Create the converter
letconverter=newPdfToMdConverter("business-plan.pdf")// Convert to Markdown without embedding images as base64
converter.Convert("without-images.md",funconvertOptions->convertOptions.MarkdownOptions.ExportImagesAsBase64<-false)0