Convert to and from DocLang

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

About DocLang

DocLang is an XML description of a document made for language models. It records what each element of a document is (a heading, a paragraph, a table, a picture), where it sits on its page and how its pieces connect. Learn more about the format in the DocLang project.

GroupDocs.Conversion supports two DocLang file types, both as a source and as a target, since version 26.11:

FormatDescription
DCLGBare DocLang markup: an XML document whose root is doclang. It holds no picture payload.
DCLXA DocLang archive: an Open Packaging Conventions package that holds the DocLang markup, the pictures of the document and, optionally, a picture of every page.

Supported DocLang conversions

  • To DocLang: every document that converts to a Word format converts to DCLG and DCLX — PDF, Word-processing, spreadsheet, presentation, email and Outlook, web, eBook, image, CAD, diagram, note, page description language, project management, Publisher, GIS, XML and JSON documents, and the documents inside archives.
  • From DocLang: a DocLang document converts to every format a DOCX document converts to — PDF, Word-processing, web, image, spreadsheet, presentation, eBook, page description language (XPS, PS, PCL) and SVG. DocLang to DocLang is not supported.

Convert to DocLang

Pass DocLangConvertOptions to the Convert method. By default the output is a DCLX archive that records where each element is on its page:

using (Converter converter = new Converter("sample.pdf"))
{
    DocLangConvertOptions options = new DocLangConvertOptions();
    converter.Convert("converted.dclx", options);
}

To get bare markup, set the format to DCLG:

using (Converter converter = new Converter("sample.docx"))
{
    DocLangConvertOptions options = new DocLangConvertOptions
    {
        Format = DocLangFileType.Dclg
    };
    converter.Convert("converted.dclg", options);
}

DocLang convert options

OptionDescription
FormatDocLangFileType.Dclx (default) or DocLangFileType.Dclg.
IncludeLocationsWrite where each element is on its page. Default is true.
IncludePageImagesAdd a picture of every page to a DCLX archive. Default is false.
PageNumber, PagesCountConvert a range of consecutive pages.
PagesConvert the listed pages only.

The following example converts the first three pages of a presentation to a DCLX archive with a picture of each page:

using (Converter converter = new Converter("sample.pptx"))
{
    DocLangConvertOptions options = new DocLangConvertOptions
    {
        IncludePageImages = true,
        PageNumber = 1,
        PagesCount = 3
    };
    converter.Convert("converted.dclx", options);
}
Warning
Bare DocLang markup cannot hold page pictures. Setting IncludePageImages to true together with Format = DocLangFileType.Dclg fails the conversion with InvalidConvertOptionsException: “DocLangConvertOptions.IncludePageImages cannot be combined with the dclg format: bare DocLang markup cannot hold page pictures. Use the dclx format for page pictures.”

Convert from DocLang

Load a DCLG or DCLX document like any other source and choose the target format:

using (Converter converter = new Converter("sample.dclx"))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

A DocLang document is read into a Word document first, so the page count that GetDocumentInfo reports is the page count of that Word document. To load a stream that has no file name, or to state the format, use DocLangLoadOptions.

Note
Refer to the API reference for all DocLang convert options.