Skip to content

Commit

Permalink
mtext initial
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Feb 6, 2025
1 parent ce5163b commit a6cccd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Binary file modified samples/export_sample.dwg
Binary file not shown.
30 changes: 17 additions & 13 deletions src/ACadSharp.Pdf/Core/IO/PdfPen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void DrawEntity(Entity entity, Transform transform)
case IPolyline polyline:
this.drawPolyline(polyline, transform);
break;
case TextEntity text:
case IText text:
this.drawText(text, transform);
break;
case Viewport viewport:
Expand Down Expand Up @@ -201,7 +201,7 @@ private void drawPolyline(IPolyline polyline, Transform transform)
this._sb.AppendLine(PdfKey.Stroke);
}

private void drawText(TextEntity text, Transform transform)
private void drawText(IText text, Transform transform)
{
this._sb.AppendLine(PdfKey.BasicTextStart);

Expand All @@ -214,7 +214,21 @@ private void drawText(TextEntity text, Transform transform)
this._sb.AppendLine();

this.appendXY(text.InsertPoint, "Td");
this._sb.AppendLine($"({text.Value}) Tj");

switch (text)
{
case MText mtext:
foreach (var l in mtext.GetTextLines())
{
this._sb.AppendLine($"({l}) Tj");
}
break;
default:
this._sb.AppendLine($"({text.Value}) Tj");
break;
}


this._sb.AppendLine(PdfKey.BasicTextEnd);
}

Expand Down Expand Up @@ -280,16 +294,6 @@ private void appendXY(IVector value, string key)
this.appendXY(value[0], value[1], key);
}

private void appendXY(XY value, string key)
{
this.appendXY(value.X, value.Y, key);
}

private void appendXY(XYZ value, string key)
{
this.appendXY((XY)value, key);
}

private string toPdfDouble(double value)
{
return (value / this.DenominatorScale).ToPdfUnit(this.PaperUnits).ToString(this._configuration.DecimalFormat);
Expand Down

0 comments on commit a6cccd3

Please sign in to comment.