Creating a PDF from a list of JPG image files

Here is a Perl script that creates a PDF from list of JPG images. This script uses the PDF::FromImage CPAN module.

#!/usr/bin/env perl
# Perl Script to create a PDF file from a sorted list of JPG images
# This script uses the PDF::FromImage module.
#
# To install PDF::FromImage module on Windows with Strawberry Perl
# execute the following commands in a Command Shell
# The following command assumes Strawberry Perl in PATH
# c:\> perl -MCPAN -e shell
# c:\> install PDF::FromImage;
#
# This script assumes there is a list of 300 JPG images with names 
# in the CURRENT_DIRECTORY in acsending order.
# E.g. fileprefix_1.jpg, fileprefix_2.jpg, fileprefix_3.jpg ...
#
#
# Steps to use the script:
# 1. Save this script as make_pdf.pl in the directory where you have
# the JPG images
# 2. Install the Perl Module
# 3. Edit the script modify as per requirement
# 4. run the script from commandline.
#
use strict;
use PDF::FromImage;
my ($prefix, $pdfname, @files)
# Enter a prefix for your image files
$prefix = 'file_prefix';

# Enter the PDF name without the ".pdf" extension
$pdfname = 'my_pdf_name';

for (my $i=1; $i load_images(@files);
$p->write_file($pdfname . '.pdf');

Perl Script to create a PDF file from a sorted list of JPG images. This script uses the PDF::FromImage module.

To install PDF::FromImage module on Windows with Strawberry Perl
execute the following commands in a Command Shell. The following command assumes Strawberry Perl in PATH

c:\> perl -MCPAN -e shell
c:\> install PDF::FromImage;

This script assumes there is a list of 300 JPG images with names in the CURRENT_DIRECTORY in ascending order.

E.g. fileprefix_1.jpg, fileprefix_2.jpg, fileprefix_3.jpg …

Steps to use the script:

  1. Save this script as make_pdf.pl in the directory where you have
    the JPG images.
  2. Install the Perl Module.
  3. Edit the script modify as per requirement.
  4. Run the script from the command line.
Advertisements

Windows String Search (commandline)

In case, you are looking for a quick string search within files on a Windows machine, you can use the “findstr” tool:

E.g.:

findstr /i /s "my_string_abc"  <folder path>

In the abve example, we use the following modifiers:
/i indicates do a case insensitive search

and

/s search in sub directories

using * instead of <folder path>  would search for all files from the current folder and below.

You can also find additional information about findstr at  http://ss64.com/nt/findstr.html

Adding a firewall rule for inbound RDP connection to windows 7

When you enable RDP for Windows 7 (default is enabled) , you will also need to add a firewall rule to accept RDP connections. By default this is not enabled. You can easily do it via the Windows firewall MMC by running the following command

 wf.msc 

or Add a rule for the same via the command prompt. Add a rule for accepting incoming RDP connections on TCP 3389.

netsh advfirewall firewall add rule name="RDP Allow TCP" dir=in protocol=tcp localport=3389 action=allow

Network connections view

I am running Windows 7 on my machine. Coming from XP, I was used to seeing and using the “Network Connections” view. The new “Network and Internet” view for configuring network settings is too confusing. I found it difficult to find my way around. To be frank it was irritating to use and I wanted my “Network Connections” view back.

Here’s a quick workaround:

On the command prompt run the command

ncpa.cpl

and voila the friendly “Network Connections” view is back. 🙂

Change firewall settings from command line

I was looking at options for enabling/disabling the Windows default firewall command line. Here’s how you can do it:

On Windows XP:

to disable the firewal

netsh firewall set opmode disable

to enable the firewall

netsh firewall set opmode enable

to allow ICMP ping to the box

netsh firewall set icmpsetting type = 8 mode = enable

to reset the firewall back to default settings:

netsh firewall reset

On Windows 7 ( & Windows 2008) commands have changed. You will need to run following commands as the machine (domain) administrator.

to disable firewall

netsh advfirewall set allprofiles state off

to enable firewall

netsh advfirewall set allprofiles state on

to reset firewall

netsh advfirewall reset

to allow ICMP ping to the box, add a new rule

netsh advfirewall firewall add rule name="ICMPv4 Allow" dir=in protocol="icmpv4:8,any" action=allow

delete the  ICMP ping rule that you just added

netsh advfirewall firewall delete rule name="ICMPv4 Allow"

For details check out the following KB article#947709