Can ExportString export EMF or GIF? In this demo, streamoutput.emf is somehow distorted:
Quiet[DeleteFile["C:\\Temp\\thisworks.emf"]]; Quiet[DeleteFile["C:\\Temp\\streamoutput.emf"]]; graphic = Graphics[{Thick, Red, Circle[{#, 0}] & /@ Range[4], Black, Dashed, Line[{{0, 0}, {5, 0}}]}]; Export["C:\\Temp\\thisworks.emf", graphic, "EMF"]; file = ExportString[graphic, "EMF"]; stream = OpenWrite["C:\\Temp\\streamoutput.emf", BinaryFormat -> True]; Write[stream, file]; Close[stream];
If ExportString worked, I could use it to transfer EMF via NETLink, for example.
kernel.Compute("ExportString[Graphics[Rectangle[]], \"EMF\"]"); File.WriteAllText("C:\\Temp\\output.emf", kernel.Result.ToString());
Adding
Got it.
kernel.Compute("ExportString[Graphics[Rectangle[]],{\"Base64\",\"EMF\"}]"); byte[] decodedBytes = Convert.FromBase64String(kernel.Result.ToString()); File.WriteAllBytes("C:\\Temp\\output.emf", decodedBytes);
source share