PDF SDK Documentation

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

Loading...
Searching...
No Matches
xml_extractor.h
Go to the documentation of this file.
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_XML_EXTRACTOR_H_INCLUDED_
4#define PDFSDK_XML_EXTRACTOR_H_INCLUDED_
5
34
35#include <pdfsdk/core.h>
36#include <pdfsdk/text_edit.h>
37
38#ifdef PDF_XMLEXTRACTOR_EXPORTS
39#define PDF_XMLEXTRACTOR_API PDFSDK_EXPORT_
40#else
41#define PDF_XMLEXTRACTOR_API PDFSDK_IMPORT_
42#endif
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* Receives the serialized UTF-8 XML in a single call. `xml` points to `numBytes` bytes (not
49 null-terminated); `clientData` is the opaque pointer passed to the serialize function. Returning a
50 non-success code aborts serialization and is propagated to the caller. */
51typedef PDErrCode(PDFSDK_CALLCONV* PDTXmlWriteProc)(const char* xml, size_t numBytes, void* clientData);
52
53/* Serializes the text block content (paragraphs, spans, font and paragraph attributes) to UTF-8 XML
54 and passes it to `proc` in a single call (no buffer pre-sizing, the XML is built once). */
55PDF_XMLEXTRACTOR_API PDErrCode PDFSDK_CALLCONV PDTTextBlockSerializeToXML(PDTLayout layout,
56 PDTTextBlock block,
57 PDTXmlWriteProc proc,
58 void* clientData);
59
60/* Replaces the text block content from UTF-8 XML produced by PDTTextBlockSerializeToXML, applying the
61 line-fit algorithm (shrinking font size and line spacing) so that the new text fits the original
62 line count recorded per paragraph in the XML. */
63PDF_XMLEXTRACTOR_API PDErrCode PDFSDK_CALLCONV PDTTextBlockDeserializeFromXML(PDDoc doc,
64 PDTLayout layout,
65 PDTTextBlock block,
66 const char* pXml,
67 size_t numBytes);
68
69/* Serializes every text block on the layout (page) to a single UTF-8 XML document and passes it to
70 `proc` in a single call: a <page> root carrying the XFA namespace/APIVersion once, with one <block>
71 child per text block. The XML is built once (no buffer pre-sizing). */
72PDF_XMLEXTRACTOR_API PDErrCode PDFSDK_CALLCONV PDTLayoutSerializeToXML(PDTLayout layout,
73 PDTXmlWriteProc proc,
74 void* clientData);
75
76/* Applies a page UTF-8 XML produced by PDTLayoutSerializeToXML back to the layout's text blocks: the
77 i-th <block> updates the i-th text block, processing min(blocks-in-xml, layout text block count). */
78PDF_XMLEXTRACTOR_API PDErrCode PDFSDK_CALLCONV PDTLayoutDeserializeFromXML(PDDoc doc,
79 PDTLayout layout,
80 const char* pXml,
81 size_t numBytes);
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif // PDFSDK_XML_EXTRACTOR_H_INCLUDED_
int32_t PDErrCode
Definition errors.h:44
Text Edit API.