Commit d565ce36 authored by Delaram's avatar Delaram

new package

parents
File added
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import java.io.IOException;
public class PDFReaderTest{
public static void main(String[] args) {
PdfReader pdfreader=null;
try{
pdfreader =new PdfReader("E:\\Codes\\Java\\Lab 4\\src\\test.pdf");
}catch(Exception e){
e.printStackTrace();
}
int pages=pdfreader.getNumberOfPages();
System.out.println(""+pages);
for (int i = 1; i <=pages ; i++) {
String pageContent= null;
try {
pageContent = PdfTextExtractor.getTextFromPage(pdfreader,i);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Content on Page"+i+":"+pageContent);
}
}
}
\ No newline at end of file
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.*;
public class PDFWriteTest {
public static void main(String[] args) {
try {
Document document = new Document();
OutputStream outputStream = new FileOutputStream(new File("E:\\Codes\\Java\\Lab 4\\src\\daD.pdf"));
PdfWriter.getInstance(document, outputStream);
document.open();
document.add(new Paragraph("سلام," + "This is a test pdf file!"));
document.close();
outputStream.close();
System.out.println("Pdf created sucessfully!");
}catch(Exception e){
e.printStackTrace();
}
}
}
File added
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment