User Code List
All my code
---Android
------Sending SMS using Intents
------Send email attachment
------read file from sdcard
------get size of screen
------Accelerometer in Android OS 2.x and deprecated API
------Getting Animation Drawables to actually Animate
------hide the status bar and title bar
------Email, send intent
------wifi scanner
---------New Snippet
------scrollable tabhost
------bluring windows when dialog shows up
------Animated activity transition, diagonal slide
------simple way to scale image
------monitor outgoing phone call
------add directory in sdcard
------EditTextPreference only numbers
------MapView, LongPress, GestureDetector, OnTouchListener
------Preference Screen with custom views
------write and read data from file
------background without stretching
------System setting, change and write_settings
------Creating Persistent AlertDialog for on Orientation Change
------print from Android application
------Screen in landscape mode
------add contact photo to your list
------Distance calculation between 2 Geopoint by Haversine formula
---Iphone
------get iphone orientation
------generate pdf from iphone
------new thread autorelease pool
------determine firmware version
------turn page animation
------load resource file to webview
------call javascript in Objective-C code
------call objective-C code from Javascript
------Disable Webview selection flash
------Disable the action popup
------Disable webview zoom effect
---Utilities
------recursive remove .svn directory
New Snippet
 
 
generate pdf from iphone
 

//Create empty PDF context on iPhone for later randering in it

-(CGContextRef) createPDFContext:(CGRect)inMediaBox path:(CFStringRef) path

{

CGContextRef myOutContext = NULL;

CFURLRef url;

url = CFURLCreateWithFileSystemPath (NULL, // 1

path,

kCFURLPOSIXPathStyle,

false);

if (url != NULL) {

myOutContext = CGPDFContextCreateWithURL (url,// 2

&inMediaBox,

NULL);

CFRelease(url);// 3

}

return myOutContext;// 4

}

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"tmp.pdf"];

CGContextRef pdfContext = [self createPDFContext:scrolledView.bounds path:(CFStringRef)writableDBPath];

NSLog(@"PDF Context created");

CGContextBeginPage (pdfContext,nil); // 6

//turn PDF upsidedown

CGAffineTransform transform = CGAffineTransformIdentity;

transform = CGAffineTransformMakeTranslation(0, scrolledView.bounds.size.height);

transform = CGAffineTransformScale(transform, 1.0, -1.0);

CGContextConcatCTM(pdfContext, transform);

//Draw view into PDF

[scrolledView.layer renderInContext:pdfContext];

CGContextEndPage (pdfContext);// 8

CGContextRelease (pdfContext);

 
Sub-Article List