2011-03-03 3 views
2

언젠가는 대화 상자없이 XPS를 인쇄하여 인쇄하고 있습니다. CodeGuru와 Feng Yuan (MSDN)의 문제에 대한 게시물을 많은 토론 주제와 함께 읽었으며 여전히 분실 상태입니다.Microsoft XPS Document Writer 프린터를 자동으로 사용하여 XPS를 만듭니다

특히 제 시나리오는 필자가 사용해야하는 타사 API가 있고 기본 프린터 (Microsoft XPS Document Writer)로 인쇄한다는 것입니다. 나는 인쇄 절차에 앞서 파일 이름을 "적용"할 수 있기를 원합니다. 물론 대화 상자가 없기를 바랍니다.

WinDDK-XPSDRV 및 LOCALMON 샘플 작업을 시도했지만 목표를 달성하기 위해 코드를 조작하는 방법을 정확하게 파악하지 못했습니다. (또는 새로운 프린터 드라이버 또는 새 포트 유형이 필요한지 완전히 이해함)

+0

문제를 조금 명확하게 할 수 있습니까? 어떤 언어로 작업하고 있습니까? 응용 프로그램에서 XPS 출력을 만들려고 구체적으로 시도하고 있습니까? 아니면 단순히 XPS Document Writer가 기본 드라이버 일 때 팝업 대화 상자가 자동화 된 워크 플로가되어야하는지 방해하고 있습니까? – Jon

+0

어쩌면 읽은 링크 중 일부는 문제 해결에 도움이 될만한 정보일지도 모릅니다. – Nocturnal

+0

Jon - 질문은 프린터 드라이버를 만드는 방법입니다. 컴퓨터의 기본 프린터로 인쇄하는 자동 프로세스입니다. - 야행성, 고마워,하지만 사실 나는이 솔루션을두고 타사 제품을 구입했다. –

답변

0

파이프 라인 xml의 필터와 관련 dll의 inf 파일을 삭제합니다. 하지만, 제가 한 것처럼, 당신은 캔버스 (그래픽)를 인쇄하는 문제에 직면하게 될 것입니다. 이 캔버스를 글리프로 변환/변환 할 수 없어 그 내용을 가져올 수 없습니다. 당신이 더 문제가 있다면

, 내가

친절 감사 나는 같은 필요에 달렸다

1

을 알려 주시기 바랍니다. 다음은 나를 위해 원하는 기능을 제공하는 일부 논리입니다.

// 
// PrintDocument_inst 
// 
this.PrintDocument_inst.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.k_line_PrintPage); 

    private void Print(string align_file_name) 
    { 
    if (plot_metafile == null) 
    { 
     MessageBox.Show("you need to load offset data before printing a plot"); 
     return; 
    } 

    try 
    { 
     PrintDocument_inst.DefaultPageSettings = PageSettings_inst; 

     PrintDialog_inst = new PrintDialog(); 
     PrintDialog_inst.Document = PrintDocument_inst; 
     PrintDialog_inst.UseEXDialog = true; // this must be set true or dialog won't show on 64 bit Vista 
     PrintDialog_inst.PrinterSettings.PrinterName = "Microsoft XPS Document Writer"; 
     PrintDialog_inst.PrinterSettings.PrintToFile = true; 
     PrintDialog_inst.PrinterSettings.PrintFileName = align_file_name; 

     i_page_to_print_next = 1; 
     n_pages_still_to_print = 1; 
     PrintDocument_inst.Print(); 
    } 
    catch (Exception e) 
    { 
     MessageBox.Show(e.ToString()); 
    } 
    finally 
    { 
    } 

    } // end of function Print(string align_file_name) 

    //PrintPage event handler 
    private void k_line_PrintPage(object sender,PrintPageEventArgs ppea) 
    {   
    int leftMargin = ppea.MarginBounds.Left; 
    int topMargin = ppea.MarginBounds.Top ; 

    try 
    { 
     float _scale_f; 

     if (PrintDialog_inst != null) 
     { 
      string str_printer_name = PrintDialog_inst.PrinterSettings.PrinterName.ToString (); 
      if (str_printer_name.CompareTo ("Adobe PDF") == 0) 
      { 
       _scale_f = 0.61F; // 0.85F; 
      } 
      else 
      { 
       _scale_f = 0.59F; // 0.82F; 
      } 
     } 
     else // case of print preview 
     { 
      _scale_f = 0.59F; // 0.82F; 
     } 
     if (_scale_f != 1.0F) ppea.Graphics.ScaleTransform (_scale_f, _scale_f); 
     ppea.Graphics.DrawImage (plot_metafile, leftMargin, topMargin); 
     ppea.HasMorePages = (--n_pages_still_to_print > 0 ? true : false); 
    } 
    finally 
    { 
    } 
    } // end of private void k_line_PrintPage(object sender,PrintPageEventArgs ppea) 
관련 문제