Package com.lowagie.text

Examples of com.lowagie.text.Document


    }
    DefaultTableModel model = new DefaultTableModel(data, col);
    table = new JTable(model);
    try {
      int count = table.getRowCount();
      Document document = new Document();
      File file = new File(fileDir);
      if (file.exists()) {
        if (file.delete()) {
          PdfWriter.getInstance(document, new FileOutputStream(
              fileDir));
        } else {
          Utils.showErrorMessage("Lütfen dosyayı kapatıp tekrar deneyiniz !");
          return;
        }
      } else {
        PdfWriter.getInstance(document, new FileOutputStream(fileDir));
      }

      String date = new SimpleDateFormat("dd/MM/yyyy").format(new Date())
          .toString();
      String headerString = "Rapor Tarihi: " + date + "          "
          + "ALTISOFT /" + "  "
          + "www.altisoft.com.tr / info@altisoft.com.tr";

      HeaderFooter hf = new HeaderFooter(new Phrase(headerString), false);
      document.setFooter(hf);
      document.open();
      BaseFont bf = BaseFont.createFont("C:\\WINDOWS\\Fonts\\Arial.ttf",
          BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
      Font f1 = new Font(bf, 10);
      Paragraph paragraph = new Paragraph("SATIŞ RAPORU", f1);
      paragraph.setFont(new Font(14));
      paragraph.setSpacingAfter(20);
      paragraph.setAlignment(Element.ALIGN_CENTER);
      document.add(paragraph);
      Calendar calIlk = Calendar.getInstance();
      calIlk.setTime(ilkTarih.getDate());
      int ilkDay = calIlk.get(Calendar.DAY_OF_MONTH);
      int ilkMounth = calIlk.get(Calendar.MONTH) + 1;
      int ilkYear = calIlk.get(Calendar.YEAR);
      calIlk.setTime(sonTarih.getDate());
      int sonDay = calIlk.get(Calendar.DAY_OF_MONTH);
      int sonMounth = calIlk.get(Calendar.MONTH) + 1;
      int sonYear = calIlk.get(Calendar.YEAR);
      Paragraph tarih = new Paragraph("Baslangıç Tarihi" + "  " + ilkDay
          + "/" + ilkMounth + "/" + ilkYear + "    Bitiş Tarihi  "
          + sonDay + "/" + sonMounth + "/" + sonYear, f1);
      tarih.setFont(new Font(8));
      tarih.setSpacingAfter(20);
      tarih.setAlignment(Element.ALIGN_LEFT);
      document.add(tarih);
      PdfPTable tab = new PdfPTable(table.getColumnCount());

      tab.setWidthPercentage(100);

      for (int i = 0; i < table.getColumnCount(); i++) {
        PdfPCell cell = new PdfPCell(new Paragraph(
            table.getColumnName(i), f1));
        tab.addCell(cell);

      }
      Font f2 = new Font(bf, 8);
      for (int i = 0; i < count; i++) {
        for (int j = 0; j < table.getColumnCount(); j++) {
          Object obj1 = GetData(table, i, j);
          String value1 = obj1.toString();
          PdfPCell cell = new PdfPCell(new Paragraph(value1, f2));
          tab.addCell(cell);
        }
      }
      document.add(tab);

      Paragraph kdvTutarParag = new Paragraph("Toplam KDV Tutarı : "
          + kdvTutari.getText() + " TL");
      kdvTutarParag.setFont(new Font(10));
      kdvTutarParag.setSpacingBefore(20);
      kdvTutarParag.setAlignment(Element.ALIGN_RIGHT);
      document.add(kdvTutarParag);
      Paragraph iskontoTutarParag = new Paragraph(
          "Toplam İskonto Tutarı : " + iskontoTutari.getText()
              + " TL");
      iskontoTutarParag.setFont(new Font(10));
      iskontoTutarParag.setSpacingBefore(0);
      iskontoTutarParag.setAlignment(Element.ALIGN_RIGHT);
      document.add(iskontoTutarParag);
      Paragraph genelToplamParag = new Paragraph("Genel Toplam : "
          + genelToplam.getText() + " TL");
      genelToplamParag.setFont(new Font(10));
      genelToplamParag.setSpacingBefore(0);
      genelToplamParag.setAlignment(Element.ALIGN_RIGHT);
      document.add(genelToplamParag);

      document.close();
      File pdfFile = new File(fileDir);

      if (pdfFile.exists()) {

        if (Desktop.isDesktopSupported()) {
View Full Code Here


     * No param instance. Used if PDF is to be created as a byte stream.
     *
     * @throws TextMarkerException
     */
    public PdfProcessor() throws TextMarkerException {
        document = new Document(pageSize, Constants.DEFAULT_LEFT_MARGIN,
                                Constants.DEFAULT_RIGHT_MARGIN,
                                Constants.DEFAULT_TOP_MARGIN,
                                Constants.DEFAULT_BOTTOM_MARGIN);

        byteStream = new ByteArrayOutputStream();
View Full Code Here

     */
    public PdfProcessor(String fileOutput, String ftlTemplate,
            String templateDir, String tagmap, Map<String, Object> data,
            PdfPageEventHelper ev) throws TextMarkerException {
        this.data = data;
        document = new Document(pageSize, Constants.DEFAULT_LEFT_MARGIN,
                                Constants.DEFAULT_RIGHT_MARGIN,
                                Constants.DEFAULT_TOP_MARGIN,
                                Constants.DEFAULT_BOTTOM_MARGIN);

        PdfWriter writer = null;
View Full Code Here

        Map results = ServiceUtil.returnSuccess();
        String surveyResponseId = (String)context.get("surveyResponseId");
        String contentId = (String)context.get("contentId");
        String surveyId = null;

        Document document = new Document();
        try {
            if (UtilValidate.isNotEmpty(surveyResponseId)) {
                GenericValue surveyResponse = delegator.findByPrimaryKey("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId));
                if (surveyResponse != null) {
                    surveyId = surveyResponse.getString("surveyId");
                }
            }
            if (UtilValidate.isNotEmpty(surveyId) && UtilValidate.isEmpty(contentId)) {
                GenericValue survey = delegator.findByPrimaryKey("Survey", UtilMisc.toMap("surveyId", surveyId));
                if (survey != null) {
                    String acroFormContentId = survey.getString("acroFormContentId");
                    if (UtilValidate.isNotEmpty(acroFormContentId)) {
                        context.put("contentId", acroFormContentId);
                    }
                }
            }

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, baos);

            List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId));
            Iterator iter = responses.iterator();
            while (iter.hasNext()) {
                String value = null;
                GenericValue surveyResponseAnswer = (GenericValue) iter.next();
                String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId");
                GenericValue surveyQuestion = delegator.findByPrimaryKey("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId));
                String questionType = surveyQuestion.getString("surveyQuestionTypeId");
                // DEJ20060227 this isn't used, if needed in the future should get from SurveyQuestionAppl.externalFieldRef String fieldName = surveyQuestion.getString("description");
                if ("OPTION".equals(questionType)) {
                    value = surveyResponseAnswer.getString("surveyOptionSeqId");
                } else if ("BOOLEAN".equals(questionType)) {
                    value = surveyResponseAnswer.getString("booleanResponse");
                } else if ("NUMBER_LONG".equals(questionType) || "NUMBER_CURRENCY".equals(questionType) || "NUMBER_FLOAT".equals(questionType)) {
                    Double num = surveyResponseAnswer.getDouble("numericResponse");
                    if (num != null) {
                        value = num.toString();
                    }
                } else if ("SEPERATOR_LINE".equals(questionType) || "SEPERATOR_TEXT".equals(questionType)) {
                    // not really a question; ingore completely
                } else {
                    value = surveyResponseAnswer.getString("textResponse");
                }
                Chunk chunk = new Chunk(surveyQuestion.getString("question") + ": " + value);
                Paragraph p = new Paragraph(chunk);
                document.add(p);
            }
            ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray());
            results.put("outByteBuffer", outByteBuffer);
        } catch (GenericEntityException e) {
            System.err.println(e.getMessage());
View Full Code Here

        Map results = ServiceUtil.returnSuccess();
        String surveyResponseId = (String)context.get("surveyResponseId");
        String surveyId = null;
        List qAndA = FastList.newInstance();

        Document document = new Document();
        try {
            if (UtilValidate.isNotEmpty(surveyResponseId)) {
                GenericValue surveyResponse = delegator.findByPrimaryKey("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId));
                if (surveyResponse != null) {
                    surveyId = surveyResponse.getString("surveyId");
View Full Code Here

public class PDFExporter extends Exporter {

  @Override
  public void export(FacesContext context, DataTable table, String filename, boolean pageOnly, int[] excludeColumns, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor) throws IOException {
    try {
          Document document = new Document();
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PdfWriter.getInstance(document, baos);
         
          if(preProcessor != null) {
          preProcessor.invoke(context.getELContext(), new Object[]{document});
        }

            if(!document.isOpen()) {
                document.open();
            }
         
      PdfPTable pdfTable = exportPDFTable(context, table, pageOnly,excludeColumns, encodingType);
        document.add(pdfTable);
       
        if(postProcessor != null) {
          postProcessor.invoke(context.getELContext(), new Object[]{document});
        }
       
          document.close();
       
          writePDFToResponse(((HttpServletResponse) context.getExternalContext().getResponse()), baos, filename);
         
    } catch (DocumentException e) {
      throw new IOException(e.getMessage());
View Full Code Here

    public Document getDocument() {
        return document;
    }

    public void startDocumentInternal(OutputStream outputStream) throws IOException {
        document = new Document();

        try {
            PdfWriter.getInstance(document, outputStream);
        } catch (DocumentException ex) {
            throw new IOException(ex);
View Full Code Here

    @Override
    public void encodeBegin(FacesContext ctx,
            UIComponent component) throws IOException {
        PdfResponseWriter writer = (PdfResponseWriter) FacesContext.getCurrentInstance().getResponseWriter();
        Document document = writer.getDocument();
        FormBuilderPdf formBuilder = (FormBuilderPdf) component;
        Form form = formBuilder.getForm();
        encodePdf(form, document);
    }
View Full Code Here

    @Override
    public void encodeBegin(FacesContext ctx,
            UIComponent component) throws IOException {
        PdfResponseWriter writer = (PdfResponseWriter) FacesContext.getCurrentInstance().getResponseWriter();
        Document document = writer.getDocument();
        FormFillerPdf formFiller = (FormFillerPdf) component;
        FormData formData = formFiller.getFormData();
        encodePdf(formData, document, formFiller.getMode(), formFiller.getWorkflowState(), formFiller.getConstraintClient());
    }
View Full Code Here

        {
            // Initialize the table with the appropriate number of columns
            initTable();

            // Initialize the Document and register it with PdfWriter listener and the OutputStream
            Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
            document.addCreationDate();
            HeaderFooter footer = new HeaderFooter(new Phrase(TagConstants.EMPTY_STRING, smallFont), true);
            footer.setBorder(Rectangle.NO_BORDER);
            footer.setAlignment(Element.ALIGN_CENTER);

            PdfWriter.getInstance(document, out);

            // Fill the virtual PDF table with the necessary data
            generatePDFTable();
            document.open();
            document.setFooter(footer);
            document.add(this.tablePDF);
            document.close();

        }
        catch (Exception e)
        {
            throw new PdfGenerationException(e);
View Full Code Here

TOP

Related Classes of com.lowagie.text.Document

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.