Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfWriter


       
        // step 1: creation of a document-object
        LwgDocument document = new LwgDocument();
        try {
            // step 2:
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LocalDestination.pdf"));
            // step 3: we open the document
            document.open();
            // step 4: we add some content
            document.add(new Paragraph("Page 1"));
            document.newPage();
            document.add(new Paragraph("This PDF file jumps directly to page 2 when opened"));
            PdfContentByte cb = writer.getDirectContent();
            cb.localDestination("page2", new PdfDestination(PdfDestination.XYZ, -1, 10000, 0));
            writer.setOpenAction("page2");
        }
        catch (Exception de) {
            de.printStackTrace();
        }
       
View Full Code Here


    LwgDocument document = new LwgDocument();
    try {
      // step 2:
      // we create a writer that listens to the document
      // and directs a PDF-stream to a file
      PdfWriter writer = PdfWriter.getInstance(document,
          new FileOutputStream("HelloEncrypted.pdf"));
      writer.setEncryption("Hello".getBytes(), "World".getBytes(), PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING, PdfWriter.STANDARD_ENCRYPTION_128);
      // step 3: we open the document
      document.open();
      // step 4: we add a paragraph to the document
      document.add(new Paragraph("Hello World"));
    } catch (DocumentException de) {
View Full Code Here

    case ACT_REPORT_1: {
      LwgDocument document = new LwgDocument();
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      try {
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        document.open();
        if (requ.getParameter("preview") == null)
          writer.addJavaScript("this.print(false);", false);
        document.add(new Chunk("Silent Auto Print"));
        document.close();
      } catch (DocumentException e) {
        e.printStackTrace();
      }
View Full Code Here

        LwgRectangle rect = new LwgRectangle(LwgPageSize.A4);
        rect.setBackgroundColor(new Color(238, 221, 88));
        LwgDocument document = new LwgDocument(rect, 50, 50, 50, 50);
        try {
            // step 2: we create a writer that listens to the document
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("templateImages.pdf"));
            // step 3: we open the document
            document.open();
            // step 4:
            PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
            String text = "Vertical";
            float size = 16;
            float width = bf.getWidthPoint(text, size);
            template.beginText();
View Full Code Here

        try {
           
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("columnsimple.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4:
           
            // we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            LwgFont font = new LwgFont(bf, 11, LwgFont.NORMAL);
           
            ColumnText ct = new ColumnText(cb);
View Full Code Here

        try {
           
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("templates.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4: we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            // we create a PdfTemplate
            PdfTemplate template = cb.createTemplate(500, 200);
           
            // we add some graphics
View Full Code Here

      System.out.println("Automatic grouping and nesting");
        try {
          // step 1
            LwgDocument document = new LwgDocument(LwgPageSize.A4, 50, 50, 50, 50);
            // step 2
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("automatic.pdf"));
            writer.setPdfVersion(PdfWriter.VERSION_1_5);
            writer.setViewerPreferences(PdfWriter.PageModeUseOC);
            // step 3
            document.open();
            // step 4
            PdfContentByte cb = writer.getDirectContent();
            LwgPhrase explanation = new LwgPhrase("Automatic layer grouping and nesting", new LwgFont(LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50, 650, 0);
            PdfLayer l12 = new PdfLayer("Layer nesting", writer);
            PdfLayer l1 = new PdfLayer("Layer 1", writer);
            PdfLayer l2 = new PdfLayer("Layer 2", writer);
View Full Code Here

        LwgDocument document = new LwgDocument();
       
        try {
           
            // step 2: creation of the writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("layers.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4:
           
            // high level
            Paragraph p = new Paragraph();
            for (int i = 0; i < 100; i++) p.add(new Chunk("Blah blah blah blah blah. "));
            document.add(p);
            LwgImage img = LwgImage.getInstance("hitchcock.png");
            img.setAbsolutePosition(100, 500);
            document.add(img);
           
            // low level
            PdfContentByte cb = writer.getDirectContent();
            PdfContentByte cbu = writer.getDirectContentUnder();
            cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
            cb.circle(250.0f, 500.0f, 50.0f);
            cb.fill();
            cb.sanityCheck();
           
View Full Code Here

        // step 1: creation of a document-object
        LwgDocument document = new LwgDocument(LwgPageSize.A4);
       
        try {
            // step 2: creation of the writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("upsidedown.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4:
            PdfContentByte cb = writer.getDirectContent();
            cb.concatCTM(1f, 0f, 0f, -1f, 0f, LwgPageSize.A4.getHeight());
           
            // we create a PdfTemplate
            PdfTemplate template = cb.createTemplate(25, 25);
           
View Full Code Here

        LwgDocument document = new LwgDocument();
       
        try {
           
            // step 2: creation of the writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("text.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4: we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            // first we draw some lines to be able to visualize the text alignment functions
            cb.setLineWidth(0f);
            cb.moveTo(250, 500);
            cb.lineTo(250, 800);
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.