All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.objects.PdfFileInformation Maven / Gradle / Ivy

The newest version!
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2015 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
     This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


 *
 * ---------------
 * PdfFileInformation.java
 * ---------------
 */
package org.jpedal.objects;

import org.jpedal.constants.PDFflags;
import org.jpedal.io.DecryptionFactory;
import org.jpedal.io.ObjectDecoder;
import org.jpedal.io.PdfFileReader;
import org.jpedal.io.PdfObjectReader;
import org.jpedal.objects.raw.MetadataObject;
import org.jpedal.objects.raw.PdfDictionary;
import org.jpedal.objects.raw.PdfObject;
import org.jpedal.utils.LogWriter;
import org.jpedal.utils.StringUtils;

/**
 * 

Added as a repository to store PDF file metadata (both legacy fields and XML metadata) in so that it can be accesed. *

Please see org.jpedal.examples (especially Viewer) for example code. */ public class PdfFileInformation { /**list of pdf information fields data might contain*/ private static final String[] information_fields = { "Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate", "ModDate", "Trapped" }; /**list of pdf information fields data might contain*/ public static final int[] information_field_IDs = { PdfDictionary.Title, PdfDictionary.Author, PdfDictionary.Subject, PdfDictionary.Keywords, PdfDictionary.Creator, PdfDictionary.Producer, PdfDictionary.CreationDate, PdfDictionary.ModDate, PdfDictionary.Trapped}; /**assigned values found in pdf information object*/ private final String[] information_values = {"","","","","","","","",""}; /**Any XML metadata as a string*/ private String XMLmetadata; private byte[] rawData; /**@return list of field names*/ public static String[] getFieldNames(){ return information_fields; } /**@return XML data embedded inside PDF*/ public String getFileXMLMetaData(){ if(rawData==null) { return ""; } else{ if(XMLmetadata==null){ //make deep copy final int length=rawData.length; byte[] stream=new byte[length]; System.arraycopy(rawData,0,stream,0,length); //strip empty lines final int count=stream.length; int reached=0; byte lastValue=0; for(int ii=0;ii so find last > * and remove the rest) */ if(rawData!=null){ int count=rawData.length; while(count>1){ if(rawData[count-1]=='>') { break; } count--; } //copy and resize if(count>0){ final byte[] trimmedVersion=new byte[count]; System.arraycopy(rawData,0,trimmedVersion,0,count); rawData=trimmedVersion; } } } return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy