Wednesday, March 24, 2010

Count total number of pages in pdf file (C#)

It is actually a simple solution to get a total number of pages in pdf file. I found it from devasp and I think it's worth to share.

using System.IO;
using System.Text.RegularExpressions;

public static int GetNoOfPagesPDF(string FileName)

{
int result = 0;

FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);

StreamReader r = new StreamReader(fs);

string pdfText = r.ReadToEnd();

System.Text.RegularExpressions.Regex regx = new Regex(@"/Type\s*/Page[^s]");

System.Text.RegularExpressions.MatchCollection matches = regx.Matches(pdfText);

result = matches.Count;

return result;
}

Tuesday, March 16, 2010

Window Phone 7 Series Development Tools

In this Mix10 event, Microsoft has released a set of development tools for Window Phone 7 Series.

The Windows Phone Developer Tools CTP includes the following


Visual Studio 2010 Express for Windows Phone CTP

Windows Phone Emulator CTP

Silverlight for Windows Phone CTP

XNA 4.0 Game Studio CTP


Download here

Friday, March 12, 2010

Android on HTC Window Mobile Phone

The XDAndroid project, Android Mobile OS for Window Mobile-Based HTC devices, has progressed tremendously and has archived many great performances for lots of Window-Mobile-Based devices to work with Android platform (sorry for HTC-HD2 users. Base on my understanding no any Android version working on HTC HD2 yet because of device driver issue). In the previous release, not many components worked, but in the recent release guys from pocketnow has tested with HTC touch pro and it works with call, sms, data.

Checkout the following links to get Android platform installed on your specific device.

Android on HTC Windows Phones:

Touch Pro2 (GSM)
Touch Pro2 (CDMA - must take SIM card out)
Touch Diamond2/Pure
Touch HD
Touch Pro/Fuze (GSM)
Touch Pro (CDMA)
Touch Diamond (GSM)
Touch Diamond (CDMA)


Via: pocketnow

Wednesday, March 10, 2010

Android Development Kits Hits Several New Update

At the same time of the announcement of Window Phone Series 7 which seems to rock the mobile market so much, Google Android is also working hard with its platform to bring developers realistic development features for their mobile development market.

The release of several update of development kits I believe will make the platform become more interesting to mobile companies and developers.

Below are several new update of development kit of Android in this March-2010.

- ADT 0.9.6: ADT Plugin for Eclipse hit version 0.9.6

- Android SDK, R5: The pakage include SDK Tools which provide developer the Development and Debugging Tools. If you are using the old version of SDK tools and want to upgrade to the new version, no need to download the whole SDK package again. You can just update the SDK tools by using the Android SDK and AVD Manager (via Eclipse or run "SDK Setup.exe" under SDK package folder)

- Android NDK,r3: Known as Android Native Development Kit currently hit Revision 3, bring new support for OpenGL ES 2.0 native library, will bring a new generation of fantastic 2D and 3D games like what we've seen in IPhone. NDK is used conjunction with Android SDK which mean we need to have Android SDK installed and you will likely use C/C++ language for coding.

Read more: http://developer.android.com

Tuesday, March 2, 2010

Regular Expression Examples

Regex to get Class Name from CSS content:

Regex: \.[-]?[_a-zA-Z][_a-zA-Z0-9-]*|[^\0-\177]*\\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\\[^\n\r\f0-9a-f]*

Input:

.center {text-align: center;}
.smcap {font-variant: small-caps;}
.u {text-decoration: underline;}

#body { ...}

Output:

.center
.smcap
.u

Regex to get all element from CSS content:

Regex: \.[-]?[_a-zA-Z][_a-zA-Z0-9-]*|[^\0-\177]*\\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\\[^\n\r\f0-9a-f]*

Input:

.center {text-align: center;}
.smcap {font-variant: small-caps;}
.u {text-decoration: underline;}
#body { ...}
div.test div.yoyo {...}

Output:

.center
.smcap
.u
#body
div.test div.yoyo

Regex to get HTML element and its content

Regex:

<span\b[^>]*>(.*?)</span>
(wrong in case this: onetwoone).

and

<span\b[^>]*>(?:(?=([^<]+))\1|<(?!table\b[^>]*>))*?</span>

Input:

<p><span><a name="bookmark1" />dirt farmer's son</span></p>

Output:

<span><a name="bookmark1" />dirt farmer's son</span>