PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
xml_extractor.h File Reference

XML Extractor API. More...

#include <pdfsdk/core.h>
#include <pdfsdk/text_edit.h>

Go to the source code of this file.

Macros

#define PDF_XMLEXTRACTOR_API   PDFSDK_IMPORT_

Typedefs

typedef PDErrCode(PDFSDK_CALLCONV * PDTXmlWriteProc) (const char *xml, size_t numBytes, void *clientData)

Functions

PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDTTextBlockSerializeToXML (PDTLayout layout, PDTTextBlock block, PDTXmlWriteProc proc, void *clientData)
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDTTextBlockDeserializeFromXML (PDDoc doc, PDTLayout layout, PDTTextBlock block, const char *pXml, size_t numBytes)
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDTLayoutSerializeToXML (PDTLayout layout, PDTXmlWriteProc proc, void *clientData)
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDTLayoutDeserializeFromXML (PDDoc doc, PDTLayout layout, const char *pXml, size_t numBytes)

Detailed Description

XML Extractor API.

Serializes a text block (paragraphs, spans, font and paragraph attributes) to a self-contained XML representation and applies such XML back to a text block, fitting the new text to the block by shrinking font size and line spacing when required.

Text lives in <tbspan> elements (one per span); all styling is a styles JSON attribute on the

(a para object plus a spans map of attribute->span-indices), so styles reattach by index.

Single text block – a <body> root:

<body xmlns="..." xmlns:xfa="..." xfa:APIVersion="2.7.8021.0">
<p styles='{"para":{"text-align":"left"},"spans":{"bold":[1],"font-family":{"Helvetica":[[0,2]]}}}'>
<tbspan>she </tbspan><tbspan>will </tbspan><tbspan>come tomorrow</tbspan>
</p>
</body>

Whole page – a <page> root with one <block> per text block:

<page xmlns="..." xmlns:xfa="..." xfa:APIVersion="2.7.8021.0">
<block><p styles='{...}'><tbspan>she will come tomorrow</tbspan></p></block>
<block><p styles='{...}'><tbspan>second block...</tbspan></p></block>
</page>