{
    "content": [
        {
            "type": "text",
            "text": "# PDF::API2::Content (perldoc)\n\n## NAME\n\nPDF::API2::Content - Methods for adding graphics and text to a PDF\n\n## SYNOPSIS\n\n# Start with a PDF page (new or opened)\nmy $pdf = PDF::API2->new();\nmy $page = $pdf->page();\n# Add a new content object\nmy $content = $page->graphics();\nmy $content = $page->text();\n# Then call the methods below add graphics and text to the page.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **COORDINATE TRANSFORMATIONS**\n- **GRAPHICS STATE**\n- **EXTERNAL OBJECTS**\n- **TEXT STATE**\n- **TEXT PLACEMENT**\n- **MIGRATION** (5 subsections)\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "PDF::API2::Content",
        "section": "",
        "mode": "perldoc",
        "summary": "PDF::API2::Content - Methods for adding graphics and text to a PDF",
        "synopsis": "# Start with a PDF page (new or opened)\nmy $pdf = PDF::API2->new();\nmy $page = $pdf->page();\n# Add a new content object\nmy $content = $page->graphics();\nmy $content = $page->text();\n# Then call the methods below add graphics and text to the page.",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COORDINATE TRANSFORMATIONS",
                "lines": 59,
                "subsections": []
            },
            {
                "name": "GRAPHICS STATE",
                "lines": 252,
                "subsections": []
            },
            {
                "name": "EXTERNAL OBJECTS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "TEXT STATE",
                "lines": 76,
                "subsections": []
            },
            {
                "name": "TEXT PLACEMENT",
                "lines": 107,
                "subsections": []
            },
            {
                "name": "MIGRATION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "transform",
                        "lines": 45
                    },
                    {
                        "name": "fill",
                        "lines": 5
                    },
                    {
                        "name": "clip",
                        "lines": 26
                    },
                    {
                        "name": "text",
                        "lines": 8
                    },
                    {
                        "name": "paragraph",
                        "lines": 9
                    }
                ]
            }
        ],
        "sections": {
            "NAME": {
                "content": "PDF::API2::Content - Methods for adding graphics and text to a PDF\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "# Start with a PDF page (new or opened)\nmy $pdf = PDF::API2->new();\nmy $page = $pdf->page();\n\n# Add a new content object\nmy $content = $page->graphics();\nmy $content = $page->text();\n\n# Then call the methods below add graphics and text to the page.\n",
                "subsections": []
            },
            "COORDINATE TRANSFORMATIONS": {
                "content": "The methods in this section change the coordinate system for the current content object relative\nto the rest of the document.\n\nChanges to the coordinate system only affect subsequent paths or text.\n\nA call to any of the methods in this section resets the coordinate system before applying its\nchanges, unless the \"relative\" option is set.\n\ntranslate\n$content = $content->translate($x, $y);\n\nMoves the origin along the x and y axes.\n\nrotate\n$content = $content->rotate($degrees);\n\nRotates the coordinate system counter-clockwise.\n\nUse a negative argument to rotate clockwise.\n\nscale\n$content = $content->scale($x, $y);\n\nScales (stretches) the coordinate systems along the x and y axes. A value of 1 for either $x or\n$y represents 100% scale (i.e. no change).\n\nskew\n$content = $content->skew($a, $b);\n\nSkews the coordinate system by $a degrees (counter-clockwise) from the x axis and $b degrees\n(clockwise) from the y axis.\n\ntransform\n$content = $content->transform(\ntranslate => [$x, $y],\nrotate    => $degrees,\nscale     => [$x, $y],\nskew      => [$a, $b],\nrelative  => $boolean,\n);\n\nPerforms multiple coordinate transformations, in the order recommended by the PDF specification\n(translate, rotate, scale, then skew). Omitted options will be unchanged.\n\nIf \"relative\" is true, the specified transformations will be added to any previous changes to\nthe coordinate system. By default, calling \"transform\" or any of the other transformation\nmethods will overwrite any previous changes to the coordinate system.\n\nmatrix\n$graphics = $graphics->matrix($a, $b, $c, $d, $e, $f);\n\n($a, $b, $c, $d, $e, $f) = $text->matrix($a, $b, $c, $d, $e, $f);\n\nSets the current transformation matrix manually. Unless you have a particular need to enter\ntransformations manually, you should use the \"transform\" method instead.\n\nThe return value differs based on whether the caller is a graphics content object or a text\ncontent object.\n",
                "subsections": []
            },
            "GRAPHICS STATE": {
                "content": "save\n$content = $content->save();\n\nSaves the current graphics state on a stack.\n\nrestore\n$content = $content->restore();\n\nRestores the most recently saved graphics state, removing it from the stack.\n\nlinewidth\n$content = $content->linewidth($points);\n\nSets the width of the stroke in points.\n\nlinecap\n$content = $content->linecap($style);\n\nSets the shape that will be used at the ends of open subpaths (and dashes, if any) when they are\nstroked.\n\n*   \"butt\" or 0 = Butt Cap, default\n\nThe stroke ends at the end of the path, with no projection.\n\n*   \"round\" or 1 = Round Cap)\n\nAn arc is drawn around the end of the path with a diameter equal to the line width, and is\nfilled in.\n\n*   \"square\" or 2 = Projecting Square Cap\n\nThe stroke continues past the end of the path for half the line width.\n\nlinejoin\n$content = $content->linejoin($style);\n\nSets the style of join to be used at corners of a path.\n\n*   \"miter\" or 0 = Miter Join, default\n\nThe outer edges of the stroke extend until they meet, up to the limit specified below. If\nthe limit would be surpassed, a bevel join is used instead.\n\n*   \"round\" or 1 = Round Join\n\nA circle with a diameter equal to the linewidth is drawn around the corner point, producing\na rounded corner.\n\n*   \"bevel\" or 2 = Bevel Join\n\nA triangle is drawn to fill in the notch between the two strokes.\n\nmiterlimit\n$content = $content->miterlimit($ratio);\n\nSets the miter limit when the line join style is a miter join.\n\nThe $ratio is the maximum length of the miter (inner to outer corner) divided by the line width.\nAny miter above this ratio will be converted to a bevel join. The practical effect is that lines\nmeeting at shallow angles are chopped off instead of producing long pointed corners.\n\nThere is no documented default miter limit.\n\nlinedashpattern\n# Solid line\n$content = $content->linedashpattern();\n\n# Equal length lines and gaps\n$content = $content->linedashpattern($length);\n\n# Specified line and gap lengths\n$content = $content->linedashpattern($line1, $gap1, $line2, $gap2, ...);\n\n# Offset the starting point\n$content = $content->linedashpattern(\npattern => [$line1, $gap1, $line2, $gap2, ...],\noffset => $points,\n);\n\nSets the line dash pattern.\n\nIf called without any arguments, a solid line will be drawn.\n\nIf called with one argument, the dashes and gaps will have equal lengths.\n\nIf called with two or more arguments, the arguments represent alternating dash and gap lengths.\n\nIf called with a hash of arguments, a dash phase may be set, which specifies the distance into\nthe pattern at which to start the dash.\n\nflatnesstolerance\n$content = $content->flatnesstolerance($tolerance);\n\nSets the maximum distance in device pixels between the mathematically correct path for a curve\nand an approximation constructed from straight line segments.\n\n$tolerance is an integer between 0 and 100, where 0 represents the device's default flatness\ntolerance.\n\negstate\n$content = $content->egstate($object);\n\nAdds a PDF::API2::Resource::ExtGState object containing a set of graphics state parameters.\n\nPATH CONSTRUCTION (DRAWING)\nNote that paths will not appear until a path painting method is called (\"stroke\", \"fill\", or\n\"paint\").\n\nmove\n$content = $content->move($x, $y);\n\nStarts a new path at the specified coordinates.\n\nline\n$content = $content->line($x, $y);\n\nExtends the path in a line from the current coordinates to the specified coordinates.\n\nhline\n$content = $content->hline($x);\n\nExtends the path in a horizontal line from the current position to the specified x coordinate.\n\nvline\n$content = $content->vline($x);\n\nExtends the path in a vertical line from the current position to the specified y coordinate.\n\npolyline\n$content = $content->polyline($x1, $y1, $x2, $y2, ...);\n\nExtends the path from the current position in one or more straight lines.\n\ncurve\n$content = $content->curve($cx1, $cy1, $cx2, $cy2, $x, $y);\n\nExtends the path in a curve from the current point to \"($x, $y)\", using the two specified points\nto create a cubic Bezier curve.\n\nspline\n$content = $content->spline($cx1, $cy1, $x, $y);\n\nExtends the path in a curve from the current point to \"($x, $y)\", using the two specified points\nto create a spline.\n\narc\n$content = $content->arc($x, $y, $major, $minor, $a, $b);\n\nExtends the path along an arc of an ellipse centered at \"[$x, $y]\". $major and $minor represent\nthe axes of the ellipse, and the arc moves from $a degrees to $b degrees.\n\nclose\n$content = $content->close();\n\nCloses the current path by extending a line from the current position to the starting position.\n\nend\n$content = $content->end();\n\nEnds the current path without filling or stroking.\n\nSHAPE CONSTRUCTION (DRAWING)\nThe following are convenience methods for drawing closed paths.\n\nNote that shapes will not appear until a path painting method is called (\"stroke\", \"fill\", or\n\"paint\").\n\nrectangle\n$content = $content->rectangle($x1, $y1, $x2, $y2);\n\nCreates a new rectangle-shaped path, between the two points \"[$x1, $y1]\" and \"[$x2, $y2]\".\n\ncircle\n$content = $content->circle($x, $y, $radius);\n\nCreates a new circular path centered on \"[$x, $y]\" with the specified radius.\n\nellipse\n$content = $content->ellipse($x, $y, $major, $minor);\n\nCreates a new elliptical path centered on \"[$x, $y]\" with the specified major and minor axes.\n\npie\n$content = $content->pie($x, $y, $major, $minor, $a, $b);\n\nCreates a new wedge-shaped path from an ellipse centered on \"[$x, $y]\" with the specified major\nand minor axes, extending from $a degrees to $b degrees.\n\nPATH PAINTING (DRAWING)\nstrokecolor\n$content = $content->strokecolor($color, @arguments);\n\nSets the stroke color, which is black by default.\n\n# Use a named color\n$content->strokecolor('blue');\n\n# Use an RGB color (start with '#')\n$content->strokecolor('#FF0000');\n\n# Use a CMYK color (start with '%')\n$content->strokecolor('%FF000000');\n\n# Use a spot color with 100% coverage.\nmy $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340');\n$content->strokecolor($spot, 1.0);\n\nRGB and CMYK colors can have one-byte, two-byte, three-byte, or four-byte values for each color,\ndepending on the level of precision needed. For instance, cyan can be given as %F000 or\n%FFFF000000000000.\n\nfillcolor\n$content = $content->fillcolor($color, @arguments);\n\nSets the fill color, which is black by default. Arguments are the same as in \"strokecolor\".\n\nstroke\n$content = $content->stroke();\n\nStrokes the current path.\n\nfill\n$content = $content->fill(rule => $rule);\n\nFills the current path.\n\n$rule describes which areas are filled in when the path intersects with itself.\n\n*   nonzero (default)\n\nUse the nonzero winding number rule. This tends to mean that the entire area enclosed by the\npath is filled in, with some exceptions depending on the direction of the path.\n\n*   even-odd\n\nUse the even-odd rule. This tends to mean that the presence of fill alternates each time the\npath is intersected.\n\nSee PDF specification 1.7 section 8.5.3.3, Filling, for more details.\n\npaint\n$content = $content->paint(rule => $rule);\n\nFills and strokes the current path. $rule is as described in \"fill\".\n\nclip\n$content = $content->clip(rule => $rule);\n\nModifies the current clipping path (initially the entire page) by intersecting it with the\ncurrent path following the next path-painting command. $rule is as described in \"fill\".\n",
                "subsections": []
            },
            "EXTERNAL OBJECTS": {
                "content": "object\n$content = $content->object($object, $x, $y, $scalex, $scaley);\n\nPlaces an image or other external object (a.k.a. XObject) on the page in the specified location.\n\nFor images, $scalex and $scaley represent the width and height of the image on the page in\npoints. If $scalex is omitted, it will default to 72 pixels per inch. If $scaley is omitted,\nthe image will be scaled proportionally based on the image dimensions.\n\nFor other external objects, the scale is a multiplier, where 1 (the default) represents 100%\n(i.e. no change).\n\nIf coordinate transformations have been made (see Coordinate Transformations above), the\nposition and scale will be relative to the updated coordinates.\n\nIf no coordinate transformations are needed, this method can be called directly from the\nPDF::API2::Page object instead.\n",
                "subsections": []
            },
            "TEXT STATE": {
                "content": "All of the following parameters that take a size are applied before any scaling takes place, so\nyou don't need to adjust values to counteract scaling.\n\nfont\n$content = $content->font($font, $size);\n\nSets the font and font size. $font is an object created by calling \"font\" in PDF::API2 to add\nthe font to the document.\n\nmy $pdf = PDF::API2->new();\nmy $page = $pdf->page();\nmy $text = $pdf->text();\n\nmy $font = $pdf->font('Helvetica');\n$text->font($font, 24);\n$text->position(72, 720);\n$text->text('Hello, World!');\n\n$pdf->save('sample.pdf');\n\ncharacterspacing\n$spacing = $content->characterspacing($spacing);\n\nSets the spacing between characters. This is initially zero.\n\nwordspacing\n$spacing = $content->wordspacing($spacing);\n\nSets the spacing between words. This is initially zero (i.e. just the width of the space).\n\nWord spacing might only affect simple fonts and composite fonts where the space character is a\nsingle-byte code. This is a limitation of the PDF specification at least as of version 1.7 (see\nsection 9.3.3). It's possible that a later version of the specification will support word\nspacing in fonts that use multi-byte codes.\n\nhscale\n$scale = $content->hscale($scale);\n\nSets/gets the percentage of horizontal text scaling. Enter a scale greater than 100 to stretch\ntext, less than 100 to squeeze text, or 100 to disable any existing scaling.\n\nleading\n$leading = $content->leading($leading);\n\nSets/gets the text leading, which is the distance between baselines. This is initially zero\n(i.e. the lines will be printed on top of each other).\n\nrender\n$mode = $content->render($mode);\n\nSets the text rendering mode.\n\n*   0 = Fill text\n\n*   1 = Stroke text (outline)\n\n*   2 = Fill, then stroke text\n\n*   3 = Neither fill nor stroke text (invisible)\n\n*   4 = Fill text and add to path for clipping\n\n*   5 = Stroke text and add to path for clipping\n\n*   6 = Fill, then stroke text and add to path for clipping\n\n*   7 = Add text to path for clipping\n\nrise\n$distance = $content->rise($distance);\n\nAdjusts the baseline up or down from its current location. This is initially zero.\n\nUse this to create superscripts or subscripts (usually with an adjustment to the font size as\nwell).\n",
                "subsections": []
            },
            "TEXT PLACEMENT": {
                "content": "position\n# Set\n$content = $content->position($x, $y);\n\n# Get\n($x, $y) = $content->position();\n\nIf called with arguments, moves to the start of the current line of text, offset by $x and $y.\n\nIf called without arguments, returns the current position of the cursor (before the effects of\nany coordinate transformation methods).\n\ncrlf\n$content = $content->crlf();\n\nMoves to the start of the next line, based on the \"leading\" setting.\n\nIf leading isn't set, a default distance of 120% of the font size will be used.\n\ntext\nmy $width = $content->text($text, %options);\n\nPlaces text on the page. Returns the width of the text in points.\n\nOptions:\n\n*   align\n\nOne of \"left\" (default), \"center\", or \"right\". Text will be placed such that it begins, is\ncentered on, or ends at the current text position, respectively.\n\nIn each case, the position will then be moved to the end of the text.\n\n*   indent\n\nIndents the text by the number of points.\n\nIf \"align\" is set to anything other than \"left\", this setting will be ignored.\n\n*   underline\n\nUnderlines the text. The value may be one of the following:\n\n*   auto\n\nDetermines the underline distance from the text based on the font and font size.\n\n*   $distance\n\nManually set the underline distance in points. A positive distance moves the line\ndownward.\n\n*   [$distance, $thickness, ...]\n\nManually set both the underline distance and line thickness, both in points.\n\nRepeat these arguments to include multiple underlines.\n\ntextjustified\nmy $width = $content->textjustified($text, $width, %options);\n\nAs \"text\", filling the specified width by adjusting the space between words.\n\nparagraph\n# Scalar context\n$overflowtext = $content->paragraph($text, $width, $height, %options);\n\n# Array context\n($overflow, $height) = $content->paragraph($text, $width, $height, %options);\n\nFills the rectangle with as much of the provided text as will fit.\n\nIn array context, returns the remaining text (if any) of the positioned text and the remaining\n(unused) height. In scalar context, returns the remaining text (if any).\n\nLine spacing follows \"leading\", if set, or 120% of the font size by default.\n\nOptions\n\n*   align\n\nSpecifies the alignment for each line of text. May be set to \"left\" (default), \"center\",\n\"right\", or \"justified\".\n\n*   align-last\n\nSpecifies the alignment for the last line of justified text. May be set to \"left\" (default),\n\"center\", \"right\", or \"justified\".\n\n*   underline\n\nAs described in \"text\".\n\ntextwidth\nmy $width = $content->textwidth($line, %overrides);\n\nReturns the width of a line of text based on the current text state attributes. These can\noptionally be overridden:\n\nmy $width = $content->textwidth($line,\nfont => $font,\nsize => $size,\ncharacterspacing => $spacing,\nwordspacing => $spacing,\nhscale => $scale,\n);\n",
                "subsections": []
            },
            "MIGRATION": {
                "content": "See \"MIGRATION\" in PDF::API2 for an overview.\n",
                "subsections": [
                    {
                        "name": "transform",
                        "content": "Remove hyphens from option names (\"-translate\" becomes \"translate\", etc.).\n\ntransformrel\nReplace with \"transform\", setting option \"relative\" to true. Remove hyphens from the names\nof other options.\n\nlinewidth\nReplace with \"linewidth\".\n\nlinecap\nReplace with \"linecap\".\n\nlinejoin\nReplace with \"linejoin\".\n\nmeterlimit\nmiterlimit\nReplace with \"miterlimit\".\n\nlinedash\nReplace with \"linedashpattern\". Remove hyphens from option names. Rename \"-shift\" to\n\"offset\".\n\nflatness\nReplace with \"flatnesstolerance\".\n\npoly\nReplace with \"move\" (first two arguments) and \"polyline\" (remaining arguments).\n\nendpath\nReplace with \"end\".\n\nrect\nReplace with \"rectangle\", converting the $w (third) and $h (fourth) arguments to the X and Y\nvalues of the upper-right corner:\n\n# Old\n$content->rect($x, $y, $w, $h);\n\n# New\n$content->rectangle($x, $y, $x + $w, $y + $h);\n\nrectxy\nReplace with \"rectangle\".\n"
                    },
                    {
                        "name": "fill",
                        "content": "Replace with \"$content->fill(rule => 'even-odd')\".\n\nfillstroke\nReplace with \"paint\".\n"
                    },
                    {
                        "name": "clip",
                        "content": "Replace with \"$content->clip(rule => 'even-odd')\".\n\nimage\nformimage\nReplace with \"object\".\n\ncharspace\nReplace with \"characterspacing\".\n\nwordspace\nReplace with \"wordspacing\".\n\nhspace\nReplace with \"hscale\".\n\nlead\nReplace with \"leading\".\n\ndistance\nReplace with \"position\".\n\ncr  Replace with either \"position\" (if called with arguments) or \"crlf\" (if called without\narguments).\n\nnl  Replace with \"crlf\".\n"
                    },
                    {
                        "name": "text",
                        "content": "Remove initial hyphens from option names.\n\ntextcenter\nReplace with \"text\", setting \"align\" to \"center\".\n\ntextright\nReplace with \"text\", setting \"align\" to \"right\".\n"
                    },
                    {
                        "name": "paragraph",
                        "content": "Remove initial hyphens from option names. \"-align-last\" becomes \"align-last\".\n\nsection\nparagraphs\nReplace with \"paragraph\".\n\nadvancewidth\nReplace with \"textwidth\".\n"
                    }
                ]
            }
        }
    }
}