# PdfGraphics class

> A drawing surface on a page. Coordinates are in points with the origin at the top left corner of the media box and y pointing down. Dispose it, or save...

Namespace: [PdfNetStack.Drawing](https://www.jadev-corp.com/api/pdfnetstack-drawing/)  
Assembly: PdfNetStack.dll  
Package: `PdfNetStack`

A drawing surface on a page. Coordinates are in points with the origin at the top left corner
of the media box and y pointing down. Dispose it, or save the document, to write the drawing
into the page. Not thread safe.

```csharp
public sealed class PdfGraphics : IDisposable
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfGraphics](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfgraphics/)

**Implements**

[IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

## Remarks

On an existing page, the page's own content is wrapped in a save and restore pair so that
graphics state it leaves behind cannot affect this drawing. The page's /Rotate is not applied:
coordinates are those of the unrotated page.

## Properties

### <a id="PdfNetStack_Drawing_PdfGraphics_BlendMode"></a> BlendMode

How further drawing blends with what is under it. Saved and restored with the graphics state.

```csharp
public PdfBlendMode BlendMode { get; set; }
```

#### Property Value

 [PdfBlendMode](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfblendmode/)

### <a id="PdfNetStack_Drawing_PdfGraphics_Form"></a> Form

The form being drawn into, or null when drawing on a page.

```csharp
public PdfForm? Form { get; }
```

#### Property Value

 [PdfForm](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfform/)?

### <a id="PdfNetStack_Drawing_PdfGraphics_Height"></a> Height

Height of the drawing area in points.

```csharp
public double Height { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_Page"></a> Page

The page being drawn on, or null when drawing into a [PdfForm](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfform/).

```csharp
public PdfPage? Page { get; }
```

#### Property Value

 [PdfPage](https://www.jadev-corp.com/api/pdfnetstack/pdfpage/)?

### <a id="PdfNetStack_Drawing_PdfGraphics_Transform"></a> Transform

The current transform from user coordinates to canvas coordinates.

```csharp
public PdfMatrix Transform { get; }
```

#### Property Value

 [PdfMatrix](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfmatrix/)

### <a id="PdfNetStack_Drawing_PdfGraphics_Width"></a> Width

Width of the drawing area in points: the media box, or the form's width.

```csharp
public double Width { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

## Methods

### <a id="PdfNetStack_Drawing_PdfGraphics_AddLink_System_Double_System_Double_System_Double_System_Double_System_Uri_"></a> AddLink\(double, double, double, double, Uri\)

Adds a link over a rectangle in current canvas coordinates; under a transform, the link
covers the transformed rectangle's bounds. Only on pages.

```csharp
public PdfAnnotation AddLink(double x, double y, double width, double height, Uri uri)
```

#### Parameters

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`uri` [Uri](https://learn.microsoft.com/dotnet/api/system.uri)

#### Returns

 [PdfAnnotation](https://www.jadev-corp.com/api/pdfnetstack/pdfannotation/)

### <a id="PdfNetStack_Drawing_PdfGraphics_AddLink_System_Double_System_Double_System_Double_System_Double_PdfNetStack_PdfPage_System_Nullable_System_Double__"></a> AddLink\(double, double, double, double, PdfPage, double?\)

Adds a link to a page of this document over a rectangle in current canvas coordinates.

```csharp
public PdfAnnotation AddLink(double x, double y, double width, double height, PdfPage target, double? top = null)
```

#### Parameters

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`target` [PdfPage](https://www.jadev-corp.com/api/pdfnetstack/pdfpage/)

`top` [double](https://learn.microsoft.com/dotnet/api/system.double)?

#### Returns

 [PdfAnnotation](https://www.jadev-corp.com/api/pdfnetstack/pdfannotation/)

### <a id="PdfNetStack_Drawing_PdfGraphics_Dispose"></a> Dispose\(\)

Writes the drawing into the page. Further drawing is not possible.

```csharp
public void Dispose()
```

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawArc_PdfNetStack_Drawing_PdfPen_System_Double_System_Double_System_Double_System_Double_System_Double_System_Double_"></a> DrawArc\(PdfPen, double, double, double, double, double, double\)

Draws an elliptical arc of the ellipse inscribed in the given rectangle. Angles in degrees, clockwise.

```csharp
public void DrawArc(PdfPen pen, double x, double y, double width, double height, double startAngle, double sweepAngle)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`startAngle` [double](https://learn.microsoft.com/dotnet/api/system.double)

`sweepAngle` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawBezier_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfPoint_PdfNetStack_Drawing_PdfPoint_PdfNetStack_Drawing_PdfPoint_PdfNetStack_Drawing_PdfPoint_"></a> DrawBezier\(PdfPen, PdfPoint, PdfPoint, PdfPoint, PdfPoint\)

Draws a cubic Bezier curve.

```csharp
public void DrawBezier(PdfPen pen, PdfPoint start, PdfPoint control1, PdfPoint control2, PdfPoint end)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)

`start` [PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)

`control1` [PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)

`control2` [PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)

`end` [PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawEllipse_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_System_Double_System_Double_"></a> DrawEllipse\(PdfPen?, PdfBrush?, double, double, double, double\)

Draws an ellipse inscribed in the given rectangle.

```csharp
public void DrawEllipse(PdfPen? pen, PdfBrush? brush, double x, double y, double width, double height)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawForm_PdfNetStack_Drawing_PdfForm_System_Double_System_Double_"></a> DrawForm\(PdfForm, double, double\)

Draws a form at its own size, its top left corner at (x, y).

```csharp
public void DrawForm(PdfForm form, double x, double y)
```

#### Parameters

`form` [PdfForm](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfform/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawForm_PdfNetStack_Drawing_PdfForm_System_Double_System_Double_System_Double_System_Double_"></a> DrawForm\(PdfForm, double, double, double, double\)

Draws a form scaled into the rectangle: a stamp, a template, a page shown in miniature.

```csharp
public void DrawForm(PdfForm form, double x, double y, double width, double height)
```

#### Parameters

`form` [PdfForm](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfform/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The form belongs to another document.

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawImage_PdfNetStack_Drawing_PdfImage_System_Double_System_Double_"></a> DrawImage\(PdfImage, double, double\)

Draws an image at its natural size: its pixels at the resolution it records, else 96 per inch.

```csharp
public void DrawImage(PdfImage image, double x, double y)
```

#### Parameters

`image` [PdfImage](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfimage/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawImage_PdfNetStack_Drawing_PdfImage_System_Double_System_Double_System_Double_System_Double_"></a> DrawImage\(PdfImage, double, double, double, double\)

Draws an image stretched to the rectangle, upright as its EXIF orientation says. Painting
follows the current transform and clip; transparency comes from the image's alpha channel.

```csharp
public void DrawImage(PdfImage image, double x, double y, double width, double height)
```

#### Parameters

`image` [PdfImage](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfimage/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawImage_PdfNetStack_Drawing_PdfImage_System_Double_System_Double_System_Double_System_Double_PdfNetStack_Drawing_PdfImageFit_PdfNetStack_Drawing_PdfImageAlignment_System_Double_"></a> DrawImage\(PdfImage, double, double, double, double, PdfImageFit, PdfImageAlignment, double\)

Draws an image into a box, fitted as <code class="paramref">fit</code> says and placed by
<code class="paramref">alignment</code> where it does not fill the box. Whatever falls outside the box
is clipped. <code class="paramref">opacity</code> fades the whole image, on top of its own alpha.

```csharp
public void DrawImage(PdfImage image, double x, double y, double width, double height, PdfImageFit fit, PdfImageAlignment alignment = PdfImageAlignment.Center, double opacity = 1)
```

#### Parameters

`image` [PdfImage](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfimage/)

The image.

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

Left edge of the box.

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

Top edge of the box.

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

Width of the box.

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

Height of the box.

`fit` [PdfImageFit](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfimagefit/)

How the image fills the box.

`alignment` [PdfImageAlignment](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfimagealignment/)

Where the image sits when it is smaller or larger than the box.

`opacity` [double](https://learn.microsoft.com/dotnet/api/system.double)

0 (invisible) to 1 (opaque).

#### Exceptions

 [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception)

<code class="paramref">opacity</code> is not between 0 and 1.

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawInvisibleText_System_String_System_Double_System_Double_System_Double_System_Double_"></a> DrawInvisibleText\(string, double, double, double, double\)

Draws text that is invisible but selectable and searchable, stretched to fill a box: the
text layer of a scanned page. The box's top left corner is at (x, y); the text's baseline
runs along its bottom edge and its height is the font size. Any script works, unshaped,
since nothing is drawn.

```csharp
public void DrawInvisibleText(string text, double x, double y, double width, double height)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

The text, in logical order.

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

Left edge of the box.

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

Top edge of the box.

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

Width the text is stretched or squeezed to.

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

Height of the box: the font size.

#### Examples

<pre><code class="lang-csharp">// A word an OCR engine found at 100,200 to 180,214 points on the page.
graphics.DrawInvisibleText("Invoice", 100, 200, 80, 14);</code></pre>

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawInvisibleText_System_String_System_Double_System_Double_System_Double_System_Double_System_Double_"></a> DrawInvisibleText\(string, double, double, double, double, double\)

Draws invisible, searchable text in a box rotated clockwise about its top left corner.

```csharp
public void DrawInvisibleText(string text, double x, double y, double width, double height, double angle)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

The text, in logical order.

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

Left edge of the box, before rotation.

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

Top edge of the box, before rotation.

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

Width the text is stretched or squeezed to.

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

Height of the box: the font size.

`angle` [double](https://learn.microsoft.com/dotnet/api/system.double)

Rotation in degrees, clockwise, about (x, y).

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawLine_PdfNetStack_Drawing_PdfPen_System_Double_System_Double_System_Double_System_Double_"></a> DrawLine\(PdfPen, double, double, double, double\)

Draws a straight line.

```csharp
public void DrawLine(PdfPen pen, double x1, double y1, double x2, double y2)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)

`x1` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y1` [double](https://learn.microsoft.com/dotnet/api/system.double)

`x2` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y2` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawLines_PdfNetStack_Drawing_PdfPen_System_Collections_Generic_IEnumerable_PdfNetStack_Drawing_PdfPoint__"></a> DrawLines\(PdfPen, IEnumerable&lt;PdfPoint\>\)

Draws connected straight lines through the given points.

```csharp
public void DrawLines(PdfPen pen, IEnumerable<PdfPoint> points)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)

`points` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable\-1)<[PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)\>

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawPath_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_PdfNetStack_Drawing_PdfPath_"></a> DrawPath\(PdfPen?, PdfBrush?, PdfPath\)

Strokes <code class="paramref">path</code> with <code class="paramref">pen</code> and fills it with <code class="paramref">brush</code>; either may be null.

```csharp
public void DrawPath(PdfPen? pen, PdfBrush? brush, PdfPath path)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`path` [PdfPath](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpath/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawPie_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_System_Double_System_Double_System_Double_System_Double_"></a> DrawPie\(PdfPen?, PdfBrush?, double, double, double, double, double, double\)

Draws a pie slice of the ellipse inscribed in the given rectangle. Angles in degrees, clockwise.

```csharp
public void DrawPie(PdfPen? pen, PdfBrush? brush, double x, double y, double width, double height, double startAngle, double sweepAngle)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`startAngle` [double](https://learn.microsoft.com/dotnet/api/system.double)

`sweepAngle` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawPolygon_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Collections_Generic_IEnumerable_PdfNetStack_Drawing_PdfPoint__PdfNetStack_Drawing_PdfFillRule_"></a> DrawPolygon\(PdfPen?, PdfBrush?, IEnumerable&lt;PdfPoint\>, PdfFillRule\)

Draws a closed polygon.

```csharp
public void DrawPolygon(PdfPen? pen, PdfBrush? brush, IEnumerable<PdfPoint> points, PdfFillRule fillRule = PdfFillRule.NonZero)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`points` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable\-1)<[PdfPoint](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpoint/)\>

`fillRule` [PdfFillRule](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdffillrule/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawRectangle_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_System_Double_System_Double_"></a> DrawRectangle\(PdfPen?, PdfBrush?, double, double, double, double\)

Draws a rectangle, stroked with <code class="paramref">pen</code> and filled with <code class="paramref">brush</code>; either may be null.

```csharp
public void DrawRectangle(PdfPen? pen, PdfBrush? brush, double x, double y, double width, double height)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawRoundedRectangle_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_System_Double_System_Double_System_Double_"></a> DrawRoundedRectangle\(PdfPen?, PdfBrush?, double, double, double, double, double\)

Draws a rectangle with circular corners.

```csharp
public void DrawRoundedRectangle(PdfPen? pen, PdfBrush? brush, double x, double y, double width, double height, double radius)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`radius` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawRoundedRectangle_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_System_Double_System_Double_PdfNetStack_Drawing_PdfCornerRadii_"></a> DrawRoundedRectangle\(PdfPen?, PdfBrush?, double, double, double, double, PdfCornerRadii\)

Draws a rectangle with elliptical corners, sized as CSS border-radius does.

```csharp
public void DrawRoundedRectangle(PdfPen? pen, PdfBrush? brush, double x, double y, double width, double height, PdfCornerRadii radii)
```

#### Parameters

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

`radii` [PdfCornerRadii](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfcornerradii/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawString_System_String_PdfNetStack_Fonts_PdfFont_System_Double_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_"></a> DrawString\(string, PdfFont, double, PdfBrush, double, double\)

Draws one line of text filled with <code class="paramref">brush</code>. (<code class="paramref">x</code>,
<code class="paramref">y</code>) is the start of the baseline; add [Ascent](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdffont/#PdfNetStack_Fonts_PdfFont_Ascent) times
the size to <code class="paramref">y</code> to place the top of the line instead.

```csharp
public void DrawString(string text, PdfFont font, double size, PdfBrush brush, double x, double y)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

`font` [PdfFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdffont/)

`size` [double](https://learn.microsoft.com/dotnet/api/system.double)

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The font has no glyph for a character of the text.

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawString_System_String_PdfNetStack_Fonts_PdfFont_System_Double_PdfNetStack_Drawing_PdfPen_PdfNetStack_Drawing_PdfBrush_System_Double_System_Double_"></a> DrawString\(string, PdfFont, double, PdfPen?, PdfBrush?, double, double\)

Draws one line of text, its glyph outlines stroked with <code class="paramref">pen</code> and filled
with <code class="paramref">brush</code>; either may be null. (<code class="paramref">x</code>, <code class="paramref">y</code>)
is the start of the baseline. Control and format characters, such as tabs and zero width
joiners, are skipped.

```csharp
public void DrawString(string text, PdfFont font, double size, PdfPen? pen, PdfBrush? brush, double x, double y)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

`font` [PdfFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdffont/)

`size` [double](https://learn.microsoft.com/dotnet/api/system.double)

`pen` [PdfPen](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpen/)?

`brush` [PdfBrush](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfbrush/)?

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The font has no glyph for a character of the text.

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawSvg_PdfNetStack_Drawing_PdfSvg_System_Double_System_Double_"></a> DrawSvg\(PdfSvg, double, double\)

Draws an SVG drawing at its own size, its top left corner at (x, y).

```csharp
public void DrawSvg(PdfSvg svg, double x, double y)
```

#### Parameters

`svg` [PdfSvg](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfsvg/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawSvg_PdfNetStack_Drawing_PdfSvg_System_Double_System_Double_System_Double_System_Double_"></a> DrawSvg\(PdfSvg, double, double, double, double\)

Draws an SVG drawing scaled to fill width by height points; its viewBox and
preserveAspectRatio decide how it fits inside.

```csharp
public void DrawSvg(PdfSvg svg, double x, double y, double width, double height)
```

#### Parameters

`svg` [PdfSvg](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfsvg/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawText_PdfNetStack_Drawing_PdfParagraph_System_Double_System_Double_System_Double_"></a> DrawText\(PdfParagraph, double, double, double\)

Lays out a paragraph at <code class="paramref">width</code> points, wrapping and aligning its lines,
and draws it with its top left corner at (<code class="paramref">x</code>, <code class="paramref">y</code>).
Returns the layout, whose [Height](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextlayout/#PdfNetStack_Drawing_PdfTextLayout_Height) tells how much room it took.

```csharp
public PdfTextLayout DrawText(PdfParagraph paragraph, double x, double y, double width)
```

#### Parameters

`paragraph` [PdfParagraph](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfparagraph/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Returns

 [PdfTextLayout](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextlayout/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawText_System_String_PdfNetStack_Drawing_PdfTextStyle_System_Double_System_Double_System_Double_PdfNetStack_Drawing_PdfTextAlignment_"></a> DrawText\(string, PdfTextStyle, double, double, double, PdfTextAlignment\)

Draws text in one style, wrapped to <code class="paramref">width</code> points; returns the layout.

```csharp
public PdfTextLayout DrawText(string text, PdfTextStyle style, double x, double y, double width, PdfTextAlignment alignment = PdfTextAlignment.Start)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

`style` [PdfTextStyle](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextstyle/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`alignment` [PdfTextAlignment](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextalignment/)

#### Returns

 [PdfTextLayout](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextlayout/)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawText_PdfNetStack_Drawing_PdfTextLayout_System_Double_System_Double_"></a> DrawText\(PdfTextLayout, double, double\)

Draws a laid out paragraph with its top left corner at (<code class="paramref">x</code>, <code class="paramref">y</code>).

```csharp
public void DrawText(PdfTextLayout layout, double x, double y)
```

#### Parameters

`layout` [PdfTextLayout](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextlayout/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_DrawText_PdfNetStack_Drawing_PdfTextLayout_System_Double_System_Double_System_Int32_System_Int32_"></a> DrawText\(PdfTextLayout, double, double, int, int\)

Draws <code class="paramref">count</code> lines of a layout from line <code class="paramref">first</code>, the
first of them at (<code class="paramref">x</code>, <code class="paramref">y</code>): for text that continues on
the next page or column.

```csharp
public void DrawText(PdfTextLayout layout, double x, double y, int first, int count)
```

#### Parameters

`layout` [PdfTextLayout](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdftextlayout/)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`first` [int](https://learn.microsoft.com/dotnet/api/system.int32)

`count` [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="PdfNetStack_Drawing_PdfGraphics_IntersectClip_PdfNetStack_Drawing_PdfPath_"></a> IntersectClip\(PdfPath\)

Restricts all further drawing to the inside of <code class="paramref">path</code>, until the next restore.

```csharp
public void IntersectClip(PdfPath path)
```

#### Parameters

`path` [PdfPath](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfpath/)

### <a id="PdfNetStack_Drawing_PdfGraphics_IntersectClip_System_Double_System_Double_System_Double_System_Double_"></a> IntersectClip\(double, double, double, double\)

Restricts all further drawing to a rectangle, until the next restore.

```csharp
public void IntersectClip(double x, double y, double width, double height)
```

#### Parameters

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

`width` [double](https://learn.microsoft.com/dotnet/api/system.double)

`height` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_MultiplyTransform_PdfNetStack_Drawing_PdfMatrix_"></a> MultiplyTransform\(PdfMatrix\)

Applies <code class="paramref">matrix</code> before the current transform.

```csharp
public void MultiplyTransform(PdfMatrix matrix)
```

#### Parameters

`matrix` [PdfMatrix](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfmatrix/)

### <a id="PdfNetStack_Drawing_PdfGraphics_Restore"></a> Restore\(\)

Restores the most recently saved state.

```csharp
public void Restore()
```

#### Exceptions

 [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)

Nothing is saved.

### <a id="PdfNetStack_Drawing_PdfGraphics_RotateAtTransform_System_Double_System_Double_System_Double_"></a> RotateAtTransform\(double, double, double\)

Rotates about (x, y), clockwise for positive angles.

```csharp
public void RotateAtTransform(double degrees, double x, double y)
```

#### Parameters

`degrees` [double](https://learn.microsoft.com/dotnet/api/system.double)

`x` [double](https://learn.microsoft.com/dotnet/api/system.double)

`y` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_RotateTransform_System_Double_"></a> RotateTransform\(double\)

Rotates about the origin, clockwise for positive angles.

```csharp
public void RotateTransform(double degrees)
```

#### Parameters

`degrees` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_Save"></a> Save\(\)

Saves the graphics state: transform, clip, colors and pen settings. Dispose the result, or
call [Restore](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfgraphics/#PdfNetStack_Drawing_PdfGraphics_Restore), to return to it.

```csharp
public PdfGraphicsState Save()
```

#### Returns

 [PdfGraphicsState](https://www.jadev-corp.com/api/pdfnetstack-drawing/pdfgraphicsstate/)

### <a id="PdfNetStack_Drawing_PdfGraphics_ScaleTransform_System_Double_System_Double_"></a> ScaleTransform\(double, double\)

Scales about the origin.

```csharp
public void ScaleTransform(double sx, double sy)
```

#### Parameters

`sx` [double](https://learn.microsoft.com/dotnet/api/system.double)

`sy` [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Drawing_PdfGraphics_TranslateTransform_System_Double_System_Double_"></a> TranslateTransform\(double, double\)

Moves the origin.

```csharp
public void TranslateTransform(double dx, double dy)
```

#### Parameters

`dx` [double](https://learn.microsoft.com/dotnet/api/system.double)

`dy` [double](https://learn.microsoft.com/dotnet/api/system.double)

## Used in

- [PDF coordinates and units in PdfNetStack](https://www.jadev-corp.com/concepts/coordinates-and-units/)
- [Get started with PdfNetStack](https://www.jadev-corp.com/getting-started/)
- [PDF links and annotations in C# and .NET](https://www.jadev-corp.com/guides/annotations/)
- [Compress PDF files in C# and .NET](https://www.jadev-corp.com/guides/compress-pdf/)
- [Draw on PDF pages in C# and .NET](https://www.jadev-corp.com/guides/drawing/)
- [Extract text from PDF files in C#](https://www.jadev-corp.com/guides/extract-text/)
- [Fonts and text in PDF with C# and .NET](https://www.jadev-corp.com/guides/fonts-and-text/)
- [Fill and create PDF forms in C# and .NET](https://www.jadev-corp.com/guides/forms/)
- [CSS support in PdfNetStack.Html](https://www.jadev-corp.com/guides/html-to-pdf/css-support/)
- [Add images to PDF in C# and .NET](https://www.jadev-corp.com/guides/images/)
- [Create PDF/A files in C# and .NET](https://www.jadev-corp.com/guides/pdf-a/)
- [Add page numbers to a PDF in C#](https://www.jadev-corp.com/recipes/add-page-numbers/)
- [Add a watermark to a PDF in C#](https://www.jadev-corp.com/recipes/add-watermark/)
- [Write Arabic text in a PDF in C#](https://www.jadev-corp.com/recipes/arabic-text-pdf/)
- [Downsample images in a PDF in C#](https://www.jadev-corp.com/recipes/downsample-pdf-images/)
- [Create a Factur-X invoice PDF in C#](https://www.jadev-corp.com/recipes/pdf-a-3-xml-attachment/)
- [Reduce PDF size for email in C#](https://www.jadev-corp.com/recipes/reduce-pdf-size/)
- [Convert a TIFF to PDF in C#](https://www.jadev-corp.com/recipes/tiff-to-pdf/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-drawing/pdfgraphics/
