The <path> element is the most powerful and flexible SVG shape element, capable of drawing any arbitrary shape using a series of commands in SVG content within your PDF documents. It supports straight lines, curves, arcs, and complex combinations, making it essential for icons, custom shapes, logos, and advanced graphics.
Usage
The <path> element creates complex shapes defined by:
Path data (d) - a string of commands and coordinates defining the shape
Fill and stroke styling attributes
Transform operations for rotation and positioning
Support for both open and closed paths
<svgxmlns="http://www.w3.org/2000/svg"width="100"height="100"><pathd="M 10,30 A 20,20 0 0,1 50,30 A 20,20 0 0,1 90,30"fill="none"stroke="#2196F3"stroke-width="2"/></svg>
Supported Attributes
Geometry Attributes
Attribute
Type
Description
d
String
Path data string containing drawing commands. Required. See Path Commands section below.
Styling Attributes
Attribute
Type
Description
fill
Color/URL
Fill color or reference to gradient/pattern. Default: black
fill-opacity
Number
Opacity of the fill (0.0 to 1.0). Default: 1.0
fill-rule
String
Fill rule for complex paths: nonzero or evenodd. Default: nonzero
stroke
Color
Stroke (border) color. Default: none
stroke-width
Unit
Width of the stroke line. Default: 1pt
stroke-opacity
Number
Opacity of the stroke (0.0 to 1.0). Default: 1.0
stroke-linecap
String
Line cap style: butt, round, square. Default: square
stroke-linejoin
String
Line join style: miter, round, bevel. Default: bevel
stroke-dasharray
String
Dash pattern (e.g., 5,3)
Marker Attributes
Attribute
Type
Description
marker-start
URL
Reference to marker for path start (e.g., url(#arrow))
Paths can be arbitrarily complex, combining multiple command types. This makes them the most versatile but also most complex SVG shape element.
Coordinate Systems
Uppercase commands use absolute coordinates relative to the SVG origin
Lowercase commands use relative coordinates from the current position
Mix both types in a single path for flexible drawing
Performance
While paths are powerful, simpler shapes (rect, circle, etc.) are more efficient when possible. Use paths for shapes that cannot be created with simpler elements.
Path Parsing
The path data string is parsed into drawing operations. Invalid syntax will result in no output or partial rendering.
Closing Paths
Use Z or z to close a path (connects last point to first)
Closing affects fill behavior and stroke joins at the closure point
Open paths can still have fill (closes implicitly for fill only)
Examples
Basic Line Path
<svgwidth="100"height="100"><pathd="M 10,10 L 90,90"stroke="#333"stroke-width="2"/></svg>
Triangle (Closed Path)
<svgwidth="100"height="100"><pathd="M 50,10 L 90,80 L 10,80 Z"fill="#4CAF50"stroke="#2E7D32"stroke-width="2"/></svg>
<svgwidth="200"height="100"><pathd="M 10,50 C 40,10 160,90 190,50"fill="none"stroke="#9C27B0"stroke-width="3"/></svg>
S-Curve
<svgwidth="200"height="150"><pathd="M 20,75 C 40,20 60,20 80,75 S 120,130 140,75 S 180,20 200,75"fill="none"stroke="#FF9800"stroke-width="3"/></svg>
Heart Shape
<svgwidth="100"height="100"><pathd="M 50,80 C 50,70 45,60 35,60 C 25,60 20,65 20,75 C 20,90 50,100 50,100 C 50,100 80,90 80,75 C 80,65 75,60 65,60 C 55,60 50,70 50,80 Z"fill="#f44336"stroke="#c62828"stroke-width="2"/></svg>
<svgwidth="200"height="100"><pathd="M 50,50 C 30,20 0,30 0,50 C 0,70 30,80 50,50 C 70,20 130,20 150,50 C 170,80 200,70 200,50 C 200,30 170,20 150,50"fill="none"stroke="#673AB7"stroke-width="4"/></svg>
Arrow with Curve
<svgwidth="150"height="100"><pathd="M 10,50 Q 75,10 140,50 L 130,55 L 140,50 L 130,45"fill="none"stroke="#4CAF50"stroke-width="3"stroke-linejoin="round"/></svg>
Star Using Path
<svgwidth="100"height="100"><pathd="M 50,10 L 61,40 L 93,40 L 68,58 L 79,88 L 50,68 L 21,88 L 32,58 L 7,40 L 39,40 Z"fill="#FFC107"stroke="#F57F17"stroke-width="2"/></svg>
Wave Pattern
<svgwidth="300"height="100"><pathd="M 0,50 Q 25,20 50,50 T 100,50 T 150,50 T 200,50 T 250,50 T 300,50"fill="none"stroke="#00BCD4"stroke-width="3"/></svg>
Speech Bubble
<svgwidth="150"height="100"><pathd="M 20,20 L 130,20 Q 140,20 140,30 L 140,70 Q 140,80 130,80 L 50,80 L 30,95 L 35,80 L 20,80 Q 10,80 10,70 L 10,30 Q 10,20 20,20 Z"fill="#fff"stroke="#333"stroke-width="2"/></svg>
Checkmark
<svgwidth="100"height="100"><pathd="M 20,50 L 40,70 L 80,25"fill="none"stroke="#4CAF50"stroke-width="6"stroke-linecap="round"stroke-linejoin="round"/></svg>
Cross (X)
<svgwidth="100"height="100"><pathd="M 20,20 L 80,80 M 80,20 L 20,80"fill="none"stroke="#f44336"stroke-width="6"stroke-linecap="round"/></svg>
Gear Icon
<svgwidth="100"height="100"><pathd="M 50,10 L 55,25 L 70,20 L 75,35 L 90,35 L 85,50 L 90,65 L 75,65 L 70,80 L 55,75 L 50,90 L 45,75 L 30,80 L 25,65 L 10,65 L 15,50 L 10,35 L 25,35 L 30,20 L 45,25 Z"fill="#607D8B"stroke="#455A64"stroke-width="2"/><circlecx="50"cy="50"r="15"fill="#fff"/></svg>
Music Note
<svgwidth="60"height="100"><pathd="M 45,10 L 45,70 Q 45,85 35,85 Q 20,85 20,75 Q 20,65 35,65 Q 45,65 45,70 L 45,25 L 50,22 Z"fill="#333"/></svg>