2016-09-09 38 views
2

のための不正な文字、私は次のコードで、iTextbarcode128を生成しようとしています:iTextのBarcode128 - バーコード

Barcode128 shipBarCode = new Barcode128(); 
shipBarCode.setCode(getOrder().getPartnerPurchaseOrderNumber()); 
shipBarCode.setBarHeight(40f); 

PdfPCell barCodeCell = new PdfPCell(); 
barCodeCell.addElement(
    shipBarCode.createImageWithBarcode(cb, BaseColor.BLACK, BaseColor.BLACK) 
); 
barCodeCell.setFixedHeight(55f); 
barCodeCell.setPaddingRight(15f); 
barCodeCell.setBorder(Rectangle.NO_BORDER); 
barCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER); 

table.addCell(barCodeCell); 

が、私は次の例外受けています:どうやら

java.lang.RuntimeException: There are illegal characters for barcode 128 in '509868_1_2_1'. 
at com.itextpdf.text.pdf.Barcode128.getRawText(Barcode128.java:518) 
at com.stuhrling.orderprocessing.partner.shopnbc.ShopNBCPackingSlip.getOrderInfoTable(ShopNBCPackingSlip.java:142) 
at com.stuhrling.orderprocessing.partner.shopnbc.ShopNBCPackingSlip.getPackingSlipElement(ShopNBCPackingSlip.java:610) 
at com.stuhrling.orderprocessing.label.PDFComboLabel.packingSlipCell(PDFComboLabel.java:131) 
at com.stuhrling.orderprocessing.label.PDFComboLabel.generateLabel(PDFComboLabel.java:87) 
at com.stuhrling.orderprocessing.OrderService.generatePackingSlip(OrderService.java:731) 
at com.stuhrling.orderprocessing.PackingSlipListener.handleMessage(PackingSlipListener.java:60) 
at com.stuhrling.orderprocessing.messaging.MessageListener.run(MessageListener.java:76) 
at java.lang.Thread.run(Thread.java:745) 

を、code 128はアンダースコアを読み取っていません..またはおそらくそれはiTextのバグですか?

iTextでこれを回避する方法を知っている人はいますか?

更新:


は:(

私は私のコードが悪いのだろうか...今私はさらに困惑して、それのバグ出しアンダースコアなしでものように見えます

私は数字だけを持っている場合にのみ起こります。文字を追加すると問題は消えます。

+0

Barcode128は永遠に正しく動作します。文字列に印刷できない文字がある可能性があります。いくつかのリテラルを直接PDFに生成してみてください。 –

+0

これと同じ結果が得られました。 – IntelliData

+0

こんにちは。私は他のタイトルのためのアイデアを提供するためのiTextに関して十分な知識がありませんが、もっと示唆的なものに変更することをお勧めします。そうでなければ、あなたの質問が誰かによって下落される可能性があります。 編集:このコメントを書いた直後に、タイトルが編集されました。気にしないで。 – SpaceCore186

答えて

0

私はこれについて正しいのか分かりませんが、バグかもしれません。スローiTextのバージョンは5.5.4 ある

if (codeSet != Barcode128CodeSet.AUTO && currentCode != codeSet.getStartSymbol()) 
     throw new RuntimeException(MessageLocalization.getComposedMessage("there.are.illegal.characters.for.barcode.128.in.1", text)); 

:これまで

if (currentCode != codeSet.getStartSymbol()) 
     throw new RuntimeException(MessageLocalization.getComposedMessage("there.are.illegal.characters.for.barcode.128.in.1", text)); 

:ぐふっiTextのは、私はこの(ライン442)に変更Barcode128.javaです。コードに精通している人がいれば、本当にバグかどうかを教えてください。

0

私はitextpdf 5.5.4バグだと思います。 5.5.12にアップグレードすると解決されます。

+0

これは質問に対する答えを提供しません。十分な[評判](https://stackoverflow.com/help/whats-reputation)があれば、[投稿にコメントする]ことができます(https://stackoverflow.com/help/privileges/comment)。代わりに、[質問者からの明確化を必要としない回答を提供する](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- i-do-代わりに)。 - [レビューより](/レビュー/低品質の投稿/ 17202595) – Aryan

関連する問題