ラベル Hyperlink/ハイパーリンク の投稿を表示しています。 すべての投稿を表示
ラベル Hyperlink/ハイパーリンク の投稿を表示しています。 すべての投稿を表示

2011/03/10

QRコード (QR code)

QRコードの差込表示を検証します。
BI Publisher本体にはQRコードを生成する機能が実装されていません。今回のサンプルでは、QRコードの生成にはGoogle Chart APIを使用します。なお、画像の挿入については「画像の表示(URLによる画像の動的切替)」を併せて参照してください。
※帳票出力のプロダクトとして仮にも「Publisher」の名を冠するのであれば、QRコード程度の機能実装はしておいてほしいものです。


テンプレートに200px × 200px の画像を用意し、Web欄に以下のソースを記載します。
url:{'http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://yahoo.co.jp/'}

テンプレート上の画像はレイアウトに合わせて適宜調整します。実行結果は以下の通りです。





値を動的に埋め込む場合、以下の書式では実行時に列(QRY_TEXT)の値を受け渡すことができませんでした。
url:{concat('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://www.bing.com/search?q=%22', QRY_TEXT, '%22')}


試行錯誤の末、一度列の値を変数に代入することで回避できました。フィールドに以下のコードを記述し、列QRY_TEXTの値を変数valTextに代入します。
<xsl:variable name="valText"><?QRY_TEXT?></xsl:variable>

画像のWebタブにて、以下のように設定します。
url:{concat('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://www.bing.com/search?q=%22', $valText, '%22')}



なお、URLを生成する際は、URLエンコードを終えておく必要があります。


【補足】
手元の環境でQRコードをPDFに出力し、印刷を行った限りでは、出力精度に問題は認められませんでした。しかしながら、商用サービスでの運用に際しては、事前に出力結果の検査を行うことをお勧めします。


[ Summary]
The example above gets QR code from Google API.  Put a dummy image (200px * 200px) and write the code on its Web tab.  i.e. BI Publisher handles QR code as image.
url:{'http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://yahoo.co.jp/'}

The code below doesn't work.
url:{concat('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://www.bing.com/search?q=%22', QRY_TEXT, '%22')}

Workaround:
1. put your value into a variable.
<xsl:variable name="valText"><?QRY_TEXT?></xsl:variable>

2. On the Web tab of dummy image, put the code below.  The variable valText is set instead of data element QRY_TEXT.
url:{concat('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http://www.bing.com/search?q=%22', $valText, '%22')}

2011/03/09

ハイパーリンク (Hyperlink)

出力結果にハイパーリンクを埋め込むには、MS-Wordのダイアログから埋め込む方法と、フィールドにコードを記述する方法の2種類があります。


【MS-Wordのダイアログを利用する方法】
MS-Wordのメニューから新規にハイパーリンクを挿入します。


データ項目の指定方法が、表示文字列とアドレスの設定で異なります。
表示文字列: <?EMPNO?>
アドレス: http://empsrv.company.com/emp.jsp?empnumber={EMPNO}
※もちろん、固定文字列でもOKです。


【フィールドにする方法】
フィールドのプロパティに以下のコードを記述します。


<fo:basic-link>
<xsl:attribute name="external-destination">http://empsrv.company.com/emp.jsp?empnumber=<xsl:value-of select="EMPNO"/>
</xsl:attribute>
<xsl:value-of select="EMPNO"/>
</fo:basic-link>



[ Summary ]
There are two ways to embed hyperlinks in RTF template.  The examples above results in same output.  You can set URL text on runtime.
1) Use MS-Word dialog (the first figure)
2) Write basic-link tags in field property (the second figure)