HTML import and export methods

You can find more information about HTML support here.

Version :
12.03.2024, 15:56 Uhr

HTML import and export methods

You can find more information about HTML support here.

static int export_frame(ItemRef frameRef, ...)

Export the content of a text frame as HTML. Style information is put into a separate .css file into a subfolder in the target folder.
More information can be found here. The parameters of the function are alternating key/value pairs. The keys are always of type String/char*. The following table describes the required and possible parameters:
Parameter String Data type Default value Description
Required parameters
Either:
"kOutputFolder" "String or char*" - Target folder
"kOutputName" String or char* - Name of the output file (without extension)
Or:
"kOutputBuffer" String or char* - When this parameter is set, the output is written into the provided string and not into a file. The parameters kOutputFolder and kOutputName are not needed and will be ignored.
Other parameters:
"kStartPosition" int 0 Start index in the text model
"kLength" int -1 Length in the text model (-1 = until the end)
"kDocTitle" String or char* [Filename] Title of the HTML document
"kCopyImages" int 0 Link or copy images? (0 = link, 1 = copy)
"kExportUnsupported" int 0 Export in HTML unsupported images as .png?
"kExportMissing" int 0 Export missing images from previews as .png?
"kWriteCSS" int 1 Write CSS?
"kInputCSS" String or char* - Alternative CSS. When this parameter is set, the input is used as CSS instead of the generated one. The input can be a path to a CSS file or a CSS definition.
"kCSSEscapeMode" int 0 Which escape style should be used for unsupported characters in style names?
0 = Hex Mode
1 = Slash Mode
See here.
"kBodyOnly" int 0 since v4.1 R22423 Export complete HMLT incl. <html><body> tags or only the <body> contents?
0 = Complete HTML
1 = Only contents of <body>
"kEscapeBrackets" int 0 since v4.1 R22423 Create XML conform output?
0 = No
1 = Yes, the following replacements are done:
  • < to &lt;
  • > to &gt;
  • & to &amp;
"kHexColors" int 0 Export CSS color values in hexadecimal format?
0 = Numeric
1 = Hexadecimal

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Frame
... ... - Other parameters depend on the task.
See table above.
Please note that some parameters are required.
int main()
{
    String 		folder 		= string::alloc();
    String 		docName 	= string::alloc("HTML Export");
    int 		err = 0;
err = file::select_folder(folder); if (err) { return 0; }
document::name(docName);
html::export_frame( gFrame,   "kOutputFolder", folder,   "kOutputName", docName,   "kDocTitle", "Hello World",   "kCSSEscapeMode", 0);
return 0; }

Version 4.1 R21800

priint:comet InDesign® Plug-Ins, comet_pdf

comet.html.exportText

static String tidy(String input)

Cleans an HTML input string and tries to output valid XHTML.

Use this function at your own risk. WERK II will not provide support for any conversion errors. Please contact HTML-Tidy directly in this case.

Name Type Default Description
Return String   Cleaned HTML String.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o values.

input String or char* - HTML input string

Version 4.1 R20505

priint:comet InDesign® Plug-Ins, comet_pdf

static String to_tagged(String input, ...)

Converts an HTML input String to InDesign® TaggedText. Input must be valid XHTML. See here for a description of supported HTML attributes. The parameters of the function are alternating key/value pairs. The keys are always of type String/char*. The following table describes the required and possible parameters:
Parameter String Data type Default value Description
"kCSSUnescapeMode" int -1 How should the escaping of unsupported characters in style names from the export be reverted?
-1 = Anything
0 = Hex Mode
1 = Slash Mode
See here.
"kPrefix" String or char* "%!TT" Prefix to prepend to the result.
See here.

Name Type Default Description
Return String   TaggedText String.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o values.

input String or char* - HTML input string
... ... - The other function parameters depend on the task. Use key/value pairs according to the table above.
#include "internal/types.h"
#include "internal/text.h"
int main() { String input = string::alloc(); String tagged = 0;
input = "<strong>Montage à <i>base de 3</i> roulements,</strong> <i>italic</i><strong><i>bolditalic</i></strong>"; tagged = html::to_tagged(input, "kPrefix", "%!TT");
textmodel::replace(tagged, 0, kEnd, 1, 4);
string::release(input); // Do NOT release tagged, as a result html::to_tagged this is a static!<br/> return 0; }

Version 4.1 R20505

priint:comet InDesign® Plug-Ins, comet_pdf

comet.html.toTagged

static String raw_text(String input)

Converts an HTML input String to raw text which contains not formatting options. All HTML entities and tags are removed. Input must be valid HTML.

Name Type Default Description
Return String   Raw text content of the HTML input String.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o values.

input String or char* - HTML input string
#include "internal/types.h"
#include "internal/text.h"
int main() { String input = string::alloc(); String tagged = string::alloc();
input = "<strong>Montage à <i>base de 3</i> roulements,</strong> <i>italic</i><strong><i>bolditalic</i></strong>"; tagged = html::to_tagged(input, "kPrefix", "%!TT");
textmodel::replace(string::get(tagged), 0, kEnd, 1, 4);
string::release(input); string::release(tagged);
return 0; }

Version 4.16 R20505

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

comet.html.getRawText

Author
Leo Quensel
Version
12.03.2024, 15:56 Uhr
Since
Plugin Version 4.1

Alphabetic index HTML hierarchy of classes or Java