Skip to content

Commit

Permalink
Imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusfaber authored and asturio committed Aug 7, 2024
1 parent a975154 commit dfb9155
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions openpdf/src/test/java/com/lowagie/text/pdf/PdfSmartCopyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;

import com.lowagie.text.Phrase;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -110,4 +110,30 @@ void canInterleaveTwoFilesWithCustomPages() throws IOException {
}
}


@Test
void verbose() throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (Document document = new Document()) {
try (PdfCopy copy = new PdfSmartCopy(document, outputStream)) {
document.open();

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document tempDocument = new Document();
PdfWriter tempWriter = PdfWriter.getInstance(tempDocument, baos);
tempDocument.open();
tempDocument.add(new Phrase("Front page"));
tempDocument.close();
PdfReader tempReader = new PdfReader(baos.toByteArray());
PdfImportedPage page = copy.getImportedPage(tempReader, 1);
copy.addPage(page);
copy.freeReader(tempReader);

document.newPage();
document.add(new Paragraph("Last page"));
}
}
Files.write(Path.of("/home/faber-espensenr/tmp/x3.pdf"), outputStream.toByteArray());

}
}

0 comments on commit dfb9155

Please sign in to comment.