Commit b0cd68a6 authored by 9731073's avatar 9731073

initial commit

parent 113bb265
Pipeline #328 failed with stages
...@@ -16,8 +16,7 @@ public class Main { ...@@ -16,8 +16,7 @@ public class Main {
Document document = new Document(); Document document = new Document();
//Create OutputStream instance. //Create OutputStream instance.
OutputStream outputStream = OutputStream outputStream = new FileOutputStream(new File("TestFile.pdf"));
new FileOutputStream(new File("C:\\TestFile.pdf"));
//Create PDFWriter instance. //Create PDFWriter instance.
PdfWriter.getInstance(document, outputStream); PdfWriter.getInstance(document, outputStream);
...@@ -26,8 +25,7 @@ public class Main { ...@@ -26,8 +25,7 @@ public class Main {
document.open(); document.open();
//Add content to the document. //Add content to the document.
document.add(new Paragraph("Hello world, " + document.add(new Paragraph("Hello world, " + "this is a test pdf file."));
"this is a test pdf file."));
//Close document and outputStream. //Close document and outputStream.
document.close(); document.close();
...@@ -36,7 +34,7 @@ public class Main { ...@@ -36,7 +34,7 @@ public class Main {
System.out.println("Pdf created successfully."); System.out.println("Pdf created successfully.");
PdfReader pdfReader=new PdfReader("C:\\Users\\Surface\\IdeaProjects\\lab4\\src\\com\\company\\Lab-4.pdf"); PdfReader pdfReader=new PdfReader("C:\\Users\\Surface\\IdeaProjects\\lab4\\src\\com\\company\\Lab-4.pdf");
int pages = pdfReader.getNumberOfPages(); int pages = pdfReader.getNumberOfPages();
// PdfTextExtractor(pdfReader.getNumberOfPages()); //PdfTextExtractor(pdfReader.getNumberOfPages());
for (int i=1; i<=pages; i++) { for (int i=1; i<=pages; i++) {
String pageContent = PdfTextExtractor.getTextFromPage(pdfReader, i); String pageContent = PdfTextExtractor.getTextFromPage(pdfReader, i);
System.out.println("Content on Page " + i + ": " + pageContent); System.out.println("Content on Page " + i + ": " + pageContent);
......
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