2009-08-21 1 views
1

Adobe AIR의 초보자이며 항공 응용 프로그램에서 HTML을 인쇄하려고하지만이 HTML을 화면에 표시해서는 안됩니다. 웹상에서 본 샘플에 따라 HTMLLoader를 사용하고 있습니다.AIR 응용 프로그램의 화면에 표시되지 않는 HTML 내용을 인쇄 할 수 없습니다.

인쇄 대화 상자가 나타나지만 빈 페이지가 인쇄됩니다.

이 응용 프로그램은 윈도우 응용 프로그램이며 인쇄 할 단추 (HTMLLoader 만)를 클릭하면 인쇄됩니다.

다음은 제 코드입니다.

var에 mySprite는 : 스프라이트 = 새로운 mySprite는()

VAR 로더 :하는 HTMLLoader = 새로운하는 HTMLLoader() loader.loadString ("주소
목 8월 20일 그리니치 표준시 21시 37분 20초 + 0530 2009
")

var에 HTML : HTML = 새 HTML()

html.htmlLoader = 로더

mySprite.addChild (HTML);

//이 자사의 꽤 표준

var에 pJob 후 : 다음 PrintJob = 새의 PrintJob(); html.width = pJob.pageWidth html.height = pJob.pageHeight loader.height = pJob.pageHeight loader.width = pJob.pageWidth

(! pJob.start()) { 던져 새로운 경우 PrintingCanceled ("사용자 취소 인쇄"); } pJob.addPage (loader, null); pJob.send();

제가 빠진 것이 있으면 알려주세요. 어떤 도움이나 제안을 환영합니다.

답변

0

페이지가로드되고 있습니까? 프레임을 볼 필요는 없지만 내용이 필요합니다. 즉, htmlLoader 데이터를 캔버스에로드하고 표시해야합니다. 그런 다음 사용자가 인쇄 할 내용을 볼 수 없도록하려는 경우 캔버스를 숨길 수 있습니다.

false로 클리핑을 설정해야합니다. 그러나 이것은 프린터 대화 상자가 화면에 표시되기까지 몇 초가 걸릴 것임을 의미합니다. 원본과

1. // Event Handler - called when the print button is clicked 
    2. private function onPrintClick():Void 
    3. { 
    4.  // Remove the clipping so all of the content is printed 
    5.  clipForPrinting(true); 
    6.  
    7.  // Start the delay to allow clipping to update before 
    8.  // printing anything. 
    9.  doLater(this, "doActualPrinting"); 
    10. } 
    11. 
    12. // Adjust the clipping to prepare for or recover from print. 
    13. private function clipForPrinting(printing:Boolean):Void 
    14. { 
    15.  // Assume printing is true if not passed in 
    16.  if (printing == undefined) { 
    17.   printing = true;  
    18.  } 
    19. 
    20.  // Modify the root clipContent so the application's width/height 
    21.  // doesn't interfere with bounds of the print content 
    22.  Application.application.clipContent = !printing; 
    23.   
    24.  // Modify the container holding the content to be printed to remove 
    25.  // the scroll masking 
    26.  printArea.clipContent = !printing; 
    27.   
    28. } 
    29. 
    30. // Handles the actual printing of the content in the popup 
    31. private function doActualPrinting():Void 
    32. { 
    33.  var printJob:PrintJob = new PrintJob(); 
    34.  // Keep track of # of pages - only print if there are pages to print 
    35.  var pageCount:Number = 0; 
    36. 
    37.  // Show the print dialog 
    38.  if (printJob.start()) { 
    39.   // The user has opted to print - add the pages that 
    40.   // need to be printed 
    41.   pageCount += PrintUtil.pagenate(printArea, printJob); 
    42. 
    43.   // Send the content to the printer 
    44.   if (pageCount > 0) { 
    45.    printJob.send(); 
    46.   } 
    47.  } 
    48. 
    49.  // Explicitly delete the printJob 
    50.  delete printJob; 
    51. 
    52.  // Fix clipping now that print is done 
    53.  clipForPrinting(false); 
    54. } 

크레딧 : 내가 할 경우 Link to source

+0

은 내가 그것을 인쇄 할 수 있습니다, 화면에 버튼의 onclick을,하지만 난 배경에서이 작업을 수행하고 싶었다. IP 프린터로 인쇄하거나 일부 구성을 기반으로합니다. 아직도, 나는 지금 함께 일할 물질이 있다고 생각한다. 고마워요! – Tanmay

관련 문제