Tag
Description
This class assists in the detection or construction of tagged and marked content in page or xobject form content streams:
Example
use lib 't';
use PDFTiny;
use PDF::Content::XObject;
use PDF::Content::Tag :ParagraphTags, :IllustrationTags;
my PDFTiny $pdf .= new;
my $page = $pdf.add-page;
my $header-font = $pdf.core-font: :family<Helvetica>, :weight<bold>;
my $body-font = $pdf.core-font: :family<Helvetica>;
$page.graphics: -> $gfx {
my PDF::Content::Tag $tag;
$tag = $gfx.mark: Header1, {
.say('Header text',
:font($header-font),
:font-size(15),
:position[50, 120]);
}
say $tag.name.Str; # 'H1'
say $tag.mcid; # marked content id of 0
$tag = $gfx.mark: Paragraph, {
.say('Paragraph that contains a figure', :position[50, 100], :font($body-font), :font-size(12));
# nested tag. Note: marks cannot be nested, but tags can
.tag: Figure, {
my PDF::Content::XObject $img .= open: "t/images/lightbulb.gif";
.do: $img, :position[50,70];
}
}
say $tag.name.Str; # 'P'
say $tag.mcid; # marked content id of 1
say $tag.kids[0].name.Str; # 'Figure'
}
say $page.gfx.tags.gist; # '<H1 MCID="0"/><P MCID="1"><Figure/></P>';