Apple 인쇄 문서 예제를 사용하여 iPhone에서 Airprint 호환 프린터로 pdf를 인쇄합니다. 그러나 나는 아이폰에서 전체 페이지 인쇄를 얻지 못하고있다. 내가 얻는 그림을 보아라, 나는 pdf가 전체 종이 길이, 너비에 인쇄되어야한다. UIPrintInteractionController가 iPhone의 전체 페이지로 인쇄되지 않습니다.
내가 인쇄 기능을 위해 사용하고 코드는 애플 인쇄 샘플 응용 프로그램에서와 같이, 아래의 동일한 코드를 부여
,UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
if(!controller){
NSLog(@"Couldn't get shared UIPrintInteractionController!");
return;
}
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if(!completed && error){
NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
controller.delegate = self;
// Obtain a printInfo so that we can set our printing defaults.
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
// This application produces General content that contains color.
printInfo.outputType = UIPrintInfoOutputGeneral;
// We'll use the URL as the job name.
printInfo.jobName = [_filePath lastPathComponent];
// Set duplex so that it is available if the printer supports it. We are
// performing portrait printing so we want to duplex along the long edge.
printInfo.duplex = UIPrintInfoDuplexLongEdge;
// Use this printInfo for this print job.
controller.printInfo = printInfo;
controller.printingItem = myData;
// Be sure the page range controls are present for documents of > 1 page.
controller.showsPageRange = YES;
// This code uses a custom UIPrintPageRenderer so that it can draw a header and footer.
APLPrintPageRenderer *myRenderer = [[APLPrintPageRenderer alloc] init];
// UIPrintPageRenderer *myRenderer = [[UIPrintPageRenderer alloc] init];
// The APLPrintPageRenderer class provides a jobtitle that it will label each page with.
// myRenderer.jobTitle = printInfo.jobName;
// To draw the content of each page, a UIViewPrintFormatter is used.
UIViewPrintFormatter *viewFormatter = [docWebView viewPrintFormatter];
#if SIMPLE_LAYOUT
UIFont *font = [UIFont fontWithName:@"Helvetica" size:HEADER_FOOTER_TEXT_HEIGHT];
CGSize titleSize = [myRenderer.jobTitle sizeWithFont:font];
myRenderer.headerHeight = myRenderer.footerHeight = titleSize.height + HEADER_FOOTER_MARGIN_PADDING;
#endif
[myRenderer addPrintFormatter:viewFormatter startingAtPageAtIndex:0];
// Set our custom renderer as the printPageRenderer for the print job.
controller.printPageRenderer = myRenderer;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[controller presentFromBarButtonItem:sender animated:YES completionHandler:completionHandler]; // iPad
}
else
{
docWebView.hidden = YES;
[controller presentAnimated:YES completionHandler:completionHandler]; // iPhone
}
에 대한 특정 포맷이 필요하지 않습니다? –
PDF 파일은 내 전화의 문서 디렉토리에 로컬로 저장됩니다. –
가져 가서 업로드 할 수 있습니까? 문서 작성 방식에 문제가있을 수 있습니까? –