Comments (5)
Alright, just spotted that the problem only occurs when elements are added to a group prior to being added to an SvgDocument. I edited the previous comment so that the problem actually occurs. Sorry!
from svg.
@Moggel12 Thanks for the illustration. Please, is this related to #946 ?
It may be an extension to it, but I don't believe it to be the same. In my case, no transformations have been added to the group. However, it does look like #946 adds elements to the group first and then adds the group to the document, so maybe the same root cause?
from svg.
@Moggel12 It will help a lot if you provide a sample.
from svg.
Sure, something like this? @paulushub
using Svg;
var document = new SvgDocument()
{
Width = new SvgUnit(SvgUnitType.Inch, 10),
Height = new SvgUnit(SvgUnitType.Inch, 10),
FontSize = 15,
FontFamily = "Sans-Serif",
};
var svgGroup = new SvgGroup();
float x = 100, y = 100;
var xLocation = new SvgUnitCollection();
var yLocation = new SvgUnitCollection();
xLocation.Add(x);
yLocation.Add(y);
var textBox = new SvgText
{
X = xLocation,
Y = yLocation
};
var lines = new List<string>()
{
"This is",
"a multiline",
"test"
};
float offset = 0;
foreach (var line in lines)
{
var unit = new SvgUnit(SvgUnitType.Em, offset);
var yOffset = new SvgUnitCollection
{
unit
};
var textSpan = new SvgTextSpan
{
Text = line,
Dy = yOffset,
X = xLocation,
};
textBox.Children.Add(textSpan);
offset += 1F;
}
textBox.AddStyle("fill", "black", 0);
textBox.AddStyle("font-size", "inherit", 0);
svgGroup.Children.Add(textBox);
var boundingBox = new SvgRectangle
{
X = textBox.Bounds.X,
Y = textBox.Bounds.Y,
Width = textBox.Bounds.Width,
Height = textBox.Bounds.Height
};
boundingBox.AddStyle("fill", "none", 0);
boundingBox.AddStyle("stroke", "black", 0);
svgGroup.Children.Add(boundingBox);
document.Children.Add(svgGroup);
var completePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "test.svg");
document.Write(completePath, false);
from svg.
@Moggel12 Thanks for the illustration. Please, is this related to #946 ?
from svg.
Related Issues (20)
- Извините но я утюг, обработка нажатия на элементы SVG HOT 3
- Latest Nuget version can not load images - BUG HOT 7
- Is it possible to vectorize text paths?
- SVG rendered to PNG is all black instead of a gradient
- Draw Svg in Svg with different ViewBox
- Looking for new maintainer(s) HOT 41
- Contributors: Planned Cleanup - please comment HOT 7
- Contributors: TargetFrameworks - please comment HOT 1
- Contributors: Code Generators HOT 1
- Contributors: ISvgEventCaller and Events Support HOT 1
- Contributors: Extension Methods HOT 2
- letter-spacing overlapping text when converting to png HOT 1
- The Icon file converted from the SVG file does not render properly in the Application Icon of the Form.
- The Icon file converted from the SVG file does not render properly in the Application Icon of the Form. HOT 1
- Diverse problems with text alignment when rendering to EMF HOT 3
- CSS Outline not working HOT 2
- anti
- SvgDocument.Ppi not works as expect (2 problems)
- Logo get rendered incorrect HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg.