IOS print pdf with minimal margins - iphone

This must be quite simple but I can't seem to figure this out.
I've managed to implement the code for printing an PDF from my App. Problem is, the PDF has quite some whitespace around it and with the default margins... it's just not how I would like the page to come out of the printer.
So, I'm trying to reduce the margins to minimum. How would I go about this? Do I need to use a custom UIPrintFormatter, UIPrintPageRenderer or UIPrintPaper. In which method from UIPrintInteractionControllerDelegate would I need to change things?
I know it can be done because when I print the PDF from Apple's iBook App, margines are significant less.
Thanks.

I did not quite solve the problem but I'm satisfied with the result now.
Actually I did not change anything, the reason why I asked this questing was because in the AirPrint simulator, my PDF printed with an excessive amount of white space / margin. But printing the PDF on an actual device did not have this problem.
So, if you run into this problem in the AirPrint simulator, try it on a real device/printer, changes are that everything prints fine.

Related

iPhone 5 Image Issuses

I have an app that I am making but the background image I am using wont work on my iPhone 5. Everything works on it when I load it on my iPhone 4. It was size the -568h#2x.png right it looks massive or it will load the #2x.png and give it a tile look. Any one know would could be wrong. I've tried making a UIImage in IB and programmatically. Neither have been successful. I've even tried if else methods to loads different pngs based on the screen height. I'm at a point where I could just quit. Any direction or guidance. I have all my code but didn't know what would be the best pice to post. Thanks
Sounds like you might need to make two separate storyboards/xibs, one for an iPhone 5 and another for the iPhone 4S/4/3GS, etc. Here's a link that will tell you how to do it.

Displaying large PDF document iPhone

After many hours of googling I thought I would see if anyone knew the answer.
I have a large PDF file (30mb) which I was using the UIWebView to display but it is painfully slow when trying to scroll through pages and when you rotate the iPhone/iPad it doesn't draw properly on the screen till you have scrolled through a few pages.
So I have been looking into using the CGPDFDocumentRef to display the PDF. Before I go any further is there an easier way to do this, or any examples/open source solutions to do this before I spend a long time trying to replicate the UIWebView or something similar to display a large PDF.
I assume someone else has had this problem?
Many thanks for any help
I've been building one of these for a while now. I'll tell you, both approaches have difficulties. The CGPDFDocumentRef path is the one that I've taken, and it's worked out pretty well.
A good place to start is here, with Apple's example, ZoomingPDFViewer. You'll get a good idea of how that CGPDF* stuff works. If you're looking to put something together in a hurry, you might want to start with this guy's example. In fact, the author's website has a huge list of resources to use when you run into problems.

How would you design a question/answer view (iPhone SDK)

I'm new to iPhone development, and I have a question on how to create a view for my application.
The view should display a problem (using formatted/syntax highlighted text), and multiple possible answers. The user should be able to click on an answer to validate it.
Currently, I am trying to use a UITableView embedding UIWebView as contentView. That allows me to display formatted text easily.
The problem is that it is a real pain to compute and adjust the height of the cells. I have to preload the webview, call sizeToFit, get its height, and update the cell accordingly. This process should be done for the problem and the answers (as they are HTML formatted text too).
It's such a pain that I am planning to switch to something else. I thought using only a big UIWebView and design everything in HTML. But I looked at some articles describing how to communicate between the HTML page and the ObjectiveC code. This seems to involve some awful tricks too...
So... that's it, I don't really know what I should do.
I guess some of you dealt with such things before, and would provide some greatly appreciated tips :)
The catch here is that the iPhone API does not yet support NSAttributedString so you can't just set the text to appear as you would like in a textview.
I saw one work around which essentially used individual UILabels to represent each attribute run. (Can't find the link now.) They used NSString UIKit extensions to calculate the position of the strings on the view and then used that to position the labels.
Another work around would be to draw the strings with their attributes to a UIImage and then just display the image. That would be the easiest solution I think.
In either case your going to have to basically recreate the data structure of an attributed string.
NSAttributedString does a lot of work for us. We really miss it when it is gone.

UIWebView With PDF

I'm displaying a PDF file using UIWebView, and I want to do 2 things:
I want to make the page fit the phone screen without the user has to double tap to do that
I want to remove the margin with gray shadow around the displayed PDF
Thanks for helping
I don't think this will help much, but I think your best option is to render the PDF to an image (of decent DPI) and show the image instead. I do this for an app, but we do that server side using ImageMagick - don't know how you might do that in obj-c. Also note that a mostly-text PDF will be much larger (filesize) when rasterized.
However, you might also try to embed the PDF in HTML page and load that HTML in the WebView - that may at least avoid the gray border/artboard.
webView.transform = CGAffineTransformScale( webView.transform, 1.25, 1.25 );
2 - Checking the Scale Pages to Fit box in IB sorted this for me
I would also like to know the answer to 1.
I guess you want to know how to display the PDF in the same way as when opening as attachment in mail, where the navigation bar only appears on a tap and the status bar also disappears?
You can also use Quartz to do it, as explained here : http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
Where has CGAFFineTransformScale been all my life?
Seriously, that is a big help. However, it worked better applying it to webView.scrollView.
Finally, is there a similar command to change the offset of the content as well as the scale?

iPhone App Delete Badge

I'd like to replicate the visual style of the Springboard's delete badge when you want to delete an application. I've gotten it pretty close, but it's not quite right, and I get the feeling that Apple isn't rendering these on the fly, but rather has a set image that they use.
I was wondering if anyone has done this before, or has such an image, or anything, really :)
I assume you're talking about the little x that is pinned to the top left of the App icon?
As far as I know, it's a PNG that is stored on the iPhone, but of course you have no legal way of getting at the filesystem.
You could always take a screenshot of the iPhone and hack it in Photoshop, but Apple mightn't like that.