PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Table 10.17 Operations which are recommended for generating Tagged PDF<br />
item<br />
Recommended <strong>PDFlib</strong> functions and options for Tagged PDF compatibility<br />
Unicode mappings Provide alternate text for symbols via the ActualText or Alt options of begin_item( ).<br />
hyphenation<br />
word boundaries<br />
artifacts<br />
Type 3 font<br />
properties<br />
interactive elements<br />
Word breaks (separating words in two parts at the end of a line) should be presented using a soft<br />
hyphen character (U+00AD) as opposed to a hard hyphen (U+002D)<br />
Words should be separated by space characters (U+0020) even if this would not strictly be required<br />
for positioning. The autospace parameter can be used for automatically generating space<br />
characters after each call to one of the show functions.<br />
In order to distinguish real content from page artifacts, artifacts should be identified as such using<br />
begin_item( ) with tag=Artifact.<br />
The familyname, stretch, and weight options of begin_font( ) should be supplied with reasonable<br />
values for all Type 3 fonts used in a Tagged PDF document.<br />
Interactive elements, e.g. links, should be included in the document structure and made accessible<br />
if required, e.g. by supplying alternate text. The tab order for interactive elements can be<br />
specified with the taborder option of begin/end_document( ) (this is not necessary if the interactive<br />
elements are properly included in the document structure).<br />
10.5.2 Creating Tagged PDF with direct Text Output and Textflows<br />
Minimal Tagged PDF sample. The following sample code creates a very simplistic<br />
Tagged PDF document. Its structure tree contains only a single P element. The code uses<br />
the autospace feature to automatically generate space characters between fragments of<br />
text:<br />
if (p.begin_document("hello-tagged.pdf", "tagged=true") == -1)<br />
throw new Exception("Error: " + p.get_errmsg());<br />
/* automatically create spaces between chunks of text */<br />
p.set_parameter("autospace", "true");<br />
/* open the first structure element as a child of the document structure root (=0) */<br />
id = p.begin_item("P", "Title={Simple Paragraph}");<br />
p.begin_page_ext(0, 0, "width=a4.width height=a4.height");<br />
font = p.load_font("Helvetica-Bold", "unicode", "");<br />
p.setfont(font, 24);<br />
p.show_xy("Hello, Tagged PDF!", 50, 700);<br />
p.continue_text("This PDF has a very simple");<br />
p.continue_text("document structure.");<br />
p.end_page_ext("");<br />
p.end_item(id);<br />
p.end_document("");<br />
Generating Tagged PDF with Textflow. The Textflow feature (see Section 8.2, »Multi-<br />
Line Textflows«, page 207) offers powerful features for text formatting. Since individual<br />
text fragments are no longer under client control, but will be formatted automatically<br />
by <strong>PDFlib</strong>, special care must be taken when generating Tagged PDF with textflows:<br />
> Textflows can not contain individual structure elements, but the complete contents<br />
of a single Textflow fitbox can be contained in a structure element.<br />
270 Chapter 10: PDF Versions and Standards (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)