0

I'm trying to create a PDF from a UIView and works well, as "How to Convert UIView to PDF within iOS?" did.
But my iPad is landscape and is a form, lengthy form, with height 3k.
When I convert to PDF, it converts only the size of the height of the iPad, namely 748 and not 3k I need.

What is wrong? The iOS version?

EDITED: Heres the code like @wain ask

-(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
    // Creates a mutable data object for updating with binary data, like a byte array
    NSMutableData *pdfData = [NSMutableData data];

    // Points the pdf converter to the mutable data object and to the UIView to be converted
    UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
    UIGraphicsBeginPDFPage();

    // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
    [aView drawRect:aView.bounds];

    // remove PDF rendering context
    UIGraphicsEndPDFContext();

    // Retrieves the document directories from the iOS device
    NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

    NSString* documentDirectory = [documentDirectories objectAtIndex:0];
    NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename];

    // instructs the mutable data object to write its context to a file on disk
    [pdfData writeToFile:documentDirectoryFilename atomically:YES];
    NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
}
Community
  • 1
  • 1
Daniel Arantes Loverde
  • 2,317
  • 2
  • 28
  • 41

1 Answers1

0

I find the solution from here "UIGraphicsGetCurrentContext and UIScrollView" and adaptate to my code and now grab all form and print a nice PDF.
If someone need my code, please let me know and i post the code.

Community
  • 1
  • 1
Daniel Arantes Loverde
  • 2,317
  • 2
  • 28
  • 41