테이블에 텍스트가있는 바코드 이미지가 포함 된 pdf 파일을 만들고 싶습니다. 이 형식으로 만들 수 없습니다.안드로이드에서 iText를 사용하여 여러 비트 맵 이미지를 텍스트와 함께 테이블에 추가하는 방법은 무엇입니까?
PdfPTable table = new PdfPTable(qrCodeModelArrayList.size());
for (int i = 0; i < qrCodeModelArrayList.size(); i++) {
Bitmap bitmap = qrCodeModelArrayList.get(i).getQrBitMap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); //use the compression format of your need
InputStream is = new ByteArrayInputStream(stream.toByteArray());
Bitmap bmp = BitmapFactory.decodeStream(is);
ByteArrayOutputStream stream1 = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream1);
Image bitmapImage = null;
try {
bitmapImage = Image.getInstance(stream1.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
PdfPCell cell = new PdfPCell();
cell.addElement(bitmapImage);
Paragraph p = new Paragraph(qrCodeModelArrayList.get(i).getQrCodeName());
p.setAlignment(Element.ALIGN_CENTER);
cell.addElement(p);
table.addCell(cell);
}
아래 이 코드를 사용하는 경우
, 내가 가진 않았다 출력 :
내 바코드 이미지를 볼 수 없습니다이고 모든 열이 같은 행에 추가 . 5 열에 넣고 싶었어.
코드를 알려주십시오. –
이 질문은 [공식 FAQ] (http://developers.itextpdf.com/frequently-asked-developer-questions-7)에서 이미 답변되었습니다 : [동일한 셀에 이미지와 텍스트를 추가하는 방법] http://developers.itextpdf.com/content/best-itext-questions-stackoverview/tables/itext-how-add-image-and-text-same-cell) iText 5 답변이 필요한 경우 [이전 버전] (http://developers.itextpdf.com/question/how-add-image-and-text-same-cell). –
@AmedeeVanGasse 내 코드를 확인하십시오. –