Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfWriter$PdfTrailer


                firstPage.getWidth(c) / _dotsPerPoint,
                firstPage.getHeight(c) / _dotsPerPoint);
       
        com.lowagie.text.Document doc =
            new com.lowagie.text.Document(firstPageSize, 0, 0, 0, 0);
        PdfWriter writer = PdfWriter.getInstance(doc, os);
        if (_pdfEncryption != null) {
            writer.setEncryption(
                    _pdfEncryption.getUserPassword(), _pdfEncryption.getOwnerPassword(),
                    _pdfEncryption.getAllowedPrivileges(), _pdfEncryption.getEncryptionType());
        }
        doc.open();
       
View Full Code Here


      if (page.getBounds().getWidth() == 0 || page.getBounds().getHeight() == 0) {
        resize = true;
      }
      // Create a document in the requested ISO scale.
      Document document = new Document(page.getBounds(), 0, 0, 0, 0);
      PdfWriter writer;
      writer = PdfWriter.getInstance(document, baos);

      // Render in correct colors for transparent rasters
      writer.setRgbTransparencyBlending(true);

      // The mapView is not scaled to the document, we assume the mapView
      // has the right ratio.

      // Write document title and metadata
      document.open();
      PdfContext context = new PdfContext(writer);
      context.initSize(page.getBounds());
      // first pass of all children to calculate size
      page.calculateSize(context);
      if (resize) {
        // we now know the bounds of the document
        // round 'm up and restart with a new document
        int width = (int) Math.ceil(page.getBounds().getWidth());
        int height = (int) Math.ceil(page.getBounds().getHeight());
        page.getConstraint().setWidth(width);
        page.getConstraint().setHeight(height);
        document = new Document(new Rectangle(width, height), 0, 0, 0, 0);
        writer = PdfWriter.getInstance(document, baos);
        // Render in correct colors for transparent rasters
        writer.setRgbTransparencyBlending(true);
        document.open();
        baos.reset();
        context = new PdfContext(writer);
        context.initSize(page.getBounds());
      }
View Full Code Here

  public void exportElement(JRPdfExporterContext exporterContext,
      JRGenericPrintElement element)
  {
    try
    {
      PdfWriter writer = exporterContext.getPdfWriter();
      PdfIndirectObject swfRef;
      boolean newContext = !existingContexts.containsKey(exporterContext);
      if (newContext)
      {
        // add the Adobe 1.7 extensions catalog dictionary
        PdfDictionary extensions = new PdfDictionary();
        PdfDictionary adobeExtension = new PdfDictionary();
        adobeExtension.put(new PdfName("BaseVersion"), PdfWriter.PDF_VERSION_1_7);
        adobeExtension.put(new PdfName("ExtensionLevel"), new PdfNumber(3));
        extensions.put(new PdfName("ADBE"), adobeExtension);
        writer.getExtraCatalog().put(new PdfName("Extensions"), extensions);
       
        // add the swf file
        byte[] swfData = readSwf();
        PdfFileSpecification swfFile = PdfFileSpecification.fileEmbedded(writer,
            null, "Open Flash Chart", swfData);
        swfRef = writer.addToBody(swfFile);
        existingContexts.put(exporterContext, swfRef);
      }
      else
      {
        swfRef = (PdfIndirectObject) existingContexts.get(exporterContext);
      }
     
      Rectangle rect = new Rectangle(element.getX() + exporterContext.getOffsetX(),
          exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY(),
          element.getX() + exporterContext.getOffsetX() + element.getWidth(),
          exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight());
      PdfAnnotation ann = new PdfAnnotation(writer, rect);
      ann.put(PdfName.SUBTYPE, new PdfName("RichMedia"));
     
      PdfDictionary settings = new PdfDictionary();
      PdfDictionary activation = new PdfDictionary();
      activation.put(new PdfName("Condition"), new PdfName("PV"));
      settings.put(new PdfName("Activation"), activation);
      ann.put(new PdfName("RichMediaSettings"), settings);
     
      PdfDictionary content = new PdfDictionary();
     
      HashMap assets = new HashMap();
      assets.put("map.swf", swfRef.getIndirectReference());
      PdfDictionary assetsDictionary = PdfNameTree.writeTree(assets, writer);
      content.put(new PdfName("Assets"), assetsDictionary);
     
      PdfArray configurations = new PdfArray();
      PdfDictionary configuration = new PdfDictionary();
     
      PdfArray instances = new PdfArray();
      PdfDictionary instance = new PdfDictionary();
      instance.put(new PdfName("Subtype"), new PdfName("Flash"));
      PdfDictionary params = new PdfDictionary();
     
      String chartData = (String) element.getParameterValue(PARAMETER_CHART_DATA);
      String vars = "inline_data=" + chartData;
      params.put(new PdfName("FlashVars"), new PdfString(vars));
      instance.put(new PdfName("Params"), params);
      instance.put(new PdfName("Asset"), swfRef.getIndirectReference());
      PdfIndirectObject instanceRef = writer.addToBody(instance);
      instances.add(instanceRef.getIndirectReference());
      configuration.put(new PdfName("Instances"), instances);
     
      PdfIndirectObject configurationRef = writer.addToBody(configuration);
      configurations.add(configurationRef.getIndirectReference());
      content.put(new PdfName("Configurations"), configurations);
     
      ann.put(new PdfName("RichMediaContent"), content);
     
      writer.addAnnotation(ann);
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
View Full Code Here

      tagHelper.init(pdfContentByte);
     
      initBookmarks();

      PdfWriter imageTesterPdfWriter =
        PdfWriter.getInstance(
          imageTesterDocument,
          new NullOutputStream() // discard the output
          );
      imageTesterDocument.open();
      imageTesterDocument.newPage();
      imageTesterPdfContentByte = imageTesterPdfWriter.getDirectContent();
      imageTesterPdfContentByte.setLiteral("\n");

      for(reportIndex = 0; reportIndex < jasperPrintList.size(); reportIndex++)
      {
        setJasperPrint((JasperPrint)jasperPrintList.get(reportIndex));
View Full Code Here

  public void write(OutputStream outputStream) throws IOException {
    PageFormat pageFormat = HomePrintableComponent.getPageFormat(this.home.getPrint());
    Document pdfDocument = new Document(new Rectangle((float)pageFormat.getWidth(), (float)pageFormat.getHeight()));
    try {
      // Get a PDF writer that will write to the given PDF output stream
      PdfWriter pdfWriter = PdfWriter.getInstance(pdfDocument, outputStream);
      pdfDocument.open();
     
      // Set PDF document description
      pdfDocument.addAuthor(System.getProperty("user.name", ""));
      String pdfDocumentCreator = this.preferences.getLocalizedString(
          HomePDFPrinter.class, "pdfDocument.creator");   
      pdfDocument.addCreator(pdfDocumentCreator);
      pdfDocument.addCreationDate();
      String homeName = this.home.getName();
      if (homeName != null) {
        pdfDocument.addTitle(this.controller.getContentManager().getPresentationName(
            homeName, ContentManager.ContentType.PDF));
      }
     
      PdfContentByte pdfContent = pdfWriter.getDirectContent();
      HomePrintableComponent printableComponent =
          new HomePrintableComponent(this.home, this.controller, this.defaultFont);
      // Print each page
      for (int page = 0, pageCount = printableComponent.getPageCount(); page < pageCount; page++) {
        // Check current thread isn't interrupted
View Full Code Here

      //process s1;
      List<process> list=main.viewRecord(temp);
     
      System.out.println(list.size());
     
      PdfWriter writer=PdfWriter.getInstance(doc, ba);
//      com.lowagie.text.Image image = com.lowagie.text.Image
//          .getInstance("c:/smi-logo.gif");
//          image.setBorder(1);
//          image.scaleAbsolute(100, 100);
//          image.setAbsolutePosition(450, 730);
View Full Code Here

            pf.setOrientation(PageFormat.PORTRAIT);
            pf.setPaper(paper);
            fmt.format(pf);
            Document document = new Document(new Rectangle(
                    (float) bounds.getWidth(), (float) bounds.getHeight()));
            PdfWriter writer = PdfWriter.getInstance(document, out);
            document.open();
            for (int i = 0; i < pageStore.getPageCount(); ++i) {
                document.newPage();
                PdfContentByte pcb = writer.getDirectContent();
                Graphics2D g = pcb.createGraphics(
                        (float) pf.getWidth(), (float) pf.getHeight());
                Page page = pageStore.getPage(i);
                page.resolveForwards(context);
                page.draw(g, drawable.getX(), drawable.getY(),
                        drawable.getHeight());
                g.dispose();
            }
            document.close();
            writer.close();
            pageStore.close();
        } catch (DocumentException e) {
            throw new IOException(e.getMessage());
        }
    }
View Full Code Here

    public void export(File file, SketchDocument doc) {
        try {
            Rectangle pageSize = new Rectangle((int)doc.getWidth(),(int)doc.getHeight());
            Document pdf = new Document(pageSize);
            PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(file));
            pdf.addCreator("Leonardo Sketch");
            pdf.open();
            ExportProcessor.process(new PDFExporter(pdf), writer, doc);
            pdf.close();
        } catch (DocumentException e) {
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(pdfPath));

      // step 3: we open the document
      document.open();

      // step 4: we create a template and a Graphics2D object that
      // corresponds with it
      int w = printPageSize.width;
      int h = printPageSize.height;
      PdfContentByte cb = writer.getDirectContent();
      PdfTemplate tp = cb.createTemplate(w, h);
      Graphics2D g2 = tp.createGraphics(w, h);
      tp.setWidth(w);
      tp.setHeight(h);
View Full Code Here

            //Basic setup of the Document, and get instance of the iText Graphics2D
            //   to pass along to uDig's standard "printing" code.
            String outputFile = page1.getDestinationDir()+
                System.getProperty("file.separator")+ //$NON-NLS-1$
                page1.getOutputFile();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));
            document.open();           
            Graphics2D graphics = null;
            Template template = getTemplate();
           
            int i = 0;
            int numPages = 1;
            do {
               
                //sets the active page
                template.setActivePage(i);
               
                PdfContentByte cb = writer.getDirectContent();    
               
                Page page = makePage(pageSize, document, template);
               
                graphics = cb.createGraphics(pageSize.getWidth(), pageSize.getHeight());
                        
                //instantiate a PrinterEngine (pass in the Page instance)
                PrintingEngine engine = new PrintingEngine(page);
               
                //make page format
                PageFormat pageFormat = new PageFormat();
                pageFormat.setOrientation(PageFormat.PORTRAIT);
                java.awt.print.Paper awtPaper = new java.awt.print.Paper();
                awtPaper.setSize(pageSize.getWidth() * 3, pageSize.getHeight() *3);
                awtPaper.setImageableArea(0, 0, pageSize.getWidth(), pageSize.getHeight());
                pageFormat.setPaper(awtPaper);
               
                //run PrinterEngine's print function
                engine.print(graphics, pageFormat, 0);
                 
                graphics.dispose();
                document.newPage();
                if (i == 0) {
                    numPages = template.getNumPages();
                }
                i++;
               
            } while (i < numPages);
           
            //cleanup
            document.close();
            writer.close();
        }
        catch (DocumentException e) {
            e.printStackTrace();
            return false;
        }
View Full Code Here

TOP

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

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.