我想在下面的代碼中使用if 條件。
<xsl:variable name="vPageNumber"><fo:page-number/></xsl:variable>
...
..
.
<xsl:if test="$vPageNumber==1">
<fo:block text-align="right" margin-right="24px">
<fo:external-graphic content-width="20mm" src="url(D:/Atlassian/images/Turkak.gif)" />
</fo:block>
</xsl:if>
檢查當前頁碼是否為 1,此代碼塊應顯示在頁眉中。如果不是,則應隱藏代碼塊但它不起作用。當我們從下面的代碼創建 pdf 渲染時,雖然當前頁碼是 1,但Turkak.gif隱藏在所有頁面標題中。完整代碼如下。
<?xml version="1.0" encoding="ISO-8859-1"?>
#set($maxIssues = 500) ## set an upper limit for issues to be exported
#set($startIssuesOnNewPages = true) ## set to "true" to add a page break before each issue
#set($linkTypeNames = "Relates")
#set($exportProjectAvatars = true) ## set to "true" to export project avatars for each issue
#set($exportThumbnails = true) ## set to "true" to export thumbnails of the image type attachments
#set($exportChangeHistory = $pdfView.name.contains('All')) ## set to "true" to export the issue field change history
#set($embedAttachments = true) ## set to "true" to include binary file attachments in the PDF document, see: https://www.midori-global.com/products/better-pdf-exporter-for-jira/server/documentation/embedding-attachments
#set($embeddedAttachmentMaxFileSize = 52428800) ## max filesize (bytes) for attachments to be embedded (default: 50M)
#set($hebele = 55555)
$scripting.execute("nfeed-tool.groovy")
$scripting.execute("sub-task-tool.groovy")
$scripting.execute("issue-link-tool.groovy")
$scripting.execute("field-value-tool.groovy")
$scripting.execute("hello-world.groovy")
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" font-family="auto">
<fo:layout-master-set >
<fo:simple-page-master master-name="A4-portrait" page-width="21cm" page-height="29.7cm" margin-top="1cm"
margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
<fo:region-body region-name="page-body" margin-top="63mm" margin-bottom="45mm"/>
<fo:region-before region-name="page-header" extent="60mm" precedence="true"/>
<fo:region-after region-name="page-footer" extent="45mm" precedence="true"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:declarations>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>$xmlutils.escape($title)</dc:title>
<dc:creator>$xmlutils.escape($user.displayName)</dc:creator>
<dc:description>Issues exported from Jira</dc:description>
<dc:subject>#foreach($issue in $issues)$xmlutils.escape($issue.key)#if($velocityHasNext), #end#end</dc:subject>
</rdf:Description>
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>Better PDF Exporter for Jira - https://marketplace.atlassian.com/5167</xmp:CreatorTool>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
#if($embedAttachments)
#foreach($issue in $issues)
#foreach($attachment in $issue.attachments)
#if($attachment.filesize <= $embeddedAttachmentMaxFileSize)
#set($attachmentUrl = "${requestContext.canonicalBaseUrl}/secure/attachment/${attachment.id}/${urlcodec.encode($attachment.filename)}")
<pdf:embedded-file filename="${attachment.id}-$xmlutils.escape($attachment.filename)" src="url($attachmentUrl)" description="Attached to [$xmlutils.escape($issue.key)]"/>
#end
#end
#end
#end
</fo:declarations>
<fo:bookmark-tree >
#foreach($issue in $issues)
#if($velocityCount <= $maxIssues)
<fo:bookmark internal-destination="$xmlutils.escape($issue.key)" >
<fo:bookmark-title>$xmlutils.escape($issue.key)</fo:bookmark-title>
</fo:bookmark>
#end
#end
</fo:bookmark-tree>
#if($issues && !$issues.empty)
#foreach($issue in $issues)
#if($velocityCount <= $maxIssues)
#if(($velocityCount == 1) || $startIssuesOnNewPages)
<fo:page-sequence master-reference="A4-portrait" id="page-sequence-id">
<xsl:variable name="vPageNumber"><fo:page-number/></xsl:variable>
## header
<fo:static-content flow-name="page-header">
<fo:table border="solid">
<fo:table-column column-width="20%"/>
<fo:table-column column-width="67%"/>
<fo:table-column column-width="13%"/>
<fo:table-body>
<fo:table-row >
<fo:table-cell >
<fo:block text-align="center" margin-left="15px" padding-top="110px">
<fo:external-graphic content-width="210px" alignment-baseline="middle" src="url(D:/Atlassian/images/MANLogo.gif)" />
</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block font-size="15pt" text-align="center" margin-top="50px" >MAN TüRK?YE A.?.</fo:block>
<fo:block font-size="15pt" text-align="center">Test Laboratuvar?</fo:block>
<fo:block font-size="14pt" text-align="center" padding-top="120px">Test Raporu</fo:block>
<fo:block font-size="14pt" text-align="center" padding-top="120px"><fo:page-number/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block padding-right="15px" padding-bottom="2mm" padding-top="1mm">
<xsl:if test="$vPageNumber==1">
<fo:block text-align="right" margin-right="24px" >
<fo:external-graphic content-width="20mm" src="url(D:/Atlassian/images/Turkak.gif)" />
</fo:block>
</xsl:if>
<fo:table width="20mm" height="24mm" font-size="7pt" >
<fo:table-body>
<fo:table-row border="solid" height="8mm">
<fo:table-cell>
<fo:block text-align="center" padding="3mm" >
AB-1365-T
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="solid" height="8mm" >
<fo:table-cell>
<fo:block text-align="center" padding="3mm">$xmlutils.escape($issue.key)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="solid" height="8mm" >
<fo:table-cell>
<fo:block text-align="center" padding="3mm"> $date.format("MM-yy", $issue.getCustomFieldValue("customfield_17843"))</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
## footer
<fo:static-content flow-name="page-footer">
<fo:block border="solid">
<fo:table margin="1mm 1mm 1mm 1mm" >
<fo:table-column column-width="90%"/>
<fo:table-column column-width="10%"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block font-size="80%">1. Bu rapor, laboratuvar?n yaz?l? izni olmadan k?smen kopyalan? ?o?alt?lamaz.(This report shall not be reproduced other than in full except with the
permission of the laboratory)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block font-size="80%">2. Rapordaki test sonu?lar? laboratuvara mü?teri taraf?ndan teslim edilen ve yukar?da tan?mlanan numunelere aittir.(Results in this report refer only to those
samples submitted by the firm mentioned above)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block font-size="80%">3. (*)??aretli testler akreditasyon kapsam? d???ndad?r.(Tests marked (*) are outside the scope of accreditation schedule.)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell >
<fo:block font-size="80%">Aksi belirtilmedik?e ?l?üm belirsizli?i dikkate al?nmadan sonu? bildirilmi?tir.</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block font-size="80%">Sayfa <fo:page-number/>/<fo:page-number-citation-last ref-id="page-sequence-id"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block margin-top="2mm">
<fo:block text-align="center" font-size="85%">FOO</fo:block>
<fo:block text-align="center" font-size="85%">FOO</fo:block>
<fo:block text-align="center" font-size="85%">FOO</fo:block>
<fo:block text-align="center" font-size="85%">FOO</fo:block>
</fo:block>
</fo:static-content>
#if(($velocityCount == $issues.size()) || ($velocityCount == $maxIssues) || $startIssuesOnNewPages)
</fo:flow>
</fo:page-sequence>
#end
#end
#end
#else
<fo:page-sequence master-reference="A4-landscape">
<fo:flow flow-name="page-body" font-size="9pt">
<fo:block>No issues found</fo:block>
</fo:flow>
</fo:page-sequence>
#end
</fo:root>
我怎么能解決這個問題。謝謝指教。
uj5u.com熱心網友回復:
我認為您應該研究如何使用fo:page-sequence-master;定義一個使用標題圖形的“第一頁”母版,以及一個沒有該圖形的“剩余”頁母版。
例如,這可能會讓你走上正確的軌道https://www.xmlpdf.com/different-first-page.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/521252.html
上一篇:在片段中創建按鈕
下一篇:XML編輯替換/洗掉
