File format of spool files with .tmp extensions? - printing

In many Windows setups, when you print directly to a printer, two files are typically created in the windows spool directory "C:\Windows\System32\spool\PRINTERS". A spool file "80021.SPL" and a shadow file "80021.SHD" are examples of these files. The spool file contains the meat and potatoes of the drawing instructions so the printer can print the page. The data in this spool file comes in a smorgasbord of different formats depending on the language technology and the print driver used. However, when you are printing to a printer that's on a print server, a single ".TMP" file is created instead and gets transmitted to the print server. I think its fair to assume that this is just the .SHD and .SPL files combined into a single transport file to get it to the server. However, its unreadable, i'm nto sure if its zipped, encrypted, or what, but I can't decipher it. When printing PDFs you can typically see plain text PostScript instructions in the spool file (.SPL), by just opening it and viewing it in a text editor. You can even send that spool file (.SPL) to a postscript viewer like GhostScript and have it show you the pages drawn on screen. But when the job is all packaged up in a .TMP file, its basically just a binary pile of bits. Does anyone know how to uncompress the data from these transport .TMP spool files?

I believe that file you have will be an EMF file that is padded with a proprietary MS structure at the beginning. Easiest way to find out if you are dealing with an EMF structure is to look for the ANSI characters ' EMF' in tmp file you have.
Assuming that you do find these characters it is just a matter of removing the proprietary structure data from the beginning of the file then treating it as a standard EMF file. Fortunately all EMF files have a standard header format so it should be reasonably to determine where the EMF file starts.
There is a good description of EMF file headers here

Related

How to find out if a program accepts as parameters just a file or a list of files?

I would like to write some code in Delphi for opening some files (e.g. mp3, png) with the associated program in Windows.
With AssocQueryString, I can find the program for a given extension.
With this program, I can start the given file, when only one file was selected.
The problem is when I try to start the program with a list of files.
Example 1 - mp3 is associated with AIMP3 and this call works fine
D:\Tools\AIMP3\AIMP3.exe "F:\TestFiles\mp3\file1.mp3" "F:\TestFiles\mp3\file2.mp3"
Example 2 - png is associated with IrfanView and this call fail
D:\Tools\IrfanView\i_view32.exe "F:\TestFiles\png\file1.png" "F:\TestFiles\png\file2.png"
IrfanView does not accept calling it with a list of files, but only with one file.
My question is, how do I find out if a program accepts as parameters just a single file or a list of files?
I have tried to check the Registry but found nothing. In shell->open->command I can find "%1" for both programs.
I have tried to use the IDropTarget interface, but this does not work with IrfanView, either (drop multiple files on i_view32.exe doesn't work in Windows Explorer, either).
On the other hand, Windows Explorer (if using Open from the context menu for many png files) opens a new instance of IrfanView for each file. If I had this information, I could also start IrfanView for each file.

LPR: what is the location of the file that will be sent to the printer?

For a research project about printing nanofluids I need some more control over my Epson Stylus SX600FW.
I am sending a file to the printer using lpr test.ps, then it is in the print queue. Now I want to see the file (in pdl?) that the printer driver will send to the printer. Where is the temp storage location of this file?
Or is there any other way to obtain this file? This file should contain ESC/P-R sequences in which I want to make some changes and then send that file to the printer.
Using the URI file:/tmp/ouput.prn, and by configuring it with the (gimpprint) driver of your printer, you can obtain the output that is being sent to the printer.
This is a hexadecimal file. Using the parse-escp2 perl script from the test directory of gimp-print you can view this file in a bit more understandable format.

Why are Notepad++/Netbeans/Sublime displaying suddenly an empty line between two lines in my PHP files?

So for a while now almost every file I open (html/css/php) has two line-breaks instead of just one. I attached a screenshot of my Notepad++ where you can see what is happening. If I open these files in Notepad they show like they should. However Notepad++/Netbeans/Sublime all leave me hanging. Any ideas?
http://snag.gy/6aLrI.jpg
There are 3 types of line terminators for text files:
Carriage return (0x0D) + line-feed (0x0A) for DOS/Windows text files.
Only line-feed (LF) for UNIX text files.
Only carriage return (CR) for MAC text files (prior OS X).
See also Wikipedia article about newline.
The preferred line terminator type on UNIX web servers is LF only, but most text files for web sites are edited on Windows. Therefore all FTP clients have the option to transfer text files either as ASCII or as binary.
Option ASCII means the FTP client inserts CR before each LF in file on downloading a text file from server. And each CR before LF is removed on uploading a text file to the server. So a text file stored on UNIX web server with just LF is converted on download to DOS/Windows and converted back on upload to UNIX. The binary transfer mode results in downloading/uploading the files without any modification by the FTP client.
In your screenshot I see in status bar at bottom Macintosh which is an indication that the file is handled as a MAC text file. The reason is most likely that on server the *.php files are stored already with DOS/Windows line terminators (CR+LF) and on download nevertheless the ASCII transfer mode is used resulting in text files having CR+CR+LF. The text editors now do not know how to correct handle those text files - as MAC files with an invalid LF or as DOS files with an invalid CR. Your text editors interpret the files as MAC files with invalid LF and therefore a newline for first CR and another one for CR+LF.
Solutions:
Select binary transfer mode in your FTP client to download/upload the DOS/Windows text files without any further modification by FTP client, or
search for \r\r\n on downloaded files and replace all occurrences with \r\n to get finally DOS/Windows text files on local disc and UNIX files on web server after upload.

How to ensure that a file is correctly written to file system?

I hava an application that reads a file from a ZIP archive and saves it to file on file system. After writing it to file system I start start immediately to read this file with a SAX2 reader. On bigger files (300+ MB) it sometimes occures, that SAX2 stops parsing because of an unclosed tag. But when I check the file (or even try to read it again later) it works, so the file it self it OK.
FZipKit.ExtractToStream(LFileName, LStream);
LStream.SaveToFile(OutputFilename);
SAX2.processUrl(OutputFilename);
My assumption is, that the file was not yet fully written to file system when I started the parsing process.
Is there a way to ensure, that the file was written or the steam has been flushed to file system?
thx
I'm going to first of all assume that the XML parser operates correctly. If it is incapable of reading files, well the solution is obvious.
Which leads us to look at how the file is created. When you call SaveToFile, the file is opened, written, closed and buffers are flushed. In a plain vanilla system, your XML parser will see the entire content of the file. The only conclusion is that something is interfering. The most like suspect is your virus scanner. Many scanners, even the most respected ones, cannot properly handle a file being closed and then immediately re-opened.
The bottom line is that your code is fine and the problem almost certainly lies with your local environment.

Download Directory and Contents

Is it possible to persuade the stream result to download an entire directory and it's contents? And if so, how? I've no problem getting it to download individual files, but I have a need to download a series of files that must be in a specific directory structure.
I don't think so.
Stream result allow you to download ONE content, with its MIME type, its name, etc.
This makes it impossible to work with a lot of files, with different names and content type.
What you can do is:
Render in a JSP the list of files (in anchor tags for example), everyone targeting the Action that will download that single file;
Call multiple Actions via scripting opening multiple pages (target="_blank") for every file you have (dangerous, annoying, almost useless...);
Create a zip with Java in server side, containing all your files and directories, then output the zip with Stream result.
I think you may consider the third option.

Resources