set_option("searchpath={" . $searchpath . "}"); /* all strings are expected as utf8*/ $p->set_option("stringformat=utf8"); /* This means we must check return values of load_font() etc. */ $p->set_option("errorpolicy=return"); if ($p->begin_document($outfile, "pdfua=PDF/UA-1 tag={tagname=Document} lang=en") == 0) throw new Exception("Error: " . $p->get_errmsg()); $p->set_info("Creator", "PDFlib Cookbook"); $p->set_info("Title", $title . ' $Revision: 1.2 $'); $font = $p->load_font("DejaVuSerif", "unicode", "embedding"); if ($font == 0) throw new Exception("Error: " . $p->get_errmsg()); $p->create_bookmark($title, ""); /* Automatically create spaces between chunks of text */ $p->set_option("autospace=true"); $p->begin_page_ext(0, 0, "width=a4.width height=a4.height"); $id_sect1 = $p->begin_item("Sect", "Title={Left column}"); $p->setfont($font, 12); /* Start with a H1 for the left column */ $p->fit_textline("Start of left column...", $x_left, $y1, "tag={tagname=H1} fontsize=18"); /* * Since we keep the first P open we must explicitly designate the * root element as parent for the right column. */ $id_sect2 = $p->begin_item("Sect", "parent=0 Title={Right column}"); $p->fit_textline("Start of right column...", $x_right, $y1, "tag={tagname=H1} fontsize=18"); /* Return to the left column and add another structure element */ $p->activate_item($id_sect1); $p->fit_textline("continued", $x_left, $y2, "tag={tagname=P}"); $p->end_item($id_sect1); /* Now return to the right column again and add an element */ $p->activate_item($id_sect2); $p->fit_textline("also continued", $x_right, $y2, "tag={tagname=P}"); $p->end_item($id_sect2); $p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=tag_parallel_columns.pdf"); print $buf; } catch (PDFlibException $e) { echo("PDFlib exception occurred in tag_parallel_columns sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); exit(1); } catch (Exception $e) { echo($e); exit(1); } $p = 0; ?>