Skip to content

Commit 50de55a

Browse files
committed
Clarify issue with pseudo-inline shapes and prepare for publish
1 parent e7d6da8 commit 50de55a

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.15.0 - Not released yet
1+
## 0.15.0 - 2025.09.12
22

33
- Support for shapes, lines and text boxes in DOCX to RTF converter.
44
Not everything is supported, see [Supported features](https://github.com/manfromarce/DocSharp/blob/main/documentation/Supported_features.MD) for reference.

documentation/Supported_features.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Only watermarks are not supported because they require full VML support in order
8686
[14]: Support for drawings is still incomplete:
8787
- **Supported**: DrawingML shapes / lines / arrows (created by modern Word versions, unless in compatibility mode), text content, solid fill, gradient fill, picture/texture fill, line color, line style (dashed, dotted, double, cap, ...), line thickness
8888
- **Not supported**: VML (Word 2007 or compatibility mode), manual adjustments (corners / points adjustments and similar), freehand curve/polygon, some shapes that are not available in RTF and would require conversion to custom shapes, pattern fill, gradient/pattern for line, some advanced text layout options, effects, 3D effects, WordArt, diagrams, shape groups, drawing canvas
89+
- **Partially supported**: shapes in line with text (not floating) are preserved but not aligned properly.
8990

9091
[15]: "Real" charts are not available in the RTF specification, so MS Word converts them to images or OLE objects.
9192
This operation is complex and currently considered out-of-scope for this library.

src/DocSharp.Docx/DocxToRtf/DocxToRtfConverter.DrawingML.cs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,10 @@ internal void ProcessTransform2D(A.Transform2D? transform2D, RtfStringWriter sb)
11911191

11921192
internal void ProcessDrawingInline(Wp.Inline inline, RtfStringWriter sb)
11931193
{
1194+
// TODO: for inline shapes with "fPseudoInline" in RTF,
1195+
// we should also write a pict element of the same size as the shape,
1196+
// otherwise RTF readers do not leave space for the shape and it overlaps with text,
1197+
// also it's not vertically aligned with text baseline.
11941198
var distT = inline.DistanceFromTop;
11951199
var distB = inline.DistanceFromBottom;
11961200
var distL = inline.DistanceFromLeft;
@@ -1215,28 +1219,36 @@ internal void ProcessDrawingInline(Wp.Inline inline, RtfStringWriter sb)
12151219
}
12161220
sb.WriteWordWithValue("shpright", extentXtwips);
12171221
sb.WriteWordWithValue("shpbottom", extentYtwips);
1222+
sb.Write(@"\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplockanchor");
12181223

12191224
sb.WriteLine();
12201225

12211226
sb.WriteShapeProperty("fUseShapeAnchor", false);
12221227
sb.WriteShapeProperty("fPseudoInline", true);
1223-
1224-
if (distT != null)
1225-
{
1226-
sb.WriteShapeProperty("dyWrapDistTop", distT.Value);
1227-
}
1228-
if (distB != null)
1229-
{
1230-
sb.WriteShapeProperty("dyWrapDistBottom", distB.Value);
1231-
}
1232-
if (distL != null)
1233-
{
1234-
sb.WriteShapeProperty("dxWrapDistLeft", distL.Value);
1235-
}
1236-
if (distR != null)
1237-
{
1238-
sb.WriteShapeProperty("dxWrapDistRight", distR.Value);
1239-
}
1228+
sb.WriteShapeProperty("fAllowOverlap", "1");
1229+
sb.WriteShapeProperty("fLayoutInCell", "1");
1230+
sb.WriteShapeProperty("lockPosition", "1");
1231+
sb.WriteShapeProperty("lockRotation", "1");
1232+
sb.WriteShapeProperty("posrelh", "3");
1233+
sb.WriteShapeProperty("posrelv", "3");
1234+
1235+
// Not supported for inlines ? (however set to 0 in tested DOCX files)
1236+
//if (distT != null)
1237+
//{
1238+
// sb.WriteShapeProperty("dyWrapDistTop", distT.Value);
1239+
//}
1240+
//if (distB != null)
1241+
//{
1242+
// sb.WriteShapeProperty("dyWrapDistBottom", distB.Value);
1243+
//}
1244+
//if (distL != null)
1245+
//{
1246+
// sb.WriteShapeProperty("dxWrapDistLeft", distL.Value);
1247+
//}
1248+
//if (distR != null)
1249+
//{
1250+
// sb.WriteShapeProperty("dxWrapDistRight", distR.Value);
1251+
//}
12401252
}
12411253

12421254
internal void ProcessDrawingAnchor(Wp.Anchor anchor, RtfStringWriter sb)

test-files/DOCX/Shapes.docx

3.58 KB
Binary file not shown.

0 commit comments

Comments
 (0)