We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert SVG Image with Pattern in Word Document and Convert to DOC Format using C# .NET

Consider this minimal code that inserts an SVG image:

var doc = new Document();
var builder = new DocumentBuilder(doc);
builder.InsertImage(@"image.svg");
doc.Save("test.doc");

That SVG image has a diagonal stripes pattern:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" preserveAspectRatio="xMinYMax" font-size="8" font-family="Consolas, &quot;Courier New&quot;, Courier, monospace" shape-rendering="auto" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1">
  <g transform="translate(10, 10)">
    <defs>
      <pattern width="10" height="10" patternUnits="userSpaceOnUse" id="diagonal_stripe">
        <image x="0" y="0" width="10" height="10" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMCcgaGVpZ2h0PScxMCc+CiAgPHJlY3Qgd2lkdGg9JzEwJyBoZWlnaHQ9JzEwJyBmaWxsPSd3aGl0ZScvPgogIDxwYXRoIGQ9J00tMSwxIGwyLC0yCiAgICAgICAgICAgTTAsMTAgbDEwLC0xMAogICAgICAgICAgIE05LDExIGwyLC0yJyBzdHJva2U9J2JsYWNrJyBzdHJva2Utd2lkdGg9JzInLz4KPC9zdmc+" />
      </pattern>
    </defs>
  </g>
  <g transform="translate(0, 40)">
    <text>foo</text>
    <g>
      <g>
        <rect width="40" height="10" color="black" transform="translate(210, -7.5)" style="fill:url(#diagonal_stripe);" />
      </g>
      <g />
    </g>
  </g>
</svg>

The SVG looks like this:

2020-03-20 10_45_15-image.svg.png (3.6 KB)

The problem is when Aspose.Words saves the document as either doc or pdf, the striped pattern is not visible:

2020-03-20 10_48_17-test.doc - Compatibility Mode - Word.png (1.4 KB)

@kristofferjalen,

Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20167. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.