Comments (6)
Can you provide example code to reproduce the problem?
from openpdf.
Here is a chunk that recreates it:
public static void main(String... args) throws Exception
{
Document document = new Document();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, byteArrayOutputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
int loops = 24;
Paragraph outerParagraph = new Paragraph();
for (int i = 0; i < loops; i++)
{
Paragraph paragraph = new Paragraph();
paragraph.setFont(new Font(Font.HELVETICA, 8));
paragraph.setSpacingBefore(2.5f);
paragraph.setKeepTogether(true);
StringReader strReader = new StringReader("arbitrary text");
ArrayList<Element> htmlObjects = HTMLWorker.parseToList(strReader, null);
for (Element htmlObject : htmlObjects)
{
paragraph.add(htmlObject);
}
outerParagraph.add(paragraph);
}
document.add(outerParagraph);
document.newPage();
Paragraph outerParagraph2 = new Paragraph();
for (int i = 0; i < loops; i++)
{
Paragraph paragraph = new Paragraph();
paragraph.setFont(new Font(Font.HELVETICA, 8));
paragraph.setSpacingBefore(2.5f);
paragraph.setKeepTogether(true);
StringReader strReader = new StringReader("arbitrary text");
ArrayList<Element> htmlObjects = HTMLWorker.parseToList(strReader, null);
for (Element htmlObject : htmlObjects)
{
paragraph.add(htmlObject);
}
outerParagraph2.add(paragraph);
}
document.add(outerParagraph2);
document.close();
writer.close();
FileOutputStream fos = new FileOutputStream("example.pdf");
fos.write(byteArrayOutputStream.toByteArray());
System.out.println("Complete");
}
from openpdf.
It seems to be related to the nested paragraphs sections, but I think this should work, yeah?
from openpdf.
Having some code in the issues are always a good starting point for me or any other contributor. Maybe this could be avoided, if before creating a new page, we check if the content of the actual page is "empty". If the paragrapha text is rendered in the previous page and the new page only contains the "new line", than maybe the newPage() should do nothing?
from openpdf.
I currently do that. I check to see if current page is empty and if it is, I skip the newpage call. I think something is causing it to not be considered empty.
from openpdf.
Is there a known workaround for this?
from openpdf.
Related Issues (20)
- PdfCopy cannot be used for writing HOT 1
- Streamlining Chunk Addition in ColumnText Without Storing All in JVM HOT 5
- Handling Row Content Splitting in PdfPTable.writeSelectedRows() HOT 3
- font can't display Complete when text length greater than pdf edit box length HOT 2
- Is OpenPDB library is fully supported on Android? HOT 3
- Support for Circular Shaped Images HOT 1
- Does OpenPDF support multiThreadding ? HOT 1
- Opening a file with `PdfReader` (or `RandomAccessFileOrArray`) keeps the file locked after `close()` HOT 1
- Print large text cells that exceed the remaining height of one page of paper starting from the second page rather than from the remaining height of the first page HOT 1
- Prevent leading from affecting the first cell HOT 2
- Unable to insert text in Identity-H encoding using a subset font file HOT 2
- Please provide Android support for GrallVM native-image feature; HOT 1
- Is there html to pdf capability HOT 2
- Japanese symbols are not rendered into PDF file HOT 14
- Rendering Multi lingual Text HOT 1
- Example code for RadioCheckField HOT 1
- "Unknown encryption type R = 5" HOT 6
- VariableBorder cell renders border differently from nonVariableBorder cell
- Non-styled versions of TTF fonts are chosen and artificially styled over available styled versions
- NullPointerException using PdfTextExtractor HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openpdf.