Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/site/components/editor/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const COMPONENTS = [
'Stop',
'Defs',
'ClipPath',
'Marker',
'LinearGradient',
'RadialGradient',
'TextInput',
Expand Down Expand Up @@ -55,6 +56,9 @@ const PROPS = [
'bookmark',
'cache',
'minPresenceAhead',
'markerStart',
'markerMid',
'markerEnd',
'hyphenationCallback',
'orphans',
'widows',
Expand Down
4 changes: 4 additions & 0 deletions apps/site/components/section-index/v4-splits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export const splits = {
slug: 'clip-path',
title: 'ClipPath',
},
{
slug: 'marker',
title: 'Marker',
},
{
slug: 'linear-gradient',
title: 'LinearGradient',
Expand Down
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/canvas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ A React component for freely drawing any content on the page.
| paint | Painter function | _Function_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Renders component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| bookmark | Attach bookmark to element. [See more](/docs/v4/advanced/document-navigation#bookmarks-v220) | _String_ or [Bookmark](/docs/v4/advanced/document-navigation#bookmark-type) | _undefined_ |

React-pdf does not check how much space your drawing takes, so make sure you always define a `width` and `height` on the `style` prop.
Expand Down
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/image-background.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ A React component for displaying an image behind child content. It works like `I
| imageStyle | Defines styles applied to the background image | _Object_, _Array_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Renders component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| cache | Enables image caching between consecutive renders | _Boolean_ | _true_ |
| srcSet | Responsive image sources for resolution-based selection | _String_ | _undefined_ |
| sizes | Display width used for `srcSet` source selection | _String_, _Number_ | _undefined_ |
Expand Down
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A React component for displaying network or local (Node only) JPG or PNG images,
| style | Defines view styles. [See more](/docs/v4/styling) | _Object_, _Array_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Renders component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| cache | Enables image caching between consecutive renders | _Boolean_ | _true_ |
| srcSet | Responsive image sources for resolution-based selection. E.g. `"small.jpg 300w, medium.jpg 600w"` | _String_ | _undefined_ |
| sizes | Display width used for `srcSet` source selection | _String_, _Number_ | _undefined_ |
Expand Down
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ A React component for displaying an hyperlink. Link’s can be nested inside a T
| style | Defines view styles. [See more](/docs/v4/styling) | _Object_, _Array_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Render component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| hitSlop | Expands the clickable area beyond the visible bounds of the link | _Number_ or _Object_ `{ top, bottom, left, right }` | _undefined_ |
| bookmark | Attach bookmark to element. [See more](/docs/v4/advanced/document-navigation#bookmarks-v220) | _String_ or [Bookmark](/docs/v4/advanced/document-navigation#bookmark-type) | _undefined_ |
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/note.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ A React component for displaying a note annotation inside the document.
| style | Defines view styles. [See more](/docs/v4/styling) | _Object_, _Array_ | _undefined_ |
| children | Note string content | _String_ | _undefined_ |
| fixed | Renders component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A React component for displaying text. Text supports nesting of other Text or Li
| style | Defines view styles. [See more](/docs/v4/styling) | _Object_, _Array_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Renders component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| hyphenationCallback | Specify hyphenation callback at a text level. See [hypthenation](/docs/v4/advanced/hyphenation) | _Function_ | _undefined_ |
| hyphenationPenalty | Specify at what level words are hyphenated. [See more](/docs/v4/fonts#hyphenationpenalty) | _Number_ | _undefined_ |
| id | Destination ID to be linked to. [See more](/docs/v4/advanced/document-navigation#destinations-v200) | _String_ | _undefined_ |
Expand Down
2 changes: 2 additions & 0 deletions apps/site/content/docs/v4/components/view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ The most fundamental component for building a UI and is designed to be nested in
| render | Render dynamic content based on context. [See more](/docs/v4/advanced/dynamic-content) | _Function_ | _undefined_ |
| debug | Enables debug mode on view bounding box. [See more](/docs/v4/advanced/debugging) | _Boolean_ | _false_ |
| fixed | Render component in all wrapped pages. [See more](/docs/v4/advanced/page-wrapping) | _Boolean_ | _false_ |
| break | Forces the wrapping algorithm to start a new page when rendering this element. [See more](/docs/v4/advanced/page-wrapping#page-breaks) | _Boolean_ | _false_ |
| minPresenceAhead | Hint that no page wrapping should occur between all sibling elements following the element within _n_ points. [See more](/docs/v4/advanced/orphans-and-widows) | _Number_ | _0_ |
| id | Destination ID to be linked to. [See more](/docs/v4/advanced/document-navigation#destinations-v200) | _String_ | _undefined_ |
| bookmark | Attach bookmark to element. [See more](/docs/v4/advanced/document-navigation#bookmarks-v220) | _String_ or [Bookmark](/docs/v4/advanced/document-navigation#bookmark-type) | _undefined_ |
1 change: 1 addition & 0 deletions apps/site/content/docs/v4/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"svg/stop",
"svg/defs",
"svg/clip-path",
"svg/marker",
"svg/linear-gradient",
"svg/radial-gradient",
"svg/presentation-attributes",
Expand Down
24 changes: 24 additions & 0 deletions apps/site/content/docs/v4/svg/marker.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Marker"
---

The `<Marker />` element defines a graphic drawn on the vertices of a `<Line />`, `<Polyline />`, `<Polygon />` or `<Path />`, typically an arrowhead or a data point.

Declare it inside a `<Defs />` element and reference it from the shape through the `markerStart`, `markerMid` and `markerEnd` attributes, which paint it on the first vertex, every intermediate vertex and the last vertex respectively.

<Usage />

## Valid props

| Prop name | Description | Type | Default |
| ------------ | :---------------------------------------------------------------------------------------------------: | -----------------: | --------------: |
| id | Unique identifier used to reference the marker from a shape. | _String_ | _undefined_ |
| viewBox | Defines the coordinate system of the marker contents, as `"minX minY maxX maxY"`. | _String_ | _undefined_ |
| markerWidth | Width of the marker viewport. Only applied when `viewBox` is present. | _String_, _Number_ | _3_ |
| markerHeight | Height of the marker viewport. Only applied when `viewBox` is present. | _String_, _Number_ | _3_ |
| refX | Position of the marker point on its x-axis, aligned to the vertex. | _String_, _Number_ | _0_ |
| refY | Position of the marker point on its y-axis, aligned to the vertex. | _String_, _Number_ | _0_ |
| orient | Rotation applied to the marker. `auto` follows the direction of the shape, `auto-start-reverse` also flips the start marker, and a number sets a fixed angle in degrees. | _String_, _Number_ | _0_ |
| markerUnits | Coordinate system for the marker. `strokeWidth` scales it with the shape's `strokeWidth`, `userSpaceOnUse` keeps its size constant. | _String_ | _strokeWidth_ |

See also [Presentation Attributes](/docs/v4/svg/presentation-attributes)
63 changes: 63 additions & 0 deletions apps/site/content/docs/v4/svg/marker.usage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
Svg,
Defs,
Marker,
Path,
Circle,
Line,
Polyline,
} from '@react-pdf/renderer';

const Flow = () => (
<Svg viewBox="0 0 120 60" width={240} height={120}>
<Defs>
<Marker
id="arrow"
viewBox="0 0 10 10"
refX={9}
refY={5}
markerWidth={6}
markerHeight={6}
orient="auto"
>
<Path d="M 0 0 L 10 5 L 0 10 z" fill="#e82200" />
</Marker>
<Marker
id="dot"
viewBox="0 0 10 10"
refX={5}
refY={5}
markerWidth={4}
markerHeight={4}
>
<Circle cx="5" cy="5" r="5" fill="#8d1602" />
</Marker>
</Defs>
<Line
x1="8"
y1="16"
x2="104"
y2="16"
stroke="#e82200"
strokeWidth={2}
markerEnd="url(#arrow)"
/>
<Polyline
points="8,48 36,32 64,44 92,26"
fill="none"
stroke="#c9c2b6"
strokeWidth={2}
markerStart="url(#dot)"
markerMid="url(#dot)"
markerEnd="url(#dot)"
/>
</Svg>
);

ReactPDF.render(
<Document>
<Page size="A6" style={{ padding: 16 }}>
<Flow />
</Page>
</Document>,
);
4 changes: 4 additions & 0 deletions apps/site/content/docs/v4/svg/presentation-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ SVG presentation attributes are CSS properties that can be used as attributes on
| transform | Defines a list of transform definitions that are applied to an element and the element's children. | _String_ | _undefined_ |
| textAnchor | Defines the horizontal alignment of a string of text. | _String_ | _undefined_ |
| visibility | Lets you control the visibility of graphical elements. | _String_ | _visible_ |
| clipPath | References a [ClipPath](/docs/v4/svg/clip-path) restricting where paint is applied. | _String_ | _undefined_ |
| markerStart | References a [Marker](/docs/v4/svg/marker) drawn on the first vertex of the shape. | _String_ | _undefined_ |
| markerMid | References a [Marker](/docs/v4/svg/marker) drawn on every intermediate vertex of the shape. | _String_ | _undefined_ |
| markerEnd | References a [Marker](/docs/v4/svg/marker) drawn on the last vertex of the shape. | _String_ | _undefined_ |
Loading