PDFBox half available

I downloaded PDFBox 1.8.6 from Apache

Then I copied it to the "res" folder created in the root Java / Eclipse project. Then I right-clicked on the project, went to properties, then to the Java build path, then to Libraries, then clicked the Add JARS ... button and added it and my documentation.

Here are the results

From now on, in my code, I could import the (ish) PDFBox.

For example, I see:

import org.apache.pdfbox.pdmodel.*;

But, if you want to do something useful, you need to import more, often in the form:

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.font.PDFont;

For some strange reason, I see, I don’t see these ...

here is a screenshot of the imports ...

Can someone please explain this to me?

+4
source share
6 answers

, , . 28 . , !

+1

. , ; Ctrl-Space, . , .

0

, javadoc jar, .

, , .

javadoc . javadoc pdfbox, , Javadoc, "...", "Javadoc in " .

, , pdfbox-app-1.8.6.jar, , . , , , pdfbox-1.8.6.jar.

0

1.8.7, libs jar " ", . ,

 "10-28 13:45:14.510: E/AndroidRuntime(1630): java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.PDDocument"..

5 .... iText PDF. ...

iText

http://zacktutorials.blogspot.com/2014/07/android-read-and-write-pdf-file-using.html

0

, javascript pdfbox, , .

pdfbox apache tika PDF .

.

bcprov-1.45.jar fontbox-1.5.0.jar org.apache.tika.jar org.apache.tika.parsers.jar pdfbox-1.3.1.jar

package readpdf;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.sax.BodyContentHandler;
import org.xml.sax.ContentHandler;

public class readpdf {
  public static void main(String args[]) throws Exception {


        File file = new File("OutputFile");

        // if file doesnt exists, then create it
        if (!file.exists()) {
            file.createNewFile();
        }

        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);

    InputStream is = null;
    OutputStream o=null;
    try {
      is = new FileInputStream(InputFile);
      ContentHandler contenthandler = new BodyContentHandler();
      Metadata metadata = new Metadata();
      AutoDetectParser parser = new AutoDetectParser();
      parser.parse(is, contenthandler, metadata);
      System.out.println(contenthandler.toString());
      bw.write(contenthandler.toString());
        bw.close();
      //String[] a = metadata.names();

   /*  for(int i = 0;i< a.length-1;i++)
      {
          System.out.println(a[i]);
      }*/

      //System.out.println("title = "+metadata.get("title"));
     // System.out.println("Author = "+metadata.get("Author"));
    //  System.out.println("Content-Type = "+metadata.get("Content-Type"));
     // System.out.println("Producer = "+metadata.get("producer"));
     // System.out.println("Created = "+metadata.get("created"));
     // System.out.println("Last-Modified = "+metadata.get("Last-Modified"));
      System.out.println("*******************Content of PDF ********************");
      System.out.println(contenthandler.toString());

    }
    catch (Exception e) {
      e.printStackTrace();
    }
    finally {
        if (is != null) is.close();
    }
  }
}
0

, , .

  • pdfbox-app-1.8.7.jar https://pdfbox.apache.org/download.cgi
  • . PS: javadoc . .
  • "org.apache.pdfbox.pdmodel.PDDocument;" ( org.apache.pdfbox.pdmodel, Ctrl + Space, ). . enter image description here
  • . . "org.apache.pdfbox.pdmodel.font.PDFont" "org.apache.pdfbox.pdmodel.font". Ctrl + Space, . enter image description here
  • I think you did "import org.apache.pdfbox.pdmodel. *;" therefore it displays all packages. For reference 3,4,5, select the appropriate package from the list of offers, and then press Ctrl + Space to get class offers inside this package. Also remove javadoc from the build path and check.

Hope this helps

0
source

All Articles