Here i am printing pdf with size 'pageSize = CGSizeMake(640, 832);'. this size is larget then A4 size page aspected. so i will cut-off some text(means it will not print whole page).
while printing same pdf using MAC, it will print whole page with help of option (scale to fit). so can any one help me to come out from this problem.. is there any option in IOS sdk for scale to fit.
here is my code..
-(void)printItem
{
NSArray *aArrPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ;
NSString *aStr = [[aArrPaths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"PropertyReport_%d.pdf",self.propertyId]];
// NSString *aStr = [[NSBundle mainBundle] pathForResource:@"TRADUZIONE HELP SECTIONS REV2" ofType:@"pdf"];
NSURL *url=[[NSURL alloc] initFileURLWithPath:aStr];
NSData *data=[[NSData alloc] initWithContentsOfURL:url];
printController = [UIPrintInteractionController sharedPrintController];
if(printController && [UIPrintInteractionController canPrintData:data])
{
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
//printInfo.jobName = [NSString stringWithFormat:@"New Image"];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.printingItem = data;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error)
{
if (!completed && error)
{
//NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
// aWebViewPDF.hidden=FALSE;
[printController presentAnimated:YES completionHandler:completionHandler];
}
}
Thanks!
As bizarre as it sounds try:
This seems to enable auto-scale, but sometimes prints an extra blank page at the end of the job. AirPrint is basically witchcraft.
You have only one option is to
scale down
to theratio
of theprinted format
from all pages of PDF then print it. I have done is got all pages ofpdf into images
and scaled that down to requirement :Add all three methods :
Convert all PDF pages into UIImages
Resize images
Get UIImage from CGPDFPageRef
EDIT : Refer printing-uiimage-using-airprint-causes-cut-off-content