Commit 9fd1cdfb authored by 9731013's avatar 9731013

Add writing

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