package com.qoppa; import android.app.Activity; import android.graphics.Color; import android.graphics.Paint.Style; import android.os.Bundle; import android.util.Log; import com.qoppa.android.pdfProcess.PDFCanvas; import com.qoppa.android.pdfProcess.PDFDocument; import com.qoppa.android.pdfProcess.PDFFont; import com.qoppa.android.pdfProcess.PDFFontStandard; import com.qoppa.android.pdfProcess.PDFPage; import com.qoppa.android.pdfProcess.PDFPaint; import com.qoppa.android.pdfProcess.PDFFontStandard.PDFFontFamily; import com.qoppa.android.pdfViewer.fonts.StandardFontTF; import com.qoppa.notes.QPDFNotesView; public class AddTextSample extends Activity { protected void onCreate(Bundle bundle) { super.onCreate(bundle); StandardFontTF.mAssetMgr = getAssets(); try { PDFDocument pdfDoc = new PDFDocument(); PDFPage page = pdfDoc.appendNewPage(8.5f*72, 11f*72); PDFCanvas pdfCanvas = page.createCanvas(); PDFFontStandard fontNormalHelv = new PDFFontStandard(PDFFontFamily.HELVETICA, PDFFont.Style.NORMAL, 12); PDFFontStandard largeBoldCourier = new PDFFontStandard(PDFFontFamily.COURIER, PDFFont.Style.BOLD, 32); PDFFontStandard smallItalicTimes = new PDFFontStandard(PDFFontFamily.TIMESROMAN, PDFFont.Style.ITALIC, 8); pdfCanvas.drawText("normal helvetica", Color.BLACK, 50, 10, fontNormalHelv); pdfCanvas.drawText("blue large bold courier", Color.BLUE, 50, 50, largeBoldCourier); pdfCanvas.drawText("red small italic times", Color.RED, 50, 100, smallItalicTimes); pdfCanvas.drawText("underlined helvetica", Color.BLACK, 50, 150, fontNormalHelv); PDFPaint paint = new PDFPaint(); paint.setStrokeWidth(.25f); paint.setStrokeColor(Color.BLACK); float width = fontNormalHelv.getTextPaint().measureText("underlined helvetica"); pdfCanvas.drawLine(50, 150, 50+width, 150, paint); pdfDoc.saveCopy("/sdcard/textsample.pdf"); } catch (Throwable t) { Log.e("", Log.getStackTraceString(t)); } } }