Commit 9fd1cdfb authored by 9731013's avatar 9731013

Add writing

parent fe6dbd5d
Pipeline #319 failed with stages
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class a{
public static void main(String args[]){
try{
PdfReader pdfReader = new PdfReader("a.pdf");
int cnt =pdfReader.getNumberOfPages();
for(int i=1 ; i<=cnt ; i++){
String str = PdfTextExtractor.getTextFromPage(pdfReader, i);
System.out.println(str);
}
Document doc = new Document();
OutputStream ostream = new FileOutputStream(new File("b.pdf"));
PdfWriter.getInstance(doc, ostream);
doc.open();
doc.add(new Paragraph("salam salam"));
doc.close();
ostream.close();
} catch (Exception e){
System.out.println(e.getMessage());
......
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