Archive
How to merge multiple PDF documents
To merge multiple PDF documents into one you can use pdftk, the free and versatile PDF toolkit from the command-line or from a batch (.BAT) file.
e.g. to merge a.pdf, b.pdf and c.pdf into result.pdf you’d use:
pdftk a.pdf b.pdf c.pdf cat output result.pdf
Also see the PDF Hacks book webpage for a collection of PDF tools.
Multiple Word documents template-based generator from Excel spreadsheet data (via VBScript/WSH)
The tranXform free transformations software collection has been enhanced with a sitemap generator for websites, called DocGen. Copying its simple usage instructions here:
It’s a script in VBScript used to generate multiple Microsoft Word documents based on templates (.DOC) and Excel spreadsheet (.XLS) data to fill-in
Instructions:
- Add/Edit document templates (.DOC) in Templates folder (put-in tags of any form, e.g. #SURNAME#)
- Add/Edit XLS data in Data folder – each XLS has two columns (a tuple) per row, of the form (TAG, VALUE)
- At the Data folder, drag-drop an XLS file onto MakeDocuments.vbs
- One document is generated for each template at the Output folder, filling-in the data (replacing the tags with respective values) from the spreadsheet file
Requirements: you must have WSH (Windows Scripting Host) installed. If you don’t have it, you can download WSH from Microsoft
(C)opyright 2009 – Zoomicon / George Birbilis
Free to use / give due credit
You can also find a downloads archive at Zoomicon’s Windows Live SkyDrive folder (tranXform is now under the umbrella of Zoomicon.com).
Sitemap generator (using VBScript / Windows Scripting Host)
The tranXform free transformations software collection has been enhanced with a sitemap generator for websites, called SitemapGen. Copying its simple usage instructions here:
It’s a script in VBScript used to generate sitemaps for websites
Instructions:
- Place website in www folder
- Edit MakeSitemap.bat with Notepad to add more file extensions to the list of files that are recorded at the sitemap ("html xml jpg png pdf")
- Double-click MakeSitemap.bat
- Sitemap is generated in www folder (sitemap.html) after recursing all its subfolders
Requirements: you must have WSH (Windows Scripting Host) installed. If you don’t have it, you can download WSH from Microsoft
(C)opyright 2009 – Zoomicon / George Birbilis
Free to use / give due credit
You can also find a downloads archive at Zoomicon’s Windows Live SkyDrive folder (tranXform is now under the umbrella of Zoomicon.com).
Multiple PowerPoint presentations concatenation (using VBScript / Windows Script Host)
My Microsoft PowerPoint presentations concatenation script, called PPTmerge, from the tranXform free transformations software collection has been updated to make the concatenation process less error-prone. Copying its usage instructions here:
Place the .PPT files you want to merge into the "PPTmerge" subfolder and double-click PPTmerge.vbs at the parent folder to launch PowerPoint, have the files merged and the presentation launched for review (the presentation file is named "Merged.ppt" and placed at the parent folder of the "PPTmerge" subfolder [e.g. on the desktop]). To enforce a certain merge order, name the files using an alphanumeric (sortable) prefix, for example "1 – Intro.ppt", "2 – Management.ppt", "3 – R&D.ppt" etc.
To remove the messagebox shown at each merge step comment out the command "MsgBox ff.Name" above, by prepending a ‘ [apostrophe] before MsgBox which will comment out that script line.
If you wish PowerPoint to close right after merging (instead of previewing the merged presentation), remove the ‘ (apostrophe), that is the whole-script-line comment char from the commands "out.Close" and "Application.Quit" and prepend the command "out.SlideShowSettings.Run" with that char (‘). Unfortunately you cannot avoid having PowerPoint application window display while merging, the command "Application.Visible = True" seems to be needed. However you could tell the PowerPoint application to start minimized (use VBA editor [show the respective toolbar at PowerPoint to find it] and press F2 to see the Object Browser, then search for minimized – if you can’t find how to do it just drop me an e-mail)
For the above to work you need PowerPoint installed (tried with Office97, Office2000, OfficeXP and Office2007) and Windows Script Host (pre-installed by default at WinXP and Windows Vista, can get it from
http://msdn2.microsoft.com/en-us/library/ms950396.aspx
)(C)opyright 2009 – Zoomicon / George Birbilis
Free to use / give due credit
You can also find a downloads archive at Zoomicon’s Windows Live SkyDrive folder (tranXform is now under the umbrella of Zoomicon.com).
Multiple Word documents concatenation (using VBScript / Windows Script Host)
The tranXform free transformations software collection has been enhanced with a Microsoft Word documents concatenation script, called DOCmerge. Copying its simple usage instructions here:
Add multiple .DOC (or also .TXT etc.) files at the "docs" folder, named alphabetically in the order you wish them to be concatenated (say add a numeric prefix to their name).
Drag-drop the "docs" folder you wish to merge onto the DOCmerge.vbs file in order to get a Word file with the same name as the folder, but with the suffix "_CONCATENATED".
Important note: page layout of different sections/pages is not respected by the above script, so either fix the page/section formatting by hand (create section breaks where needed and change page layout for those sections you want to layout say horizontally [landscape] instead of vertically [portrait]). Can also try uncommenting "word.Selection.PasteAndFormat wdPasteDefault" by removing the ‘ in front of it and commenting the next line instead, in case that action also copy/pastes page orientation (haven’t tried it and find it unlikely though). Doing that change will render the script non-workable at older Word versions though. To fix this issue a total rewrite of the script is needed to enumerate all sections and copy text per section, also reading and setting the section orientation and whatever other section layout settings from the source file to the target file.
Requirements: you must have Microsoft Office and WSH (Windows Scripting Host) installed. If you don’t have WSH (it’s preinstalled at recent Windows versions), you can download WSH from Microsoft
(C)opyright 2009 – Zoomicon / George Birbilis
Free to use / give due credit
You can also find a downloads archive at Zoomicon’s Windows Live SkyDrive folder (tranXform is now under the umbrella of Zoomicon.com).
Multiple Choice generator (using VBScript / Windows Script Host [WSH])
My tranXform free transformations software collection has been enhanced with a Multiple Choice documents generator script, dubbed MultiChoice. Copying its usage instructions here to get an idea of what it does:
It’s a script in VBScript used to generate exam documents based on multiple choice and free text questions
Instructions:
- Edit document templates at "Templates" folder. Unused test documents are prefixed with "~" char
- Clear output folder from old documents
- Navigate to Data folder
- Edit "OldQuestions.doc" to add any questions used in previous tests that you don’t want to reuse (copy-paste the question text – text formatting isn’t important)
- Edit multiple choice questions spreadsheet at "Data" folder. See existing sample there (mark unused questions with a * at the 1st column and mark correct answers with bold font)
- Edit Generate.vbs with Notepad
- to select how many questions to pick from spreadsheet’s tab A, tab B and tab C
- to select how many shuffled versions of the multiple choice document to generate [one for each student group to avoid them copying from each other])
- to edit the length of the text that is used for spreadsheet questions to compare with old questions (from OldQuestions.doc) to see if it will be ignored
- to select whether a filled-in with answers document will also be generated
- to select whether comments from spreadsheet cells are shown at the generated answers document
- Drag-drop a questions spreadsheet (.xls file) onto the Generate.vbs script (need to have installed Windows Script Host [WSH] – it is preinstalled at recent Windows versions)
This will process all templates (apart the ones prefixed with ~) from "Templates" folder and will pick questions from the spreadsheet tabs to fill them in, ignoring any old questions. Results will be placed in "Output" folder. If you edit the script to generate a filled-in with answers document it will also generate one for each questions document generated.
Requirements: you must have WSH (Windows Scripting Host) installed. If you don’t have it, you can download WSH from Microsoft
(C)opyright 2009 – Zoomicon / George Birbilis
Free to use / give due credit
I recently started moving all my websites under the umbrella of Zoomicon.com, so you can check there now and then for more interesting stuff. You can also find a downloads archive at Zoomicon’s Windows Live SkyDrive folder.
Fixing Windows Update error 800700C1 at Vista
A client (and friend) of mine installed around the start of this August the Service Pack (SP2) for Windows Vista and although it seemed to have installed fine, he realized later on that his laptop wouldn’t install even critical updates anymore (was installing Microsoft Office and some other small updates ok though), with Windows Update returning the error number 0x800700C1 (hex).
Searching on the Internet about this, I found out some people had suggested the following workaround (also suggested by Microsoft, but for the error code 0×80245003):
-
Open a command prompt, or Start menu’s Run dialog by pressing WinKey+R.
-
Type net stop wuauserv and then press ENTER key.
-
Type or copy and paste rmdir /s %windir%\softwaredistribution\wuredir and then press ENTER key.
-
Type or copy and paste net start wuauserv and then press ENTER key.
-
Use Windows Update again to install updates.
So I told him to try this workaround but it didn’t work. After some time passed with this issue still bugging him, I decided to use Remote Assistance to help him. Told him to install Windows Live Messenger and enable "Remote Assistance" connections at My Computer’s properties’ "Remoting" tab. I had him use Messenger’s "Request remote assistance" action – I accepted the support request, then pressed the button to take remote control of his machine (which he accepted from the other side) to see what was exactly the problem.
By the way, here are some useful links on Remote Assistance (some of them write about the older Windows Messenger instead of Windows Live Messenger, but it’s pretty similar):
After some research on the Internet, I decided to use Microsoft Windows System File Checker (SFC) tool, entering the following command at the command-line:
sfc /scannow
When it finished running I noticed a message that it had found corrupt system files but couldn’t repair them. So I examined its log file (at %windir%\logs\CBS\CBS.log), where I noted the following entry near the end of the log:
2009-10-15 20:04:08, Info CSI 000001d7 [SR] Could not reproject corrupted file [ml:520{260},l:46{23}]"\??\C:\Windows\System32"\[l:22{11}]"msdelta.dll"; source file in store is also corrupted
There were also similar entries for the files C_10029.NLS, C_10029.NLS and C_28592.NLS, but the msdelta.dll file was very suspicious since it’s a patching compression engine (calculates and compresses only the different bytes between file versions) used by Windows Update (see Delta Compression Application Programming Interfaces for the patching compressor API).
Searching the Internet I found indeed mention of msdelta.dll file corruption affecting Windows Update, but the workaround for Windows XP mentioned there wasn’t straightforward to apply at Windows Vista:
-
search hard-drive (e.g. using dir msdelta.dll /s 2>nul at the command prompt with 2>nul instructing to not print out any error messages about very long file paths etc.)
-
find all versions of msdelta.dll file
-
replace the one in %windir%/System32 with the most recent of the other found ones
This is because at Windows Vista the msdelta.dll file is owned by the TrustedInstaller account. Luckily Microsoft Support had published instructions on how to troubleshoot corrupted system files on Windows Vista or Windows 7. Using their suggestions I opened an elevated command prompt (to bypass User Access Protection – UAC) and issued the following commands:
-
takeown /f %windir%\system32\msdelta.dll (to take ownership of the file)
-
icacls %windir%\system32\msdelta.dll /GRANT ADMINISTRATORS:F (to grant administrators full access to the file)
-
Then copied the newest msdelta.dll from the ones I had found onto %windir%\system32\msdelta.dll one, using the DOS command copy fromfile tofile (could have also used Windows Explorer too that last step)
-
Opened Windows Update again and all started working fine again!
Needless to say my friend was very relieved, since I had spared him of the trouble to reinstall Windows Vista and all the other applications he was using.
Με την ηλεκτρονική έκδοση του Ενημερωτικού Δελτίου ΤΕΕ προστατεύετε το περιβάλλον
Στην αρχή αυτό δεν ενοχλεί, μετά από λίγο καιρό όμως δεν μπορείς να αποθηκεύσεις/οργανώσεις τόσα περιοδικά. Επίσης ένα μεγάλο μέρος τους αφορά ανακοινώσεις παρατάξεων και αγγελίες που δεν έχει μεγάλη χρησιμότητα να αποθηκεύονται μαζί με τα υπόλοιπα ενίοτε ενδιαφέροντα άρθρα στη βιβλιοθήκη ενός μηχανικού.
Σύμφωνα μάλιστα με το ίδιο το ΤΕΕ το κόστος του περιοδικού αυτού είναι 50 ευρώ λιγότερα για το ταμείο του ΤΕΕ και ένα δένδρο λιγότερο περίπου ανά μηχανικό που το λαμβάνει.
Δεδομένου ότι το Ενημερωτικό Δελτίο είναι πλέον διαθέσιμο σε ψηφιακή μορφή (όλα τα τεύχη από το Σεπτέμβριο του 2003 και μετά) από το σύνδεσμο "Γραφείο Τύπου" στον ιστότοπο του ΤΕΕ, είναι προτιμότερο όλοι οι μηχανικοί να ζητήσουμε από το Μητρώο του ΤΕΕ να μην μας αποστέλεται σε έντυπη μορφή. Απλά στέλνετε ηλεκτρονικό μήνυμα στη διεύθυνση mitroo{παπάκι}central.tee.gr, γράφοντας τα πλήρη στοιχεία σας (ονοματεπώνυμο, πατρώνυμο, αριθμό μητρώου μέλους, ειδικότητα), γνωστοποιώντας ότι δεν επιθυμείτε να λαμβάνετε στο εξής την έντυπη έκδοση του Ε.Δ. (το περίεργο είναι πως θα σας έρθει με το ταχυδρομείο πρωτοκολλημένη επιβεβαίωση από το ΤΕΕ αντί να λάβετε απλά ένα e-mail επιβεβαίωσης).
Παρομοίως, μπορεί να ενημερωθεί το Μητρώο του ΤΕΕ με ηλεκτρονικό μήνυμα και στην περίπτωση που λαμβάνετε πολλαπλά τεύχη του Ε.Δ. (ως φυσικό ή νομικό πρόσωπο) και προαιρετικά να επιλέξετε να λαμβάνετε μόνο ένα (στη διεύθυνση που επιθυμείτε), συμβάλλοντας έτσι στην εξοικονόμηση πόρων χρηματικών και κυρίως περιβαλλοτικών.
Προαιρετικά μπορείτε να εγγραφείτε στις δωρεάν υπηρεσίες του MyTEE (μέσω fax, πληροφορίες δείτε στον ιστότοπο του ΤΕΕ – θα σας αποσταλλούν στοιχεία εισόδου με επιστολή όπου τα στοιχεία θα αναγράφονται στο πίσω μέρος), και να ενεργοποιήσετε στη συνέχεια στις ρυθμίσεις της υπηρεσίας αυτής να σας αποστέλεται μέσω e-mail το Ε.Δ. σε μορφή αρχείου PDF, στο e-mail που χωρηγεί δωρεάν η υπηρεσία αυτή στα μέλη της.
Removing old-style inclusion guards from Visual C++ header files
|
Recent versions of Microsoft Visual C++ compiler support the following directive in C++ header files (.h): #pragma once This is used to prevent their multiple inclusion (prevents multiple definition of symbols and also spurious inclusion loops that could freeze the parser). Before introduction of this directive (the #pragma command allows compilers to introduce compiler-specific features) one would use an inclusion guard of the following pattern in their C++ header files: #if !defined(unique-guard-id) For the unique guard sometimes the .h filename was used in a form like "TEST_H" for a "test.h" C++ header file, or a combination of a GUID (a statistically unique number defined at Microsoft COM, based on OSF DCE’s UUID) and the filename, like "TEST_H_02A4AB75-4421-4dcf-952C-9819A27169C7" Using "#pragma once" results in less noise to anyone reading that source code to understand it and work with it, since the less boilerplate stuff is at the top of a file, the less users have to scroll down to get to the real source code in it. Moreover the header files are faster to parse that way (especially if a solution has a big number of C++ header files). It should be also noted that the VC++ compiler keeps a structure regarding header files that are marked using #pragma once, so the parser doesn’t bother to open them again if they’re included more than once. That isn’t the case obviously with the low efficiency old-style inclusion guards, which result in the parser opening the header file multiple-times and parsing it from start to end just to skip all of its inner content all times apart the first time it is parsed. You might also see the following even more verbose and overkill pattern at some C++ header files: #if _MSC_VER > 1000 #pragma once |
After the replace operation though you have to remove manually the #endif symbols at the end of the .h files where the replace operation was performed (that’s why I left the "Keep modified files open after Replace All" option checked). Just visit each file tab (pressing CTRL+TAB once quickly), then press CTRL+End to go to the file’s last line and then CTRL+L to delete that line (the #endif that is). No need to press CTRL+S to save the file or CTRL+F4 to close it, can work on all the open files and then use "Save All" and "Close All" menu actions. Could also use the more powerful "Regular Expressions" mode to also remove the #endif automatically, but one would have to use find groups and match the whole inner text of the header file at the find string to then use it at the replace string and I’m not sure how big strings it can handle (probably it can handle it fine but don’t want to risk truncating your header files after a certain length, do you?). Else, if the "Look in" field had an option to look in all open files and Microsoft supported a regular expression symbol for the virtual EOF (End-Of-File) mark, then one could do a 2nd pass instead to replace those #endif symbols at the end of only the open files (assuming you had closed all other files before doing the 1st pass, then all open files after the 1st pass would be the ones were a replacement has been done during that pass). |
Replacing multi-line text in Visual Studio solutions
|
I was editing a Visual C++ project of Flight Sim Labs recently and came across conditional defines of the following form at many of their C++ header files: #if _MSC_VER > 1000 That would be obviously faster to parse (taking in mind that the solution had a big number of C++ header files) and would result in less noise to anyone reading that source code to understand it and work with it, if it was converted to a simpler form: #pragma once Having less clutter at the top of a source code file frees the programmer from having to scroll down a lot after opening the file to examine or work with it. Having a big number of header files though meant that I had to find some way to replace all that automatically through out the solution. So I used the powerful "Replace in Files" action from Visual Studio’s Edit menu, using the intuitive "Wildcards" mode with the settings shown at the side-image. Note the \# and \n to escape the special # char and to define line change respectively. Could also have used "Regular Expression" mode, but would need a different and a bit non-intuitive syntax for the search string (but this is more a matter of taste I guess). To avoid having lots of open file tabs after the "Replace All" operation, I unchecked the option "Keep modified files open after Replace All". This results in the IDE doing the replace and saving the changed file without keeping the file open in a "dirty" state for you to save. |
|