This SVG is invalid. Validate it before opening - svg

I just modified a svg file that came with my Wordpress Template but i come up to this: Error Line 787, Column 77: there is no attribute "sketch:type"
<g id="city-copy" transform="translate(1305.000000, 47.000000)" sketch:type="MSShapeGroup">

Open the svg in a text editor and remove the sketch:type="MSShapeGroup" attribute from the <g> element. An even better maneuver would be to optimize your svg with a tool like svgo.

Check the encoding value.
I changed the encoding="windows-1252" to encoding="utf-8" and worked for me.

This can be caused by a variety of things but I've been able to solve this by:
open the SVG in Inkscape
Go To File > Clean Up Document
Save the SVG (choose a unique file name so you do not lose your previous work).

guys! I saw this tip on another forum, and it worked. I managed to fix the corrupted file. What you have to do is:
Open the file in a text-editor (I used Dreawweaver)
Check the first line for entries like: xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;", and delete the '&' characters so it reads: xmlns:x="ns_extend;" xmlns:i="ns_ai;" xmlns:graph="ns_graphs;"
Save the file, and Illustrator will open it.
Good luck!

Thanks much for the how-to principle. In my situation, using that idea (of opening the corrupted SVG file with a text editor since Adobe Illustrator wouldn't open the file), I used a text editor (Smultron) to open both the corrupted SVG file and an openable SVG file. I compared the upper area of both files; saw that certain lines of code were missing from the corrupted SVG file; copied those few extra lines of code from the openable (working) SVG; and saved. AI could then open the formerly corrupted SVG file. I copied the layers I needed into a new AI file and abandoned the formerly corrupted SVG.

AI version CS7 is saving invalid SVG and SVGZ files. In my case, two namespaces were missing from the SVG file.
Use the Export to SVG instead. It save the SVG without the need for namespaces.

I had similar problems with svg files that I had saved in Adobe Illustrator. The easy fix for me was to open the files in Inkscape and save a copy, and these files are fine.
The original error message said "The SVG file is invalid. Validate it before opening." The ironic thing is that after saving a copy with a new name, the original files will now open inĀ  Illustrator.

As a complete non-techy, I followed the advice above and opened my SVG in text editor. None of the problems above were in my file so I compared the file to a working SVG file, trialed a few things and discovered that
" 0 0 no-repeat
at the very end of the code outside of the tag was the culprit! Deleted this and voila! :-)

Wow, so many different answers! Might as well add my own... This is handled the error in Adobe Illustrator when opening a file downloaded from the internet, might work in other scenarios as well.
I opened the svg in a text editor and noticed that the XML prolog at the beginning did not match a different, working, file. Specifically the non-working one was version 1.1 and did not include the standalone="no" attribute. So the fixed prolog now reads:
<?xml version="1.0" encoding="UTF-8" standalone="no">
Worked for me!

After opening my svg in a code/text editor, in my case Visual Studio Code I noticed that mine had <DIV id="container"> and </DIV> surrounding the <svg..... > data.
Removing this div tag solved my issue.

I stumbled on another easy fix by luck: I was about to open an SVG in a text editor, when I noticed that OSX was defaulting SVGs to ImageOptim, an app I use for stripping metadata, etc. So I let that have the file, and a moment later I had a valid SVG file that took up 68% less space on disk.

I had a similar problem, which was not solved by any of the above mentioned solutions. In the end I solved it by unchecking the box 'Export RDF metadata' when creating the SVG file (in QGIS in this case).
Most likely something in the RDF metadata must have been unreadable for Illustrator, but I didn't manage to figure out what part exactly.

Related

Why won't my .stl file show the correct information in a text editor?

I am quite new to work working with .stl files and in my research, I found they can be opened in a text editor where faces and vertices were clearly written out and easy to read. However, whenever I download a .stl file and open it with a text editor, I get a series of random characters. The same thing happens when I take a .blend file and export it to a .stl file. In spite of this, the .stl files still render correctly. I have attached a picture of what my problem looks like. If anyone could help me out, I would appreciate it.
Thanks.
The random characters when I open .stl files in a text editor.

How to convert vector image files to SVG with inkscape, when I don't know the extension

TL;DR: Is there a way to tell Inkscape on the command line, what the file extension is of the parameter --file=?
I have a case where I have to convert vector image files to SVG, using Inkscape command line tool. Current code is targeted at PDFs, so the following works fine:
inkscape --without-gui --file=source_file.pdf --export-plain-svg=result_file.svg
My problem is that I have to apply the same to new files, that are stored without extension, so my command would look like this:
inkscape --without-gui --file=some_stored_file --export-plain-svg=result_file.svg
When I run this command I get an error: "Specified document some_stored_file cannot be opened (does not exist or not a valid SVG file)"
I think this happens because the file doesn't have an extension and Inkscape can't guess the format.
What I can do is: get the format somewhere else, copy the stored file to a temp file with extension (some_temp_file.pdf) and then convert that to SVG, then remove the new temp file.
While this works fine, I would skip the otherwise unnecessary file copying just to have an extension.
Is there a way to tell Inkscape what the file extension is, other than having a file extension explicitely?
Well, I didn't found an answer to my question so what I did is symlinking the file (instead of copying), adding the extension on the symlink. Still better than copying the file and works fine.

How to add ton of text (using TextView) to content (Android studio)?

I'm just started to programming in android studio and need to add a ton of text, but if I just paste all the text in the text field of the TextView component, then I get a mess. Tried to insert in the code of .xml, correcting paragraphs, but all the same it turns out not that. Therefore, several questions arose:
What is the most correct way to add a ton of text to the content? (Please refer to the details)
How can I make the text inserted correctly, with paragraphs, etc.? (Ie so that they are observed)?
All of this question's about ton of text.
Thank you very much in advance!
You can add all your text in a .doc file, format it in the way you want, then in your code, you load this file and output it to your TextView.
You need to make sure you import this file as an asset in your project or either load it from the device storage.
Please check this SO post: How to read .doc file?
And check this to see How to import file to assets

Inkscape doesn't allow to edit svg text lines once it has been saved as plain svg or treated with scour

I was for several days trying to find a solution to the following problem :
Create a svg with text (simply click with the text tool to add text, do not drag to open a frame)
Type enter to create a multiline text, add several lines of text
Save as plain svg or optimized svg
Or treat with scour in command-line
Reopen with Inkscape : you cannot edit the text, it shows it properly but when you go to the next line (with the mouse or keyboard arrow down) the cursor stays on the first line.
This is an annoying bug running for some time in Inkscape and doesn't help with web edition.
But there are solutions... See the following thread to manually (in vim) replace all tspans :
Vim search replace regex + incremental function
And see my answer below to correct the svg code in order to get your Inkscape files back in working order !!!
SVG files do not currently support multi-line text. Inkscape uses custom XML attributes to keep track of which spans of text are part of that block of text.
When you save as Optimized SVG, Inkscape strips out all its custom XML attributes and writes a vanilla SVG file. So the sense of what is a block of text is gone.
Sed is very useful in order to correct your files in a batch:
cd /home/user/my/svg/files
sed -i.bak 's|<svg|<svg\nxmlns:xlink="http://www.w3.org/1999/xlink"\nxmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"|g' *.svg
This runs on all svg files in the current folder and :
Creates a .bak file which you can rename to svg in order to get your original files (but I nevertheless strongly advocate to duplicate your working folder in order to avoid terrible mistakes when fiddling with sed)
Adds the correct namespaces with newlines (\n)
Then:
sed -i.2.bak 's|<tspan|<tspan sodipodi:role="line" |g' *.svg
This appends sodipodi:role="line" to all tspan tags in the current folder and creates file.2.bak backups.

why am I losing content when I convert a file from .ps to .svg

I need icons for a site I'm having developed, and therefore I need .svg files. I have a .psd file that I save as a .ps file. I then attempt to use cloudconvert.org to convert the .ps file to .svg. The problem is that it fails to capture the whole image -- only leaving about 40% of the original. What can I do??
Assuming you have the Adobe suite, you can use Photoshop to File - > Export-> Paths to Illustrator,
save as a .ai file and then save it as an svg from illustrator without losing quality.
Hope this helps
EDIT: you can download a trial version of illustrator for free for 30 days form the adobe website

Resources