2016-07-10 10 views
0

인쇄 된 문서에 html을 사용하려고합니다. 나는 모든 인쇄 된 페이지에 표시 할 헤더를 가지고 있고, 나는 다음과 같은 코드를 사용하고 있습니다 : 나는 크롬의 자신의 인쇄 대화 상자 내에서이 문제를 미리 볼 경우컵의 xhtmltopdf 필터가 인쇄 매체 css의 어떤 부분을 차지합니까?

<style type="text/css"> 
    @media print { 
    div.header { 
     position: fixed; 
     width: 100%; 
     top: 0; 
    } 
    #student_name, #date_submitted { 
     background: transparent; 
     border: none; 
     border-bottom: 1px solid #000000; 
     width: 55%; 
    } 
    } 
    div.twocol { 
    width: 50%; 
    float: left; 
    } 
    div.problem { 
    display: inline-block; 
    width: 5.5em; 
    font: 300% monospace; 
    text-align: right; 
    margin: 2.5em 0 2.5em 0; 
    } 
    div.operand2, div.operation { 
    float: right; 
    border-bottom: 0.1em black solid; 
    } 
    } 
</style> 
</head> 
<body> 
<div class="header"> 
    <div class="twocol"> 
    <label class="student_name" for="student_name">Name</label> 
    <input class="student_name" type="text" id="student_name"></input> 
    </div> 
    <div class="twocol"> 
    <label class="date_submitted" for="date_submitted">Date</label> 
    <input class="date_submitted" type="text" id="date_submitted"></input> 
    </div> 
</div> 
<div class="problem"> 
    <div class="operand1"></div> 
    <div class="operand2"></div> 
    <div class="operation">+</div> 
</div> 

, 그것은 거의 내가하려는 방법을 보인다. 또한 Chrome의 인쇄 대화 상자 (미리보기와 동일, 적어도 내 안구와 동일)에서 인쇄하면 올바르게 표시됩니다.

CUPS의 xhtmltopdf 필터 (인쇄를 시뮬레이트하기 위해)를 통해 실행하면 몇 가지 결함이 나타납니다.

첫 번째 페이지에서는 헤더가 올바르게 표시되지만 Chrome 자체의 인쇄 대화 상자에서와 같이 후속 페이지에는 표시되지 않습니다. 이것은 스타일링이 인 것을 증명합니다. 미디어 인쇄 선택기의 항목입니다. 그렇지 않으면 일반 입력을 볼 수 있습니다. 미디어 인쇄 선택기와 관련하여 문제가 있습니까? 아니면 위치 고정 기능과 관련이 있습니까?

두 번째 문제는 다른 요소 (클래스 "문제")가 Chrome의 인쇄 대화 상자보다 xhtmltopdf에서 훨씬 더 크게 렌더링된다는 것입니다.

From ChromeFrom xhtmltopdf

이 또한 CSS 문제, 또는 CUPS에서 독특한 무언가인가? 나는 이것에 관해 일종의 일종이지만, 몇 년 전부터 일부 브라우저에는 최소한 쿼크 모드에서 요소의 기본 스타일이 있다는 것을 기억하는 것 같습니다. Chrome에서 xhtmltopdf가 누락 된 스타일이 적용됩니까? 다른 일이 진행되고 있습니까?

john$ cupsfilter /mnt/Linkstation/Documents/Education/\!Curricula/Arithmetic/Arithmetic\ -\ g1\ -\ Addition\,\ no\ carrying.html > test2.pdf 
DEBUG: argv[0]="cupsfilter" 
DEBUG: argv[1]="1" 
DEBUG: argv[2]="john" 
DEBUG: argv[3]="Arithmetic - g1 - Addition, no carrying.html" 
DEBUG: argv[4]="1" 
DEBUG: argv[5]="" 
DEBUG: argv[6]="/mnt/Linkstation/Documents/Education/!Curricula/Arithmetic/Arithmetic - g1 - Addition, no carrying.html" 
DEBUG: envp[0]="<CFProcessPath>" 
DEBUG: envp[1]="CONTENT_TYPE=text/html" 
DEBUG: envp[2]="CUPS_DATADIR=/usr/share/cups" 
DEBUG: envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts" 
DEBUG: envp[4]="CUPS_SERVERBIN=/usr/libexec/cups" 
DEBUG: envp[5]="CUPS_SERVERROOT=/private/etc/cups" 
DEBUG: envp[6]="LANG=en_US.UTF8" 
DEBUG: envp[7]="PATH=/usr/libexec/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin" 
DEBUG: envp[8]="PPD=/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd" 
DEBUG: envp[9]="PRINTER_INFO=cupsfilter" 
DEBUG: envp[10]="PRINTER_LOCATION=Unknown" 
DEBUG: envp[11]="PRINTER=cupsfilter" 
DEBUG: envp[12]="RIP_MAX_CACHE=128m" 
DEBUG: envp[13]="USER=john" 
DEBUG: envp[14]="CHARSET=utf-8" 
DEBUG: envp[15]="FINAL_CONTENT_TYPE=application/pdf" 
INFO: xhtmltopdf (PID 29607) started. 
DEBUG: Page = 612x792; 17,19 to 595,773 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: Invalid Connection ID 0 
DEBUG: Loading "file:///mnt/Linkstation/Documents/Education/!Curricula/Arithmetic/Arithmetic%20-%20g1%20-%20Addition,%20no%20carrying.html" 
DEBUG: Waiting for HTML file to load, 10% 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
DEBUG: Waiting for HTML file to load, 50% 
DEBUG: Waiting for HTML file to load, 50% 
DEBUG: Page title="Basic Addition, No Carrying" 
DEBUG: Bounds of document are [0.0 0.0 579.0 2608.0] 
DEBUG: Starting page 1: [0.0 0.0 578.8 681.0] 
DEBUG: Starting page 2: [0.0 681.0 578.8 754.8] 
DEBUG: Starting page 3: [0.0 1435.8 578.8 685.2] 
DEBUG: Starting page 4: [0.0 2121.0 578.8 754.8] 
INFO: xhtmltopdf (PID 29607) exited with no errors. 

답변

0

나는 "CUPS 'xhtmltopdf"이 뭔지 모르 (빠른 검색은 유용한 정보를 찾을 수 없습니다 :이,하지만 난 컵 필터의 출력을 포함하고있어 도움이 될 것입니다 경우

확실하지 않음)하지만 PDF 작성을 위해 paged media을 사용하는 것이 더 나을 것이 확실합니다.

단점은 최신 브라우저에서는 CSS 규칙을 미리 볼 수 없으므로 PrinceXML, PDFReactor 또는 wkhtmltopdf와 같은 솔루션이 필요하다는 것입니다. 이렇게하면 특정 CSS 규칙을 사용하여 원하는 것을 성취 할 수 있습니다.

예 :

@page { 

    @top-left { 
     content: Name __________________; 
     font-size: 9pt; 
     color: #333; 
    } 

    @top-right { 
     content: Date __________________; 
     font-size: 9pt; 
     color: #333; 
    } 
} 
+0

이 내 질문에 대답하지 않습니다. CUPS는 Mac OSX 및 대부분의 Linux 시스템의 프린터 시스템입니다. –