Hi all, I have spent the last couple of days trying to solve this problem with no luck, so I'm asking for some quidance.
1. I have a long list of Objects that I have broken up into an array of separrate pages :[ObjectType]
2. I have a ViewController that has a TableView and a TextField to hold the page nuber being printed
3. I have a class property of objectsPerPage:Int. (example: 72)
4. For each page I wish to print I load the TableView with 72 objects out of the list of all objects and set the TextField to the pageNumber
5. I then have a loop when I can print the ViewController.view for any or all of the pages using:
let printOperation = NSPrintOperation(view: view, printInfo : printInfo)
...
printOperation.run()
No matter what range of pages I print or print all pages, the first page printed always has exactly 37 rows printed in the TableView. The remaining pages are print with the proper number of rows in the TableView, 72 in this case.
I have check the "NSTableViewDataSource.numberOfRows(in tableView: NSTableView) -> Int" function and for all pages including the first page printed it returns the correct value of "72"
I have checked the"NSTableViewDelegate.tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?" function and it is called (72 *number of Columns) for every page except the first which is correct. The fist Page printed is called (38 * number of Columns) which is wrong but also doesn't match the 37 rows that are being printed.
After the first page printed (incorrectly), there is no error mesage printed. But after the second page printed (correctly) and each subsequent page, the following error code is displayed:
2018-12-29 09:26:01.258290-0700 HCB_121918[25663:9040666] [Printing] -[NSPrintThumbnailView widthForHeight:]: Invalid result: nan (paperAspectRatio: nan, paperShadowOffset: {0, -3}, paperShadowBlurRadius: 6.000000)
2018-12-29 09:26:01.258315-0700 HCB_121918[25663:9040666] [Printing] -[NSPrintPreviewController _tileView]: Bailing due to invalid thumbnailViewSize: {nan, 310} (maxThumbnailViewSize: {310, 310})
This entire message is repeated 16 times after each correctly printed page.
I have searched my entire code for the number '37' and it does not appear anywhere
I have searched the Apple documentation for the class 'NSPrintPreviewController' but found nothing.
Any help to point me in the right direction would be most appreciated.
Thanks, Tom