1

I can print a nice perfect Report on iPad, but now we want to port our app to iPhones, too. All normal views are being printed as they have to, except the one view where we use ShinobiCharts (OpenGL): on iPhone only the screensize will be printed, the rest of the PDF-Sheet will remain white.

I tried putting it into a scrollview and programatically assign the right resolution to the view before it was printed, but this resulted in the small window being streched to fit the PDF-Sheet's size, still not displaying the whole diagrams.

Normal views:

UIGraphicsBeginPDFPage();
[pdf1.view.layer renderInContext:pdfContext];

Diagram view:

UIGraphicsBeginPDFPage();
UIGraphicsBeginImageContextWithOptions(pdf8.view.bounds.size, NO, 0.0);
[pdf8.view drawViewHierarchyInRect:pdf8.view.bounds afterScreenUpdates:YES];
UIImage *pdf8Image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *pdf8ImageView = [[UIImageView alloc] initWithImage:pdf8Image];
[pdf8ImageView.layer renderInContext:pdfContext];

Full image on iPad enter image description here

Cropped image without ScrollView enter image description here

Scaled image with ScrollView enter image description here

Sander de Jong
  • 351
  • 6
  • 18
daydr3amer
  • 326
  • 2
  • 19
  • Are you printing directly from the screen to the pdf or redrawing it to A4 size? If you're printing from screen, the best you could do is scale up proportionately until you hit either max width/height of an A4. – Johnny Rockex Mar 21 '16 at 23:48
  • It's a little difficult to tell if the problem is caused by the charts themselves (I work on shinobi charts). If you think they may be the cause, could you please send a sample project that demonstrates the problem to info@shinobicontrols.com where a member of our team will take a look. – sburnstone Mar 23 '16 at 17:01
  • @JohnnyRockex: Im not showing the screen being printed to the user. I create the ViewController and initiate it from a Storyboard, without displaying it on screen. The printed screen size itself remains the devices screensize in the DiagramView, in the NomalView I can set the width&height to whatever size I want and it will be printed – daydr3amer Mar 28 '16 at 18:52
  • @sburnstone: Once I asked a similar question and the above code results directly from it: http://stackoverflow.com/questions/22259349/printing-shinobi-chart-into-pdf If i have some spare time left soon, I will send you a sample project. – daydr3amer Mar 28 '16 at 18:52

0 Answers0