Package nz.govt.natlib.adapter.pdf.dom

Examples of nz.govt.natlib.adapter.pdf.dom.PDFDocument


    writeFileInfo(oFile, ctx);
    try {
      InputStream in = new FileInputStream(oFile);
      ctx.fireStartParseEvent("pdf-meta");
      // the first thing to do is to open a PDF 'Stream'
      PDFDocument doc = new PDFDocument(oFile, null); // if we could pass
                              // passwords there
                              // is where to do
                              // it...

      String idBase = doc.getIdBase();
      ctx.fireParseEvent("doc-id", doc.getIdBase());
      ctx.fireParseEvent("iteration-id", doc.getIdIteration());
      if (idBase == null) {
        ctx.fireParseEvent("original", "unknown");
      } else {
        ctx.fireParseEvent("original", doc.getIdIteration().equals(
            idBase));
      }

      fireSpecialNull(ctx, "title", doc.getTitle());
      fireSpecialNull(ctx, "language", doc.getLanguage());
      fireSpecialNull(ctx, "author", doc.getAuthor());
      fireSpecialNull(ctx, "creator", doc.getCreator());
      fireSpecialNull(ctx, "subject", doc.getSubject());
      fireSpecialNull(ctx, "producer", doc.getProducer());
      fireSpecialNull(ctx, "keywords", doc.getKeywords());

      // created...
      SimpleDateFormat dateFormatter = new SimpleDateFormat();
      Date date = doc.getCreationDate();
      ctx.fireStartParseEvent("creation-date");
      if (date != null) {
        dateFormatter.applyPattern(FXUtil.dateFormat);
        ctx.fireParseEvent("DATE", dateFormatter.format(date));
        ctx.fireParseEvent("DATEPATTERN", FXUtil.dateFormat);
        dateFormatter.applyPattern(FXUtil.timeFormat);
        ctx.fireParseEvent("TIME", dateFormatter.format(date));
        ctx.fireParseEvent("TIMEPATTERN", FXUtil.timeFormat);
      } else {
        ctx.fireParseEvent("unavailable");
      }
      ctx.fireEndParseEvent("creation-date");

      // modified
      date = doc.getModificationDate();
      ctx.fireStartParseEvent("modified-date");
      if (date != null) {
        dateFormatter.applyPattern(FXUtil.dateFormat);
        ctx.fireParseEvent("DATE", dateFormatter.format(date));
        ctx.fireParseEvent("DATEPATTERN", FXUtil.dateFormat);
        dateFormatter.applyPattern(FXUtil.timeFormat);
        ctx.fireParseEvent("TIME", dateFormatter.format(date));
        ctx.fireParseEvent("TIMEPATTERN", FXUtil.timeFormat);
      } else {
        ctx.fireParseEvent("unavailable");
      }
      ctx.fireEndParseEvent("modified-date");

      ctx.fireParseEvent("has-forms", doc.hasForms());
      ctx.fireParseEvent("has-metadata-stream", doc.hasMetadataStream());
      ctx.fireParseEvent("has-outine", doc.hasOutline());
      ctx.fireParseEvent("has-threads", doc.hasThreads());
      ctx.fireParseEvent("tagged", doc.isTagged());
      fireSpecialNull(ctx, "page-layout", doc.getPageLayout());
      fireSpecialNull(ctx, "page-mode", doc.getPageMode());
      fireSpecialNull(ctx, "trapped", doc.getTrapped());
      fireSpecialNull(ctx, "version", doc.getVersion());

      boolean encrypted = doc.isEncrypted();
      ctx.fireStartParseEvent("security");
      ctx.fireParseEvent("encrypted", encrypted);
      if (encrypted) {
        fireSpecialNull(ctx, "scheme", doc.getScheme());
        fireSpecialNull(ctx, "scheme-type", doc.getSchemeType());
        ctx.fireParseEvent("key-length", doc.getKeyLength());
        ctx.fireParseEvent("readonly", doc.isReadOnly());
        ctx.fireParseEvent("allow-print", doc.allowPrint());
        ctx.fireParseEvent("allow-copy", doc.allowCopy());
        ctx.fireParseEvent("allow-notes", doc.allowTextNotes());
        ctx.fireParseEvent("user-password", doc.hasUserPassword());
        ctx.fireParseEvent("owner-password", doc.hasOwnerPassword());
      }
      ctx.fireEndParseEvent("security");

      doc.close();
      ctx.fireEndParseEvent("pdf-meta");
      in.close();
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    } finally {
View Full Code Here

TOP

Related Classes of nz.govt.natlib.adapter.pdf.dom.PDFDocument

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.