this question was previously posted ( Creating a PDF from a UIScrollView in an iphone application ), and the code I'm using is here .
Here is the code
-(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
[aView.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();
NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString* documentDirectory = [documentDirectories objectAtIndex:0];
documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename];
[pdfData writeToFile:documentDirectoryFilename atomically:YES];
}
Customization: I have a UIScrollView, inside a UIView. I want to save the entire UIView (950,500px) and its in space (UIScrollView size) (520 500). The generated PDF file is only the size of a UIScrollView (520,500)
I read the answer, but it obviously changed the code, but it does not work for me. I tried to fix it all day.
I am a beginner, so please indicate everything that I should add to my question that I missed. Thank.
PS is an iPad app.
source
share