0

We have template SVG drawings which have tags on the drawing to be replaced by text when the drawing is generated. Whenever it is generated as an SVG, it is ok, but when it is exported to a pdf, the text all shifts.

All of the tags in the SVG file were set to x='0', y='0', as there were problems in the formatting of text. When the file is generated as an SVG file there are no problems at all. I'm not sure how the PDF drawings are generated, I am assuming that they are generated as SVGs and then exported but I don't know.

Here is an example of how the text has shifted, and how it looks in the SVG drawing:

enter image description here

enter image description here

Reproducible Code:

<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg height="793.33331" id="svg10" inkscape:version="0.92.3 (2405546, 2018-03-11)" sodipodi:docname="1c E37 Face Electric Operation No No.svg" version="1.1" viewBox="0 0 1122.6667 793.33331" width="1122.6667" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <metadata id="metadata16">
  <rdf:RDF>
   <cc:Work rdf:about="">
    <dc:format>
     image/svg+xml
    </dc:format>
    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
    <dc:title/>
   </cc:Work>
  </rdf:RDF>
 </metadata>
 <sodipodi:namedview bordercolor="#666666" borderopacity="1" gridtolerance="10" guidetolerance="10" id="namedview12" inkscape:current-layer="g18" inkscape:cx="561.33337" inkscape:cy="396.66666" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-height="2066" inkscape:window-maximized="1" inkscape:window-width="3840" inkscape:window-x="-11" inkscape:window-y="-11" inkscape:zoom="2.1646365" objecttolerance="10" pagecolor="#ffffff" showgrid="false"/>
 <g id="g18" inkscape:groupmode="layer" inkscape:label="1c E37 Face Electric Operation No No" transform="matrix(0,-0.08,-0.08,0,1120,790.66666)">
  <g id="g20">
   <g clip-path="url(#clipPath26)" id="g22"/>
  </g>
  <g id="g28">
   <g clip-path="url(#clipPath34)" id="g30"/>
  </g>
  <g id="g36">
   <g clip-path="url(#clipPath42)" id="g38"/>
  </g>
  <g id="g44">
   <g clip-path="url(#clipPath50)" id="g46"/>
  </g>
  <g>
    <path d="m 7819,5214 -204,-182 v -17" id="path16964" inkscape:connector-curvature="0" style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"/>
    <path d="M 2874,6382 V 5212" id="path16966" inkscape:connector-curvature="0" style="fill:none;stroke:#000000;stroke-width:12.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"/>
    <text id="text16970" style="font-variant:normal;font-weight:normal;font-size:123.10199738px;font-family:Arial;-inkscape-font-specification:ArialMT;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" transform="matrix(0,-1,-1,0,2900,6382)">
     <tspan id="tspan16968" sodipodi:role="line" x="0" y="0">
      TYPICAL THROUGH
     </tspan>
    </text>
 </g>
</g>
</svg>
5
  • Post the SVG code...
    – Scott
    Aug 23, 2019 at 15:01
  • @Scott see edit, the whole file is very large so I removed a lot of unnecessary parts
    – user141784
    Aug 23, 2019 at 15:18
  • Well I see the problem but I don't know where it's being introduced. If I open the svg in Illustrator, the text has a bunch of empty spaced in front of it, causing the indent. A PDF, also being an Adobe format, I suspect is seeing the same thing. But I can't figure out why those spaces are being rendered.
    – Scott
    Aug 23, 2019 at 15:28
  • Do you need any more of the code?
    – user141784
    Aug 23, 2019 at 15:29
  • I'll have a look to see if it's anything to do with xml:space being preserved rather than default
    – user141784
    Aug 23, 2019 at 15:30

1 Answer 1

0

If I open the SVG in Illustrator, the text has a bunch of empty spaces before it. Since PDF is also an Adobe format, I suspect the PDF is seeing these same empty spaces.

After some playing.... just remove the white space in the SVG around the text...

<tspan id="tspan16968" sodipodi:role="line" x="0" y="0">TYPICAL THROUGH</tspan>

For some odd reason those line feeds, and the indent in the XML markup, are being seen as spaces and honored by Illustrator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.