Problem writing a changed DeepCopied document
See original GitHub issueHello! I have a problem writing a changed DeepCopied document.
Description
I have an original SVG file, that looks like that I open it and make a deep copy of it:
var sampleDoc = SvgDocument.Open(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../sample_closed.svg"));
var newDoc = (SvgDocument)sampleDoc.DeepCopy<SvgDocument>();
SvgPath newPath = (SvgPath)newDoc.Children[1].Children[1];
Then I make some changes to the path elements of the deep copied document. For example:
newPath.PathData[1] = new PointF(newPath.PathData[1].End.X - 1000, newPath.PathData[1].End.Y - 1000);
After that, I call Draw
method to get changed png file as a result:
newDoc.Draw().Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"result.png"));
And it works fine:
Then I try to save changed svg, calling Write
method:
newDoc.Write(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"result.svg"));
But I get a svg file without any change as a result
Is it a bug or I do something wrong?
Used Versions
Target framework: .net 6.0
Issue Analytics
- State:
- Created 4 months ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Comment format changing when copying from Word doc... - ...
Solved: Hi, I am using Adobe Acrobat Pro DC version 2019.012.20040 The comments I wanna add are in a different format in a...
Read more >Shallow and deep copy operations
A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original. Two...
Read more >How to override the copy/deepcopy operations for a Python ...
Its not clear from your problem why you need to override these methods, since you don't want to do any customization to the...
Read more >copy in Python (Deep Copy and Shallow Copy)
It means that any changes made to a copy of the object do not reflect in the original object.
Read more >Shallow vs Deep Copying of Python Objects
What's the difference between a shallow and a deep copy of a Python object? Learn how to clone arbitrary objects in Python, including...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a look at this, and there seem to be two problems:
Nodes
of the object, that are not created on adding an element toChildren
DeepCopy
does not check for equal references, so the same object referenced both as a child and as a node will end up as two different objects after the deep copy - updating the nodes will not have the expected effectI think that at least the second one is a bug, and the first one is either a bug, or some missing convienence method, or at least documentation.
Fair point.
Well, the problem happens for other SvgElements too, in this case SvgPath, because Nodes are used for writing documents.