Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.RandomAccessFileOrArray


     * @throws Exception
     */
    private void executeBurst(SplitParsedCommand inputCommand) throws Exception {
        int currentPage;
        Document currentDocument;
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),
                inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();

        // we retrieve the total number of pages
View Full Code Here


     *
     * @param inputCommand
     * @throws Exception
     */
    private void executeSplitOddEven(SplitParsedCommand inputCommand) throws Exception {
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),
                inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();

        // we retrieve the total number of pages
View Full Code Here

     * @param bookmarksTable
     *            bookmarks table. It's populated only when splitting by bookmarks. If null or empty it's ignored
     * @throws Exception
     */
    private void executeSplit(SplitParsedCommand inputCommand, Hashtable bookmarksTable) throws Exception {
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),
                inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();

        int n = pdfReader.getNumberOfPages();
View Full Code Here

     * @throws Exception
     */
    private void executeNSplit(SplitParsedCommand inputCommand) throws Exception {
        Integer[] numberPages = inputCommand.getSplitPageNumbers();
        if (numberPages != null && numberPages.length == 1) {
            pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile()
                    .getAbsolutePath()), inputCommand.getInputFile().getPasswordBytes());
            pdfReader.removeUnusedObjects();
            pdfReader.consolidateNamedDestinations();
            int n = pdfReader.getNumberOfPages();
            int numberPage = numberPages[0].intValue();
View Full Code Here

     *
     * @param inputCommand
     * @throws Exception
     */
    private void executeBookmarksSplit(SplitParsedCommand inputCommand) throws Exception {
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),
                inputCommand.getInputFile().getPasswordBytes());
        int bLevel = inputCommand.getBookmarksLevel().intValue();
        Hashtable bookmarksTable = new Hashtable();
        if (bLevel > 0) {
            pdfReader.removeUnusedObjects();
View Full Code Here

     *
     * @param inputCommand
     * @throws Exception
     */
    private void executeSizeSplit(SplitParsedCommand inputCommand) throws Exception {
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),
                inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();
        int n = pdfReader.getNumberOfPages();
        BookmarksProcessor bookmarkProcessor = new BookmarksProcessor(SimpleBookmark.getBookmark(pdfReader), n);
View Full Code Here

      setPercentageOfWorkDone(0);
      Document currentDocument;
      try{                               
        File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());
        LOG.debug("Opening "+inputCommand.getInputFile().getFile().getAbsolutePath());
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
          pdfReader.consolidateNamedDestinations();
          int n = pdfReader.getNumberOfPages();
            currentDocument = new Document(pdfReader.getPageSizeWithRotation(1));
           
View Full Code Here

            int[] limits1 = { 1, 1 };
            int[] limits2 = { 1, 1 };
            try {
                File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());

                pdfReader1 = new PdfReader(new RandomAccessFileOrArray(inputCommand.getFirstInputFile().getFile()
                        .getAbsolutePath()), inputCommand.getFirstInputFile().getPasswordBytes());
                pdfReader1.removeUnusedObjects();
                pdfReader1.consolidateNamedDestinations();
                limits1[1] = pdfReader1.getNumberOfPages();

                pdfReader2 = new PdfReader(new RandomAccessFileOrArray(inputCommand.getSecondInputFile().getFile()
                        .getAbsolutePath()), inputCommand.getSecondInputFile().getPasswordBytes());
                pdfReader2.removeUnusedObjects();
                pdfReader2.consolidateNamedDestinations();
                limits2[1] = pdfReader2.getNumberOfPages();
View Full Code Here

        PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(pdf_file));
        int pages = 0;
        document.open();
        PdfContentByte cb = writer.getDirectContent();
                RandomAccessFileOrArray ra = null;
                int comps = 0;
                try {
                    ra = new RandomAccessFileOrArray(tiff_file);
                    comps = TiffImage.getNumberOfPages(ra);
                }
                catch (Throwable e) {
                    System.out.println("Exception in " + tiff_file + " " + e.getMessage());
                    continue;
                }
                System.out.println("Processing: " + tiff_file);
                for (int c = 0; c < comps; ++c) {
                    try {
                        LwgImage img = TiffImage.getTiffImage(ra, c + 1);
                        if (img != null) {
                            System.out.println("page " + (c + 1));
                            if (img.getScaledWidth() > 500 || img.getScaledHeight() > 700) {
                                img.scaleToFit(500, 700);
                            }
                            img.setAbsolutePosition(20, 20);
                            document.add(new Paragraph(tiff_file + " - page " + (c + 1)));
                            cb.addImage(img);
                            document.newPage();
                            ++pages;
                        }
                    }
                    catch (Throwable e) {
                        System.out.println("Exception " + tiff_file + " page " + (c + 1) + " " + e.getMessage());
                    }
        }
        ra.close();
        document.close();
      } catch (Throwable e) {
        e.printStackTrace();
      }
    }
View Full Code Here

      System.err.println("OddEven needs 3 Arguments.");
      System.out.println("Usage: com.lowagie.examples.objects.images.tiff.OddEven odd_file.tif even_file.tif combined_file.pdf");
      System.exit(1);
    }
    try {
      RandomAccessFileOrArray odd = new RandomAccessFileOrArray(args[0]);
      RandomAccessFileOrArray even = new RandomAccessFileOrArray(args[1]);
      LwgImage img = TiffImage.getTiffImage(odd, 1);
      LwgDocument document = new LwgDocument(new LwgRectangle(img.getScaledWidth(),
          img.getScaledHeight()));
      PdfWriter writer = PdfWriter.getInstance(document,
          new FileOutputStream(args[2]));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      int count = Math.max(TiffImage.getNumberOfPages(odd), TiffImage
          .getNumberOfPages(even));
      System.out.println("Combining 2 TIFF files into 1 PDF");
      for (int c = 0; c < count; ++c) {
        try {
          LwgImage imgOdd = TiffImage.getTiffImage(odd, c + 1);
          LwgImage imgEven = TiffImage.getTiffImage(even, count - c);
          document.setPageSize(new LwgRectangle(imgOdd.getScaledWidth(),
              imgOdd.getScaledHeight()));
          document.newPage();
          imgOdd.setAbsolutePosition(0, 0);
          cb.addImage(imgOdd);
          document.setPageSize(new LwgRectangle(imgEven.getScaledWidth(),
              imgEven.getScaledHeight()));
          document.newPage();
          imgEven.setAbsolutePosition(0, 0);
          cb.addImage(imgEven);

        } catch (Throwable e) {
          System.out.println("Exception page " + (c + 1) + " "
              + e.getMessage());
        }
      }
      odd.close();
      even.close();
      document.close();
    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

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

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.