Ich erstelle PDFs in ColdFusion mit cfdocument. Ich muss einen Tisch mit der Kopfzeile schräg stellen, damit alles auf die Seite passt. Hier ist ein Beispiel für das, was ich erreichen möchte. Keines der HTML- oder CSS-Beispiele, die ich bisher gefunden habe, hat funktioniert. Jetzt frage ich mich, ob das eine Besonderheit für ColdFusion und/oder PDF-Erstellung ist. Ich weiß, dass dieser Code direkt von einer Antwort auf eine ähnliche Frage kam, aber er erstellt keine Tabelle mit schrägen Spalten in meinem PDF. Es schafft dies. PDF Tabelle mit schräger Kopfzeile
//CSS
* {
box-sixing: border-box;
}
.outerDiv {
background: grey;
height: 200px;
width: 100px;
border: 1px solid black;
border-bottom: 0;
border-left: 0;
transform: skew(-30deg) translateX(58%);
}
th:first-child .outerDiv {
border-left: 1px solid black;
position: relative;
}
.innerDiv {
position: absolute;
width: 250px;
height: 85px;
bottom: -34%;
left: 10px;
transform: skew(30deg) rotate(-60deg);
transform-origin: 0 0;
text-align: left;
}
body,
html {
height: 100%;
}
body {
display: flex;
justify-content: center;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid black;
}
.well {
min-height: 20px;
padding: 5px;
margin-bottom: 10px;
background-color: #f5f5f5;
border: 1px solid black;
border-radius: 3px;
}
.well_tight {
padding: 3px;
margin-bottom: 5px;
background-color: #f5f5f5;
border: 1px solid black;
border-radius: 3px;
}
//ColdFusion/HTML
<cfdocument format="pdf" name="#formname#" pagetype="letter" marginleft=".25" marginright=".25" margintop=".25" marginbottom=".5">
<cfoutput><style type="text/css">@import "/mach15/web/assets/css/formPDF.css";</style></cfoutput>
<div class="well">
<table cellpadding="0" cellspacing="0">
<tr>
<th>
<div class="outerDiv">
<div class="innerDiv">This is first column header</div>
</div>
</th>
<th>
<div class="outerDiv">
<div class="innerDiv">This is second column header</div>
</div>
</th>
<th>
<div class="outerDiv">
<div class="innerDiv">This is third column header</div>
</div>
</th>
</tr>
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
</tr>
<tr>
<td> 4 </td>
<td> 5 </td>
<td> 6 </td>
</tr>
<tr>
<td> 7 </td>
<td> 8 </td>
<td> 9 </td>
</tr>
<tr>
<td> 10 </td>
<td> 11 </td>
<td> 12 </td>
</tr>
</table>
</div>
Nun, es funktioniert wie HTML, also ist es definitiv eine cfdocument Beschränkung. Es ist nur [unterstützt CSS2] (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdocument.html) (meistens) und 'transform' ist CSS3. Am nächsten habe ich bisher gefunden [ist dieser alte Thread] (https://forums.adobe.com/thread/80941), der ein paar Hacks erwähnt (obwohl keine ist sehr gut IMO). – Leigh
Ich empfehle die Verwendung von WKHTMLTOPDF (ein kostenloses Befehlszeilenprogramm) mit ColdFusion 8, 9, 10, 11 und 2016, um PDF-Dokumente zu generieren. Ich hatte guten Erfolg mit schrägen/gedrehten Texten, Schatten, Webfonts (fontawesome), SVGs, CSS-Gradienten, Alpha-PNG-Unterstützung, relative/absolute Position usw. –
Ja, ich bezweifle, dass schräger Text mit cfdocument möglich [email protected] - Wenn Sie ein Beispiel für das Erstellen von schrägem Text mit WKHTMLTOPDF haben, können Sie es als Antwort posten, da es wahrscheinlich für andere in Zukunft hilfreich wäre. – Leigh