Re: SVG Extracted to clip or png

2020-02-28 Thread John J Foster via 4D_Tech
Hi Keith,

Thank you.

I’ll take a look at that as I suspect the underlying code must be similar to 
what Peter suggested.

Not sure how I missed seeing that?

I did review the docs.

Funny,
John…


> Try using SVG_Add_object ($svgOtherDocRef;$groupRef) to get the group into 
> the other svg document.
> 
> Keith - CDI

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: SVG Extracted to clip or png

2020-02-28 Thread John J Foster via 4D_Tech
Hi Peter,

I think what might work best is to create a “starter” SVG object with all the 
 contained within. I’ll save it to disk and load as needed.

Then when I extract the  I’ll insert the  into that sag doc and it should 
work.

In this case I have over 120 glyphs (sag images) that I preload and convert 
into base 64 that are part of the 

Then I reuse as needed.

Anyway, I’ll have to play with these very good ideas you suggested and see how 
far I get. No play time until early next week.

Appreciate,
John…


> 
> Hi Peter,
> 
> Ah yes thanks, I tend to forget that an SVG doc is in XML format.
> 
> Sometimes the solution winds up being so simple in 4D.
> 
> If the SVG doc uses  for displaying various glyphs in the  object I 
> would assume that I need to also bring those into the doc?
> 
> 
> Yes, then you need to handle that as well. What I do is parse properties of 
> objects that are copied - like "mask", "fill" or "clip-path" properties - if 
> they contain "url(id)" value,  and if 'url' is used, I 1. find defs element 
> with given id, 2. move it to target as well and 3. change id of defs and 
> value of url to new, unique value (alternatively you could check if defs with 
> given 'id' was already moved and not move it.)
> 
> If you have control over how are SVG generated, you can make sure that defs 
> are included within the same group, and make sure all defs have unique id's. 
> Then you just copy the group. I did not have control over SVG, so had to use 
> more complex approach.
> 
> Peter Bozek
> 
> Appreciate,
> John…
> 
> 
> > Just use a XML commands and copy the node to another SVG files. AS SVG 
> > files are XML documents, you can use any XML DOM commands to manipulate SVG 
> > files.
> > 
> > Something like 
> > $group:=DOM Find XML element by ID(oldSVGImage;$groupID)
> > If (OK=1)
> >   $newEl:=DOM Append XML element(newSVGImage;$group)
> > end if
> > 
> > Peter Bozek
> > 
> > On Fri, Feb 28, 2020 at 5:08 PM John J Foster via 4D_Tech 
> > <4d_tech@lists.4d.com  
> > >> wrote:
> > Hi All,
> > 
> > I have an SVG Doc which contains many  grouped objects. Each group has a 
> > unique ID (name).
> > 
> > Sometimes I’d like to click on a part of the document, corresponding to a 
> > grouped object, and have it sent to the clipboard or saved as a png. Just 
> > the part of the document clicked on.
> > 
> > Is there a technique to easily extract a  object into it’s own SVG doc 
> > so I can save just the selected group as an png?
> > 
> > Yes, I could redraw each object that was selected but like to save that 
> > time if it’s possible.
> > 
> > Thanks,
> > John…
> 

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: SVG Extracted to clip or png

2020-02-28 Thread Peter Bozek via 4D_Tech
On Fri, Feb 28, 2020 at 5:50 PM John J Foster via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi Peter,
>
> Ah yes thanks, I tend to forget that an SVG doc is in XML format.
>
> Sometimes the solution winds up being so simple in 4D.
>
> If the SVG doc uses  for displaying various glyphs in the  object
> I would assume that I need to also bring those into the doc?
>
>
Yes, then you need to handle that as well. What I do is parse properties of
objects that are copied - like "mask", "fill" or "clip-path" properties -
if they contain "url(id)" value,  and if 'url' is used, I 1. find defs
element with given id, 2. move it to target as well and 3. change id of
defs and value of url to new, unique value (alternatively you could check
if defs with given 'id' was already moved and not move it.)

If you have control over how are SVG generated, you can make sure that defs
are included within the same group, and make sure all defs have unique
id's. Then you just copy the group. I did not have control over SVG, so had
to use more complex approach.

Peter Bozek

Appreciate,
> John…
>
>
> > Just use a XML commands and copy the node to another SVG files. AS SVG
> files are XML documents, you can use any XML DOM commands to manipulate SVG
> files.
> >
> > Something like
> > $group:=DOM Find XML element by ID(oldSVGImage;$groupID)
> > If (OK=1)
> >   $newEl:=DOM Append XML element(newSVGImage;$group)
> > end if
> >
> > Peter Bozek
> >
> > On Fri, Feb 28, 2020 at 5:08 PM John J Foster via 4D_Tech <
> 4d_tech@lists.4d.com > wrote:
> > Hi All,
> >
> > I have an SVG Doc which contains many  grouped objects. Each group
> has a unique ID (name).
> >
> > Sometimes I’d like to click on a part of the document, corresponding to
> a grouped object, and have it sent to the clipboard or saved as a png. Just
> the part of the document clicked on.
> >
> > Is there a technique to easily extract a  object into it’s own SVG
> doc so I can save just the selected group as an png?
> >
> > Yes, I could redraw each object that was selected but like to save that
> time if it’s possible.
> >
> > Thanks,
> > John…
>
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: SVG Extracted to clip or png

2020-02-28 Thread John J Foster via 4D_Tech
Hi Peter,

Ah yes thanks, I tend to forget that an SVG doc is in XML format.

Sometimes the solution winds up being so simple in 4D.

If the SVG doc uses  for displaying various glyphs in the  object I 
would assume that I need to also bring those into the doc?

Appreciate,
John…


> Just use a XML commands and copy the node to another SVG files. AS SVG files 
> are XML documents, you can use any XML DOM commands to manipulate SVG files.
> 
> Something like 
> $group:=DOM Find XML element by ID(oldSVGImage;$groupID)
> If (OK=1)
>   $newEl:=DOM Append XML element(newSVGImage;$group)
> end if
> 
> Peter Bozek
> 
> On Fri, Feb 28, 2020 at 5:08 PM John J Foster via 4D_Tech 
> <4d_tech@lists.4d.com > wrote:
> Hi All,
> 
> I have an SVG Doc which contains many  grouped objects. Each group has a 
> unique ID (name).
> 
> Sometimes I’d like to click on a part of the document, corresponding to a 
> grouped object, and have it sent to the clipboard or saved as a png. Just the 
> part of the document clicked on.
> 
> Is there a technique to easily extract a  object into it’s own SVG doc so 
> I can save just the selected group as an png?
> 
> Yes, I could redraw each object that was selected but like to save that time 
> if it’s possible.
> 
> Thanks,
> John…

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**