Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes getting of information on regular report sheet. After starting the example the following operations are executed:
Number of regular report sheets is retrieved.
It is checked if the selected sheet is visible.
Name of the selected sheet is retrieved.
Key of the selected sheet is retrieved.
Sheet extension is retrieved.
Regular report sheet path is retrieved.
A PDF page object is created based on the information obtained by mean of the regular report sheet path.
Page width and height are retrieved from PDF page object.
Scale factor and indent from document start are retrieved for PDF page object.
Current page index and number of document pages are retrieved by means of methods of the <ProceduralDelegate> protocol.
Transition to the specified document page is executed.
Current regular report page PNG data is retrieved for screenshot.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Regular Report section):
// Delete all window subviews NSArray *reportSubviews = [self.view subviews]; for(UIView *subView in reportSubviews) { [subView removeFromSuperview]; } // Get regular report view MAProceduralReportViewController *proceduralReportController = (MAProceduralReportViewController *)m_controller; // Get array of regular report views NSArray *dataViewControllers = [proceduralReportController dataViewControllers]; // Parse regular report views in cycle for( UIViewController *controller in dataViewControllers) { // Check if the current view is a regular report viewer view if([controller isMemberOfClass:[MAProceduralReportDataViewController class]]) { // Get sheet viewer view MAProceduralReportDataViewController *dataViewController =(MAProceduralReportDataViewController *)controller; // Get regular report viewer view MAProceduralReportDataViewControllerBase *reportDataViewControllerBase = (MAProceduralReportDataViewControllerBase *)dataViewController; // Get regular report data source from sheet viewer view id<MAProceduralReportViewControllerDelegate> dataSource = [dataViewController dataSource]; // Get number of sheets int worksheetCount = [dataSource worksheetCount]; if(worksheetCount > 0) { // Check if selected sheet is visible if([dataSource isWorksheetVisibleAtIndex:worksheetCount - 1] == YES) { // Display regular report sheet name and key in the development environment console NSString *worksheetName = [dataSource worksheetNameAtIndex:worksheetCount - 1]; int worksheetKey = [dataSource worksheetKeyAtIndex:worksheetCount - 1]; NSLog(@"Regular report sheet: %@, key: %d",worksheetName, worksheetKey); // Check if selected sheet is PDF document if([[dataSource worksheetExtAtIndex:worksheetCount - 1] isEqualToString:@"pdf"] == YES) { // Get regular report sheet path NSString *worksheetFullpath = [dataSource worksheetFullpathAtIndex:worksheetCount - 1]; // Get regular report sheet URL CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:worksheetFullpath]; // Open PDF document CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithURL(url); // Get first page (PDF document pages are numbered from the first page) CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDocument, 1); // Get page object PdfPage *page = [[PdfPage alloc] initWithPage:pdfPage]; // Display page information in the development environment console float width = [page width]; float heght = [page height]; float scale = [page scale]; CGFloat offset = [page offset]; NSLog(@"Page width: %f, page height: %f", width, heght); NSLog(@"Page scale factor: %f, page indent from document start: %f", scale, offset); } } } // Get current page index int currentPage = [dataViewController currentPage]; // Check if the next page exists if(currentPage + 1 < [dataViewController pagesCount]) { // Go to the next page [dataViewController jumpToPage: currentPage + 1]; } // get PNG data fro screenshot NSData *data = [reportDataViewControllerBase workspacePNGData]; // Create an image based on obtained data UIImage *image = [[UIImage alloc] initWithData:data]; // Display obtained image on mobile device screen UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [self.view addSubview:imageView]; } }
After executing the example the development environment console displays name and key of the selected regular report sheet, parameters of the PDF page created by means of information on the selected sheet:
Regular report sheet: Map, key: 10
Page width: 841.124390, page height: 594.538574
Page scale factor: 1.000000, page indent from document start: 0.000000
The mobile device screen also displays the screenshot of the regular report page, to which transition is executed:
See also: