Fixing EPS Files Corrupted by Being E-Mailed

by Andrew Barber 25. April 2010 22:44

If someone is sending you any Encapsulated PostScript (EPS) files via e-mail, I'd definitely recommend that they be sent in some form of an archive. Not only is the compression likely to be useful, but it can also prevent them from being corrupted. EPS files are basically plain text, with some blocks of encoded byte values mixed in. For what ever reason, the process of e-mailing these documents can corrupt them; adding garbage to the beginning and/or end of the file. Perhaps it happens while being encoded/decoded by e-mail clients, or maybe in the process of being scanned for viruses. It does not happen to everyone, though... if it happens to you, and you can't get your source to quickly send you a replacement, here's a way to try to fix the file yourself.

Garbage Before the 
valid parts of the file (Notepad++)First, be sure you have a backup of the file. Of course! Open the EPS file in a text editor. It should appear to start with some neatly ordered lines similar to this:

%!PS-Adobe-3.1 EPSF-3.0
%ADO_DSC_Encoding: MacOS Roman
%%Title: File-Title.eps
%%Creator: Adobe Illustrator(R) 13.0
%%For: Andrew Barber
%%CreationDate: 4/26/10
%%BoundingBox: 0 0 143 57
%%HiResBoundingBox: 0 0 142.4434 56.6699
%%CropBox: 0 0 142.4434 56.6699
...snip...

If you do not see anything like the above toward the beginning of the file, stop right now; something else is probably going on, and this procedure won't help you. However, what you may see is a line or two of apparent garbage preceding the "%!PS-Adobe-3.1 EPSF-3.0" line. The garbage might be on the same line as that correct starting line, so you may need to scroll to the right to find it. Delete all of the garbage before the percent sign.

Garbage after the valid end of the file (Notepad++)Next, scroll down to the end of the file. You will see lots of code lines, likely some encoded blocks of binary data - but it should all be well formatted either as code or blocks of data. The very last line of the file should read %AI9_PrivateDataEnd, followed by a single line break. However, you might again see garbage starting on that line after. Delete all the garbage at the end, but leave that single empty line after the %AI9_PrivateDataEnd.

Hopefully that should do it; save the file, and try to load it again.

Random Stuff Learned/Remembered Lately

by Andrew Barber 4. April 2010 20:47

I have a bad habit of wanting to post something of a certain size and weight before I post anything at all. The end result? I don't post anything! As the beginnings of an attempt to break this habit, I offer some almost entirely unrelated items I have come across lately. The top two items are from some recent adventures in Linux administration, while the last one is a really dumb one with an ASP.NET app.

Paranoid hosts.deny Can Trip You Up

One of my Debian-based firewall servers had the 'paranoid' option set in its /etc/hosts.deny file. The purpose of this option is to block access to any remote host where the host name does not match the address. I imagine it would work by pulling a PTR record from the IP, and then querying the resulting host name to see if it matches back to the IP again.

That system has had that setting for quite some time now, and it never caused me any trouble. Every connection I have apparently used in that time has had its DNS settings properly set. But I recently used a connection at a partner's office, which was provided through a small, local cable company. Hair-pulling ensued; While I had no trouble accessing the services on the systems behind the firewall, I could not connect to the SSH or VPN services provided by the firewall itself. Packet sniffing showed there were packets going back and forth. As I recall (it's been a few weeks now), something in syslog prompted me to think of hosts.deny;

I don't know how prevalent it is that ISPs will have improperly setup PTR records, but it's something to keep in mind.

I Was Creating a New Grub menu.lst Every Kernel Upgrade!

On another Debian-based firewall system I have, I kept a backup copy of Grub's menu.lst file to restore over the automatically generated one every time I did a kernel upgrade. This is a big-time case of "RTFM!" The reason I was doing it has to do with the perculiarities of the hard drive subsystem on the motherboard in question, requiring me to need to use the IDs of the drives.

But if I had simply read the comments in menu.lst, or read the man page, I would have known I had two options: 1) add special entries before/after the 'AUTOMAGIC KERNELS LIST' section or, more appropos for my situation 2) edit the default options within that section. The default menu.lst file comes with comments that describe the process quite well; the key lines are commented by a single hash (#), and that hash must remain there. When configuration of a new kernel is done, the defaults entered there are used. I was actually considering replacing this server with another one due to this issue, when all it took was literally a 30-second fix.

Don't Forget That Global.asax File!

Okay, you say, what kind of silly advice is that? Who would forget to upload one of the files of a web site? And wouldn't it be obvious when it happened? Of course, ASP.NET folks know that Global.asax is a special file. It's not a page that you load (requests for it are specifically denied by IIS by default, in fact), but it is frequently a vital file. Application-level code runs - or does not run - based on it.

I almost always use Code-Behinds in ASP.NET, where the 'web site files' (including Global.asax) merely contain markup, and then names of the compiled program objects from which they are to derive - those objects having been programmed via the 'code-behind' files, which are pure C# code, in my case. Even though all the code is compiled in an assembly, the web files are still needed (without some other special circumstances); The layout/design and markup code is still in the ASPX files - you will get the standard "File Not Found" error if such a file was not uploaded.

But the Global.asax is a special case. If it does not exist, the result is simply that no application-level code is run. This should seem obvious, but without the Global.asax being present in the web directory, the ASP.NET runtime has no way of knowing what, if any, HttpApplication-derived object that may or may not be in your code should run. You could derive a dozen such objects and compile them in your assembly. You may have compiled only one, but you don't want it used. My point is, the Global.asax file and the markup contained therein is the way that the runtime knows what you intended.

In my case, this oversight was the reason on my development system, a global variable set in Application_Start was valid, but on the staging server it was NULL.

Add/Remove Programs Cleaner Rescues (Kills!) Orphans

by Andrew Barber 13. November 2009 00:34

Sometimes a software uninstall might not complete fully on a Windows system, and you'll be left with an entry in Add/Remove Programs, even though the program files are no longer present. Attempting to remove the program from that list again sometimes will generate an error, and the entry will not be removed, leaving you with an annoying orphan. IntelliAdmin has a freeware program called Add/Remove Programs Cleaner (link) which removes entries from that list.

Important Note: This tool does not do anything toward actually uninstalling a program's files, shortcuts, or registry or profile data. It only removes the item in the Add/Remove Programs list, and it should only be used on a program which you know has been uninstalled, but which Windows won't remove from the list when you try via the normal means.

The Cleaner works on Windows NT, 2000, XP, 2003, 2008 and Vista, and may work on Windows 7; I believe it does not work on Windows 98 (seriously, you aren't still using that, are you?) It does not require an installation; it is simply a single executable file that you run.

SQL Server Won't Start Up Automatically

by Andrew Barber 11. November 2009 08:30

I've had a recurring issue with a client's web server and the local installed instance of SQL Server 2005 Express, in this case, but this issue applies to all versions of 2005 and 2008. The behavior was that the service would fail to start automatically once the system was rebooted, but once I connected via the RRAS VPN and then Terminal Services for remote management, the service would start up just fine. The Windows Event Log had the following SQL Server error messages, immediately back-to-back in order (SQL Server itself has the same messages in its own logs):

- Server failed to listen on x.x.x.x <ipv4> xxxxx. Error: 0x2741. To proceed, notify your system administrator.
- TDSSNIClient initialization failed with error 0x2741, status code 0xa.
- TDSSNIClient initialization failed with error 0x2741, status code 0x1.
- Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
- SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.

The server was configured to listen on only certain IP addresses, on port xxxxx. 127.0.0.1 was the primary address for the local web sites to use, and x.x.x.x was the private IP address assigned to the RRAS server; this was for remote management of the SQL Server via the VPN connection. Hopefully your light bulb is going off over your head more quickly than it did mine!

More...

Breaking Visual Studio 2008 Intellisense for Fun and Profit

by Andrew Barber 17. September 2009 17:47

So, I can get pretty aggravated by the most simple things!

I was doing some coding in Visual Studio 2008, and suddenly found that Intellisense was not working on the StreamReader object instance I was coding. I verified that I had declared the object correctly; It was a very small and simple bit of code which read a text file line-by-line. Not only that, the code compiled and worked.

When you frequently code in VS, the Intellisense popup can become like an old friend. It pops up and disappears constantly as you type code. Even when you don't need it to know what members an object has, its constant flicker lets you know you are doing OK.

This is the code I was working with:

More...

Something More Obscure Than it Seems it Should Be

by Andrew Barber 16. December 2008 20:15

I came across a somewhat obscure issue that, it seems, really should not be so obscure. I am working on an application that will be used to display rotating videos, a 'ticker' and rotating graphics in lobbies/waiting areas, on the client's hardware. I am using Windows Forms 2.0, DirectX 10 to display the videos, and a simple WinForms PictureBox control to display the graphic images. My intent was that the 1.0 version of the program would no longer use the PictureBox in order to support animated GIFs to be among the graphic items. My prior experience was that simply using a PictureBox.Image property would not properly display an animated GIF, but only show the first frame.

So, I read somewhere that with WinForms 2.0, that was no longer the case. So, I figured I'd try one out before going too far. I put an AniGif in the rotation, and it loads up. I wait the 5-seconds I know this particular GIF has until frame 2 comes up, and, lo and behold, an uncatchable exception: A generic error occurred in GDI+

Taking a peek at the stack trace from the exception, I find that there are, in fact, WinForms methods being called on my behalf at the appropriate time, trying to display the next frame of the image. But they are not working. "Generic Error" and all. How helpful...

More...

Why Eels?

No one can really be certain. But those slimey underwater critters obviously have something going for them!

Links/Profile

Andrew Barber's Profiles:
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent the views of employees, contractors or clients of Inkwell Creative Group, LLC in any way.

© Copyright 2008, 2009 Andrew Barber