Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: compare 2 PDF file and write summary of that in JAVA

  1. #1
    Junior Member
    Join Date
    Mar 2018
    Thanked 0 Times in 0 Posts

    Default compare 2 PDF file and write summary of that in JAVA


    I am new and written code to compare 2 pdf file and create summary for in which lines change has done in another PDF file after compare both PDF. But my code is for word compare and it is not working for all lines. I need help for PDF or Word:

    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;

    public class CompareTextFiles
    public static void main(String[] args) throws IOException
    BufferedReader reader1 = new BufferedReader(new FileReader("D:/Data/v1.docx"));
    BufferedReader reader2 = new BufferedReader(new FileReader("D:/Data /v2.docx"));
    String line1 = reader1.readLine();
    String line2 = reader2.readLine();
    boolean areEqual = true;
    int lineNum = 1;
    while (line1 != null || line2 != null)
    if(line1 == null || line2 == null)
    areEqual = false;
    else if(! line1.equalsIgnoreCase(line2))
    areEqual = false;
    // break;
    line1 = reader1.readLine();
    line2 = reader2.readLine();
    System.out.println("Two files have same content.");
    System.out.println("Two files have different content. They differ at line "+lineNum);
    System.out.println("File1 has "+line1+" and File2 has "+line2+" at line "+lineNum);

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,475 Times in 2,426 Posts

    Default Re: compare 2 PDF file and write summary of that in JAVA

    I need help for PDF
    Look at the Apache project. It has packages for working with PDFs.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. how to write java data to pdf file
    By viral.bhat in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2014, 11:32 PM
  2. Replies: 3
    Last Post: December 13th, 2013, 07:36 AM
  3. how to get the print preview for pdf file in java
    By sivanand in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 20th, 2013, 12:55 PM
  4. how to write data to a pdf file which is stored on a sql database
    By cancer625 in forum Object Oriented Programming
    Replies: 3
    Last Post: January 22nd, 2012, 10:34 PM
  5. Write to pdf file with pdfbox with greek encoding
    By javment in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 16th, 2011, 08:57 AM

Tags for this Thread