5

A3

I am working on the iPhone app using print image concept using UIPrintInteractionController. I have stuck at one point i.e. border, whenever I tried to print any image using printer it always show border on all sides which is not required. Image should use whole the paper size, as I am giving the image size same as paper width and height, but still it is showing border.

I didn't find any kind of method to remove the border or make the paper content border less. See iPhone image enter image description here enter image description here

You can see in the attached image enter image description here, In this I am trying to print the image from Mac system in which it is giving option for border and border less.

I think it should be there in the UIPrintInteractionController framework, but didn't find anyone.

Please help me, if someone has experienced regarding this.

Thanks in advance. Your help will be appreciated

[![A4][4]][4]

A3

Anuraj R
  • 524
  • 2
  • 8
  • 24
Minkle Garg
  • 723
  • 3
  • 9
  • 35

2 Answers2

8

If you want to eliminate any borders you could quickly achieve that by passing a photo outputType to a printInfo object:

let printController = UIPrintInteractionController.shared
printController.printingItem = someImage
printController.showsPaperSelectionForLoadedPapers = true

let printInfo             = UIPrintInfo.printInfo()
printInfo.outputType      = .photo
printController.printInfo = printInfo

enter image description here

Now, if you want greater control over the final rendering, you could explore Apple's sample project regarding UIPrintInteractionController

Alladinian
  • 34,483
  • 6
  • 89
  • 91
  • It's works only for A4 page size, not for others and print preview never give the option to choose paper size, how to get that – Minkle Garg Nov 02 '17 at 09:18
  • I am accepting your answer, it is working 70% fine but not for all papers. – Minkle Garg Nov 02 '17 at 09:18
  • @MinkleGarg Can you provide a mini project demonstrating the problem? Do you use a custom `UIPrintFormatter` / `UIPrintPageRenderer`? – Alladinian Nov 02 '17 at 09:32
  • I have added two images in the question, one is A4 and other is A3, When I load the image of A4 size then it is working fine, but suppose user has selected A3 options before print preview in custom option, then the print preview is not correct. – Minkle Garg Nov 02 '17 at 09:39
  • This worked for me for specialty 54x86mm paper. Nice! – charmingToad Nov 02 '18 at 19:33
2

Objective-C version

UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
printController.printingItem = someImage;
controller.showsPaperSelectionForLoadedPapers=YES;

UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputPhoto;
printController.printInfo = printInfo;
June7
  • 19,874
  • 8
  • 24
  • 34
Ashish
  • 2,977
  • 1
  • 14
  • 32