Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Streamlining Chunk Addition in ColumnText Without Storing All in JVM

Aperta
#1,167 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

Start by reading ColumnText and BidiLine, which the issue identifies as handling chunk processing, and trace what happens when go() is called after each chunk. Compare that with adding multiple chunks before calling go(). The issue is resolved when streamed chunks continue on the same line where appropriate, with a test covering successive chunk additions and text flow.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Hello Team,

I am working on generating a PDF book with very lengthy text (>1000 pages). Due to the large content, I encountered OutOfMemoryException when using phrase/paragraph directly and decided to use ColumnText to handle the text chunk by chunk. While this approach helps avoid memory issues, I have run into a problem where each new chunk starts on a new line within the same column. This behavior is observed when adding chunks one at a time. In contrast, adding multiple chunks before calling ct.go() works fine, with the text flowing continuously. I identified that BidiLine processes all chunks and outputs the content line by line.

Code I have tried :

  public static void main(String[] args) throws Exception {
      Document document = new Document(new Rectangle(842, 595));
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ParagraphTest.pdf"));
      document.open();
      DataSupplier dataSupplier = new DataSupplier();
      ColumnText ct = new ColumnText(writer.getDirectContent());
      ct.setSimpleColumn(50, 50, 200, 545);
      while (dataSupplier.hasMoreContent()) {  // until data supplier has no more content
          String text = dataSupplier.getText();
          ct.addText(new Chunk(text));  // adding chunk by chunk. Each chunk may actually vary in style
          while (ct.go() != ColumnText.NO_MORE_TEXT) { // if end of page is reached, creating new page and resuming
              document.newPage();
              ct.setSimpleColumn(50, 50, 200, 545);
          }
      }
      document.close();
  }

Is there any way to append chunks to the previous chunk on the same line? Alternatively, if there is a different class or method to achieve streaming of text, please suggest.

Thank you !

Lingua principale
Java
Stelle
4.4k
Fork
714
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di LibrePDF/OpenPDF

Tutte le issue di LibrePDF/OpenPDF

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.