import java.io.BufferedReader; import java.io.FileOutputStream;
import java.io.FileReader; import com.lowagie.text.Annotation; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Image; import com.lowagie.text.PageSize; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.TextElementArray; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.ColumnText; import com.lowagie.text.pdf.PdfAnnotation; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfCopy; import com.lowagie.text.pdf.PdfFileSpecification; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfStamper; import com.lowagie.text.pdf.PdfWriter; import de.mwag.pageunits; public class image { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { // we create a PdfReader object PdfReader reader = new PdfReader("template2.pdf"); // step 1 Document document = new Document(reader.getPageSize(1)); // step 2 //PdfCopy copy = new PdfCopy(document, new FileOutputStream("t123.pdf")); //copy.addPage(copy.getImportedPage(reader, 1)); // step 3 // document.open(); // step 4 System.out.println("Tampered? " + reader.isTampered()); // copy.addPage(copy.getImportedPage(reader, 1)); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream( "z123.pdf")); stamper.getWriter().setPdfVersion(PdfWriter.VERSION_1_7); PdfContentByte over; over = stamper.getOverContent(1); over.beginText(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); over.setFontAndSize(bf, 18); over.moveText(0, -20); over.setTextMatrix(pageunits.mm(30), pageunits.mm(80)); over.showText("HuLLO Alle "); over.endText(); //########################### BILD ################### /* Image pic = Image.getInstance("00000D22.jpg"); pic.scaleToFit(200, 200); pic.setAbsolutePosition(pageunits.mm(60), pageunits.mm(60)); over.addImage(pic); // ########################### Video ################### /* PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(stamper.getWriter(), "foxdog.mpg", "foxdog.mpg", null); stamper.addAnnotation(PdfAnnotation.createScreen(stamper.getWriter(), new Rectangle(pageunits.mm(160), pageunits.mm(160), pageunits.mm(160), pageunits.mm(160)), "Fox and Dog", fs, "video/mpeg", true), 1); */ // ########################### Video ################### PdfContentByte cb2 = over; Annotation a5 = new Annotation(pageunits.mm(160), pageunits.mm(160), pageunits.mm(160), pageunits.mm(160), "demo1.swf", "application/x-shockwave-flash", true); cb2.rectangle(100, 700, 100, 100); stamper.getWriter().add(a5); PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(stamper.getWriter(), "demo1.swf", "demo1.swf", null); stamper.addAnnotation(PdfAnnotation.createScreen(stamper.getWriter(), new Rectangle(pageunits.mm(60), pageunits.mm(60), pageunits.mm(60), pageunits.mm(60)), "Fox and Dog", fs, "application/x-shockwave-flash", true), 1); // ######################### Spalten ################# StringBuffer sb = new StringBuffer(1024); BufferedReader reader2 = new BufferedReader(new FileReader( "caesar.txt")); int c; while ((c = reader2.read()) > -1) { sb.append((char) c); } reader.close(); ColumnText ct = new ColumnText(over); ct.setLeading(30); ct.setAlignment(Element.ALIGN_JUSTIFIED); ct.setText(new Phrase(sb.toString())); float[] left = { 36, (400 / 2) + 18 }; float[] right = { (400 / 2) - 18, PageSize.A4.getWidth() - 36 }; int status = ColumnText.START_COLUMN; int column = 0; while (ColumnText.hasMoreText(status)) { ct.setSimpleColumn(left[column], 36, right[column], PageSize.A4.getHeight() - 36); status = ct.go(); column++; if (column > 1) { column = 0; } } // stamper.insertPage(3, PageSize.A4); // copy.close(); // document.close(); stamper.close(); } catch (Exception e){ e.printStackTrace(); } } } --> pageunits.mm converts millimeter it pt ----- Original Message ----- From: "Bruno Lowagie" <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <itext-questions@lists.sourceforge.net> Sent: Tuesday, January 22, 2008 1:13 PM Subject: Re: [iText-questions] Problem: Stamper and Annotation for embeding a SWF doen´t work right > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ -------------------------------------------------------------------------------- > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/