Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to save a pie graph in pdf file in iphone app
    primarykey
    data
    text
    <p>I have iphone app which created Pie Chart i want that chart should be save in pdf file in iphone.</p> <p>Below is the code for PieChart but how can i save it in pdf i have read that we can save text in pdf but how to save this </p> <pre><code> -(void)createGraph{ PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(400,40, 320, 230)]; myPieClass.itemArray=[[NSArray alloc]initWithObjects:textFieldOne.text,textFieldTwo.text,textFieldThree.text, nil]; myPieClass.myColorArray=[[NSArray alloc]initWithObjects:[UIColor purpleColor],[UIColor redColor],[UIColor orangeColor], nil]; myPieClass.radius=100; [self.view addSubview:myPieClass]; [self creatPDFFromView:@"mydata.pdf"]; } -(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename { </code></pre> <p>// Creates a mutable data object for updating with binary data, like a byte array</p> <pre><code> NSMutableData *pdfData = [NSMutableData data]; </code></pre> <p>// Points the pdf converter to the mutable data object and to the UIView to be converted</p> <pre><code> UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil); UIGraphicsBeginPDFPage(); CGContextRef pdfContext = UIGraphicsGetCurrentContext(); </code></pre> <p>// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData</p> <pre><code> [aView.layer renderInContext:pdfContext]; </code></pre> <p>// remove PDF rendering context</p> <pre><code> UIGraphicsEndPDFContext(); </code></pre> <p>// Retrieves the document directories from the iOS device</p> <pre><code> NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES); NSString* documentDirectory = [documentDirectories objectAtIndex:0]; NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename]; </code></pre> <p>// instructs the mutable data object to write its context to a file on disk</p> <pre><code> [pdfData writeToFile:documentDirectoryFilename atomically:YES]; NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload