Examples of COSDocument


Examples of org.apache.pdfbox.cos.COSDocument

{

    public void validate(PreflightContext ctx) throws ValidationException
    {
        PDDocument pdfDoc = ctx.getDocument();
        COSDocument cDoc = pdfDoc.getDocument();

        List<?> lCOSObj = cDoc.getObjects();
        for (Object o : lCOSObj)
        {
            COSBase cBase = ((COSObject) o).getObject();
            if (cBase instanceof COSDictionary)
            {
View Full Code Here

Examples of org.apache.pdfbox.cos.COSDocument

     * @param cfg
     * @throws IOException
     */
    public PreflightDocument(Format format, PreflightConfiguration cfg) throws IOException
    {
        this(new COSDocument(), format, cfg);
    }
View Full Code Here

Examples of org.apache.pdfbox.cos.COSDocument

            {
                LOG.warn("System property " + SYSPROP_EOFLOOKUPRANGE
                        + " does not contain an integer value, but: '" + eofLookupRangeStr + "'");
            }
        }
        setDocument(new COSDocument(false, useScratchFiles));
        pdfSource = new PushBackInputStream(raStream, 4096);
        password = decryptionPassword;
    }
View Full Code Here

Examples of org.apache.pdfbox.cos.COSDocument

     * @param cfg
     * @throws IOException
     */
    public PreflightDocument(Format format, PreflightConfiguration cfg) throws IOException
    {
        this(new COSDocument(), format, cfg);
    }
View Full Code Here

Examples of org.apache.pdfbox.cos.COSDocument

            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
                    "D entry is mandatory for the ThreadAction"));
            return false;
        }

        COSDocument cosDocument = this.context.getDocument().getDocument();
        if (!(COSUtils.isInteger(d, cosDocument) || COSUtils.isString(d, cosDocument) || COSUtils.isDictionary(d,
                cosDocument)))
        {
            context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "D entry type is invalid"));
            return false;
View Full Code Here

Examples of org.pdfbox.cos.COSDocument

  * Convert a PDF file into text and save PDF fields in a IndexableDoc object
  */
public void getDocument(String ifile, IndexableDoc doc
{
  doc.setFileType("text"); doc.setFileName(ifile);
  COSDocument cosDoc = null;
  logger.info("Extracting text from PDF file " + ifile);
  try
  { cosDoc = parseDocument(new FileInputStream(new File(ifile)) ); }
  catch (OutOfMemoryError exc)
  {  logger.error("Ran out of memory for " + ifile + " or could be corrupt file " + exc.getMessage());
  return; }
  catch (IOException e)
  { logger.error("Cannot read PDF document " + ifile + " " +  e.getMessage());
  return; }
  catch (Exception e)
  { logger.error("Could not parse PDF document" + ifile + " " + e.getMessage());
  return; }

  // decrypt the PDF document, if it is encrypted -- use a blank password
  try
  {
   String password = "";
   if ( (cosDoc != null) && (cosDoc.isEncrypted()) )
   { DocumentEncryption decryptor = new DocumentEncryption(cosDoc); decryptor.decryptDocument(password); }
  }
  catch (CryptographyException e)
  { logger.error("Could not decrypt PDF doc: " + ifile + " " + e.getMessage()); closeCOSDocument(cosDoc)
  return; }
View Full Code Here

Examples of org.pdfbox.cos.COSDocument

        {
            is = new java.io.FileInputStream(in);
            PDFParser parser = new PDFParser(is);
            parser.parse();

            COSDocument doc = parser.getDocument();

            os = new java.io.FileOutputStream(out);
            writer = new COSWriter(os);

            writer.write(doc);
View Full Code Here

Examples of org.pdfbox.cos.COSDocument

        else
        {
                this.willEncrypt = false;
        }
               
        COSDocument cosDoc = document.getDocument();
        COSDictionary trailer = cosDoc.getTrailer();
        COSArray idArray = (COSArray)trailer.getDictionaryObject( "ID" );
        if( idArray == null )
        {
            try
            {
               
                //algothim says to use time/path/size/values in doc to generate
                //the id.  We don't have path or size, so do the best we can
                MessageDigest md = MessageDigest.getInstance( "MD5" );
                md.update( Long.toString( System.currentTimeMillis()).getBytes() );
                COSDictionary info = (COSDictionary)trailer.getDictionaryObject( "Info" );
                if( info != null )
                {
                    Iterator values = info.getValues().iterator();
                    while( values.hasNext() )
                    {
                        md.update( values.next().toString().getBytes() );
                    }
                }
                idArray = new COSArray();
                COSString id = new COSString( md.digest() );
                idArray.add( id );
                idArray.add( id );
                trailer.setItem( "ID", idArray );
            }
            catch( NoSuchAlgorithmException e )
            {
                throw new COSVisitorException( e );
            }
        }
       
        /*
        List objects = doc.getObjects();
        Iterator iter = objects.iterator();
        long maxNumber = 0;
        while( iter.hasNext() )
        {
            COSObject object = (COSObject)iter.next();
            if( object.getObjectNumber() != null &&
                object.getGenerationNumber() != null )
            {
                COSObjectKey key = new COSObjectKey( object.getObjectNumber().longValue(),
                                                     object.getGenerationNumber().longValue() );
                objectKeys.put( object.getObject(), key );
                objectKeys.put( object, key );
                maxNumber = Math.max( key.getNumber(), maxNumber );
                setNumber( maxNumber );
            }
        }*/
        cosDoc.accept(this);
    }
View Full Code Here

Examples of org.pdfbox.cos.COSDocument

        {
            if ( raf == null )
            {
                if( tempDirectory != null )
                {
                    document = new COSDocument( tempDirectory );
                }
                else
                {
                    document = new COSDocument();
                }
            }
            else
            {
                document = new COSDocument( raf );
            }
            setDocument( document );
            String header = readLine();
            document.setHeaderString( header );
View Full Code Here

Examples of org.pdfbox.cos.COSDocument

     *
     * @throws IOException If there is an error creating this document.
     */
    public FDFDocument() throws IOException
    {
        document = new COSDocument();
        document.setHeaderString( "%FDF-1.2" );

        //First we need a trailer
        document.setTrailer( new COSDictionary() );

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.