List of usage examples for com.itextpdf.text.html HtmlTags BODY
String BODY
To view the source code for com.itextpdf.text.html HtmlTags BODY.
Click Source Link
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public int createContentPagesConversation(Document document) throws DocumentException { float[][] COLUMNS; document.newPage();//from w w w . j a v a 2 s .c om ColumnText ct = new ColumnText(this.writer.getDirectContent()); this.currentColumn = 0; if (COLUMNS_REG[0][0] == Txtbook.leftMargin(this.writer, document, this.settings.addFrontCover)) { COLUMNS = COLUMNS_REG; } else { COLUMNS = COLUMNS_ALT; } ct.setSimpleColumn(COLUMNS[this.currentColumn][0], COLUMNS[this.currentColumn][1], COLUMNS[this.currentColumn][2], COLUMNS[this.currentColumn][3]); Cursor cursor = this.mContext.getContentResolver().query( Uri.parse("content://mms-sms/conversations/" + this.settings.threadId), new String[] { "_id", "ct_t", "normalized_date" }, "normalized_date >= " + this.settings.startDateMillis + " AND normalized_date <= " + this.settings.endDateMillis, null, "normalized_date"); Iterator<Integer> itr = this.settings.getSelectedRows().iterator(); while (itr.hasNext()) { if (cursor.moveToPosition(((Integer) itr.next()).intValue())) { String senderString; Boolean isMe; Long messageId = Long.valueOf(cursor.getLong(cursor.getColumnIndex("_id"))); String mimetype = cursor.getString(cursor.getColumnIndex("ct_t")); if (MMSUtilities.getMessageSenderType(this.mContext, messageId, mimetype) == 1) { senderString = this.settings.theirName; isMe = Boolean.valueOf(false); } else { senderString = this.settings.myName; isMe = Boolean.valueOf(true); } String contentString = PdfObject.NOTHING; Boolean isVideo = Boolean.valueOf(false); if ("application/vnd.wap.multipart.related".equals(mimetype)) { Cursor mmsCursor = this.mContext.getContentResolver().query(Uri.parse("content://mms/part"), null, "mid=" + messageId, null, null); Boolean hasNext = Boolean.valueOf(mmsCursor.moveToFirst()); while (hasNext.booleanValue()) { contentString = PdfObject.NOTHING; Bitmap contentImage = null; isVideo = Boolean.valueOf(false); String partId = mmsCursor.getString(mmsCursor.getColumnIndex("_id")); String mimetype2 = mmsCursor.getString(mmsCursor.getColumnIndex("ct")); if ("application/smil".equals(mimetype2)) { hasNext = Boolean.valueOf(mmsCursor.moveToNext()); } else { if (mimetype2.startsWith("image/")) { contentImage = MMSUtilities.getMmsImage(this.mContext, partId); } else { if (mimetype2.startsWith("text/")) { contentString = mmsCursor.getString(mmsCursor.getColumnIndex("_data")) != null ? MMSUtilities.getMmsText(this.mContext, partId) : mmsCursor.getString(mmsCursor.getColumnIndex("text")); } else { if (mimetype2.startsWith("video/")) { isVideo = Boolean.valueOf(true); contentImage = wrapVideoThumbnailWithFilm(this.mContext, MMSUtilities.getMmsVideoThumbnail(this.mContext, partId)); } else { contentString = mimetype2.startsWith("audio/") ? "[audio message]" : "[unknown message type]"; } } } doAddNextConversation(document, cursor, ct, senderString, contentString, contentImage, isVideo, isMe); hasNext = Boolean.valueOf(mmsCursor.moveToNext()); } } mmsCursor.close(); } else { Cursor smsCursor = this.mContext.getContentResolver().query(Uri.parse("content://sms"), new String[] { HtmlTags.BODY, LicenseKey.LICENSE_DATE }, "_id = " + messageId, null, null); if (smsCursor.moveToFirst()) { contentString = smsCursor.getString(smsCursor.getColumnIndex(HtmlTags.BODY)); } smsCursor.close(); doAddNextConversation(document, cursor, ct, senderString, contentString, null, Boolean.valueOf(false), isMe); } } } return 0; }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public int createContentPagesStorybook(Document document, String title) throws DocumentException { document.newPage();/*from w ww .jav a 2s . c o m*/ ((StorybookHeaderFooter) this.writer.getPageEvent()).addHeader(this.writer, document); Cursor cursor = this.mContext.getContentResolver().query( Uri.parse("content://mms-sms/conversations/" + this.settings.threadId), new String[] { "_id", "ct_t", "normalized_date" }, "normalized_date >= " + this.settings.startDateMillis + " AND normalized_date <= " + this.settings.endDateMillis, null, "normalized_date"); int i = 0; Long previousDate = null; String previousSenderString = PdfObject.NOTHING; Iterator<Integer> itr = this.settings.getSelectedRows().iterator(); while (itr.hasNext()) { if (cursor.moveToPosition(((Integer) itr.next()).intValue())) { Long messageId = Long.valueOf(cursor.getLong(cursor.getColumnIndex("_id"))); String mimetype = cursor.getString(cursor.getColumnIndex("ct_t")); int type = MMSUtilities.getMessageSenderType(this.mContext, messageId, mimetype); String senderString = this.settings.myName; String receiverString = this.settings.theirName; if (type == 1) { senderString = this.settings.theirName; receiverString = this.settings.myName; } String contentString = PdfObject.NOTHING; Boolean isVideo = Boolean.valueOf(false); Long date; if ("application/vnd.wap.multipart.related".equals(mimetype)) { Cursor mmsCursor = this.mContext.getContentResolver().query(Uri.parse("content://mms/part"), null, "mid=" + messageId, null, null); Boolean hasNext = Boolean.valueOf(mmsCursor.moveToFirst()); while (hasNext.booleanValue()) { contentString = PdfObject.NOTHING; Bitmap contentImage = null; isVideo = Boolean.valueOf(false); String partId = mmsCursor.getString(mmsCursor.getColumnIndex("_id")); String mimetype2 = mmsCursor.getString(mmsCursor.getColumnIndex("ct")); if ("application/smil".equals(mimetype2)) { hasNext = Boolean.valueOf(mmsCursor.moveToNext()); } else { if (mimetype2.startsWith("image/")) { contentImage = MMSUtilities.getMmsImage(this.mContext, partId); } else { if (mimetype2.startsWith("text/")) { contentString = mmsCursor.getString(mmsCursor.getColumnIndex("_data")) != null ? MMSUtilities.getMmsText(this.mContext, partId) : mmsCursor.getString(mmsCursor.getColumnIndex("text")); } else { if (mimetype2.startsWith("video/")) { isVideo = Boolean.valueOf(true); contentImage = wrapVideoThumbnailWithFilm(this.mContext, MMSUtilities.getMmsVideoThumbnail(this.mContext, partId)); } else { contentString = mimetype2.startsWith("audio/") ? "[audio message]" : "[unknown message type]"; } } } date = null; if (this.settings.useTimestamps.booleanValue()) { date = Long.valueOf(cursor.getLong(cursor.getColumnIndex("normalized_date"))); } try { addStorybookPart(document, i, date, previousDate, senderString, previousSenderString, receiverString, contentString, contentImage, isVideo); } catch (Exception e) { e.printStackTrace(); } previousDate = date; previousSenderString = senderString; hasNext = Boolean.valueOf(mmsCursor.moveToNext()); } } mmsCursor.close(); } else { Cursor smsCursor = this.mContext.getContentResolver().query(Uri.parse("content://sms"), new String[] { HtmlTags.BODY, LicenseKey.LICENSE_DATE }, "_id = " + messageId, null, null); if (smsCursor.moveToFirst()) { contentString = smsCursor.getString(smsCursor.getColumnIndex(HtmlTags.BODY)); } smsCursor.close(); date = null; if (this.settings.useTimestamps.booleanValue()) { date = Long.valueOf(cursor.getLong(cursor.getColumnIndex("normalized_date"))); } try { addStorybookPart(document, i, date, previousDate, senderString, previousSenderString, receiverString, contentString, null, Boolean.valueOf(false)); } catch (Exception e2) { e2.printStackTrace(); } previousDate = date; previousSenderString = senderString; } } i++; } return 0; }
From source file:com.ideationdesignservices.txtbook.sms.MessageListAdapter.java
public View buildView(View view, Context context, Cursor cursor, int type) { int position = cursor.getPosition(); TextView userNameTextView = (TextView) view.findViewById(R.id.userNameTextView); LinearLayout userMessageContent = (LinearLayout) view.findViewById(R.id.userMessageContent); userMessageContent.removeAllViews(); if (type == -1) { type = getItemViewType(position); }/*from w w w . ja v a 2 s . c o m*/ switch (type) { case Vector.I1 /*0*/: userNameTextView.setText(this.myName); userMessageContent.setGravity(3); view.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.conversation_cell_bg_dark)); break; case Vector.I2 /*1*/: userNameTextView.setText(this.theirName); userMessageContent.setGravity(5); view.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.conversation_cell_bg_light)); break; } Long date = Long.valueOf(0); LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, 150, 0.0f); layoutParams.setMargins(0, 0, 0, 10); layoutParams = new LinearLayout.LayoutParams(-2, -2, BaseField.BORDER_WIDTH_THIN); layoutParams.setMargins(0, 0, 0, 10); layoutParams = new LinearLayout.LayoutParams(26, 150, 0.0f); layoutParams.setMargins(0, 0, 0, 10); String string = cursor.getString(cursor.getColumnIndex("ct_t")); Bitmap mmsImage = null; Long messageId = Long.valueOf(cursor.getLong(cursor.getColumnIndex("_id"))); if (this.useTimestamps.booleanValue()) { date = Long.valueOf(cursor.getLong(cursor.getColumnIndex("normalized_date"))); } View textView; if ("application/vnd.wap.multipart.related".equals(string)) { String selectionPart = "mid=" + messageId; Cursor mmsCursor = context.getContentResolver().query(Uri.parse("content://mms/part"), null, selectionPart, null, null); for (Boolean hasNext = Boolean.valueOf(mmsCursor.moveToFirst()); hasNext .booleanValue(); hasNext = Boolean.valueOf(mmsCursor.moveToNext())) { try { String partId = mmsCursor.getString(mmsCursor.getColumnIndex("_id")); String mimetype = mmsCursor.getString(mmsCursor.getColumnIndex("ct")); if (!"application/smil".equals(mimetype)) { if (mimetype.startsWith("image/")) { mmsImage = MMSUtilities.getMmsImage(this.mContext, partId); ImageView imageView = new ImageView(context); imageView.setImageBitmap(mmsImage); imageView.setVisibility(0); imageView.setLayoutParams(layoutParams); imageView.setAdjustViewBounds(true); imageView.setContentDescription(context.getString(R.string.user_message_image)); userMessageContent.addView(imageView); if (mmsImage == null || this.usePhotos.booleanValue()) { imageView.setAlpha(BaseField.BORDER_WIDTH_THIN); } else { imageView.setAlpha(0.5f); } } else { if (mimetype.startsWith("text/")) { String body; if (mmsCursor.getString(mmsCursor.getColumnIndex("_data")) != null) { body = MMSUtilities.getMmsText(context, partId); } else { body = mmsCursor.getString(mmsCursor.getColumnIndex("text")); } textView = new TextView(context); textView.setLayoutParams(layoutParams); textView.setTextSize(14.0f); textView.setText(body); textView.setGravity(119); userMessageContent.addView(textView); } else { if (mimetype.startsWith("video/")) { mmsImage = MMSUtilities.getMmsVideoThumbnail(context, partId); textView = new LinearLayout(context); textView.setOrientation(0); textView.setLayoutParams(new RelativeLayout.LayoutParams(-2, -2)); textView = new ImageView(context); textView.setImageDrawable( context.getResources().getDrawable(R.drawable.film_strip_left)); textView.setLayoutParams(layoutParams); textView.setContentDescription(context.getString(R.string.user_message_image)); textView.addView(textView); textView = new ImageView(context); textView.setImageBitmap(mmsImage); textView.setVisibility(0); textView.setLayoutParams(layoutParams); textView.setAdjustViewBounds(true); textView.setContentDescription(context.getString(R.string.user_message_image)); textView.addView(textView); textView = new ImageView(context); textView.setImageDrawable( context.getResources().getDrawable(R.drawable.film_strip_right)); textView.setLayoutParams(layoutParams); textView.setContentDescription(context.getString(R.string.user_message_image)); textView.addView(textView); if (mmsImage == null || this.usePhotos.booleanValue()) { textView.setAlpha(BaseField.BORDER_WIDTH_THIN); } else { textView.setAlpha(0.5f); } userMessageContent.addView(textView); } else { if (mimetype.startsWith("audio/")) { textView = new TextView(context); textView.setLayoutParams(layoutParams); textView.setTextSize(14.0f); textView.setText("[audio message]"); textView.setGravity(119); userMessageContent.addView(textView); } else { textView = new TextView(context); textView.setLayoutParams(layoutParams); textView.setTextSize(14.0f); textView.setText("[unknown message type]"); textView.setGravity(119); userMessageContent.addView(textView); } } } } } } catch (OutOfMemoryError e) { } } mmsCursor.close(); } else { Cursor smsCursor = this.mContext.getContentResolver().query(Uri.parse("content://sms"), new String[] { HtmlTags.BODY, LicenseKey.LICENSE_DATE }, "_id = " + messageId, null, null); if (smsCursor.moveToFirst()) { textView = new TextView(context); textView.setLayoutParams(layoutParams); textView.setTextSize(14.0f); textView.setText(smsCursor.getString(smsCursor.getColumnIndex(HtmlTags.BODY))); textView.setGravity(119); userMessageContent.addView(textView); } smsCursor.close(); } TextView userDateTextView = (TextView) view.findViewById(R.id.userDateTextView); if (this.useTimestamps.booleanValue()) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM dd, yyyy h:mm a", Locale.US); simpleDateFormat.setTimeZone(TimeZone.getDefault()); userDateTextView.setText(simpleDateFormat.format(new Date(date.longValue()))); } CheckBox checkbox = (CheckBox) view.findViewById(R.id.userCheckBox); if (mmsImage == null || this.usePhotos.booleanValue()) { checkbox.setChecked( ((ConversationActivity) this.mContext).selectedRows.contains(Integer.valueOf(position))); checkbox.setEnabled(true); userNameTextView.setTextColor(-16777216); userDateTextView.setTextColor(Color.argb(100, 119, 119, 119)); } else { checkbox.setChecked(false); checkbox.setEnabled(false); userNameTextView.setTextColor(Color.argb(50, 0, 0, 0)); userDateTextView.setTextColor(Color.argb(50, 119, 119, 119)); } checkbox.setTag(Integer.valueOf(position)); checkbox.setOnClickListener(new OnClickListener() { public void onClick(View view) { Integer tagPosition = (Integer) view.getTag(); if (((CheckBox) view).isChecked()) { ((ConversationActivity) MessageListAdapter.this.mContext).selectedRows.add(tagPosition); } else { ((ConversationActivity) MessageListAdapter.this.mContext).selectedRows.remove(tagPosition); } ((ConversationActivity) MessageListAdapter.this.mContext).updateSelectOrClearAllButton(); } }); return view; }
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
/** * @see com.itextpdf.text.xml.simpleparser.SimpleXMLDocHandler#startDocument() *///from w w w . j a v a 2s. c o m public void startDocument() { HashMap<String, String> attrs = new HashMap<String, String>(); style.applyStyle(HtmlTags.BODY, attrs); chain.addToChain(HtmlTags.BODY, attrs); }