testarea-itext5 | Test area for public iText v5 issues | Document Editor library
kandi X-RAY | testarea-itext5 Summary
kandi X-RAY | testarea-itext5 Summary
Test area for public iText v5 issues on stackoverflow etc
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates a template from a PDF document
- Creates a PdfObject from a PDF document .
- Remove a page from a page tree .
- Hide a template .
- Converts a page contents to a byte array .
- Stores the named pages in a PDF file .
- Store the named Templates in a PDF file .
- Get a HashMap of pages indexed by page name .
- Get the names of the Templates associated with a given Pamper .
- Gets the name dictionary of the font .
testarea-itext5 Key Features
testarea-itext5 Examples and Code Snippets
Community Discussions
Trending Discussions on testarea-itext5
QUESTION
We have been using the iText based PdfVeryDenseMergeTool we found in this SO question How To Remove Whitespace on Merge to merge multiple PDF files into a single PDF file. The tool merges PDFs without leaving any whitespace in between, and individual PDFs also get broken out across pages when possible.
We want to port PdfVeryDenseMergeTool to PDFBox. We found a PDFBox 2 based PdfDenseMergeTool that merges PDFs like this:
Individual PDFs:
Dense Merged PDF:
We are looking for something like this (this is already one in iText based PdfVeryDenseMergeTool but we want to do it using PDFBox 2) :
In our attempt to do the porting, we found that PdfVeryDenseMergeTool uses a PageVerticalAnalyzer that extends iText PDF Render Listener and does something every time a text, image, or arc is drawn in a PDF. And all the rendering info is then used to split an individual PDF across multiple pages. We tried looking for a similar PDF Render Listener in PDFBox 2 but found that the available PDFRenderer class only has image rendering methods. So we are not sure how to port PageVerticalAnalyzer to PDFBox.
If someone can suggest an approach to move forward, we'd greatly appreciate their help.
Thanks a lot!
EDIT 7 Feb 2020
At present, we are extending PDFGraphicsStreamEngine from PDFBox to make a custom rendering engine that tracks coordinates of images, text lines, and arcs when they are drawn. That custom engine will be the port of the PageVerticalAnalyzer. After that, we are hoping to be able to port PdfVeryDenseMergeTool to PDFBox.
EDIT 8 Feb 2020
Here is a very simple port of PageVerticalAnalyzer that handles images and text. I'm a PDFBox newbie, so my logic to handle images is probably wonky. Here's the basic approach:
Text: for every glyph printed, get the bottomY and make topY = bottomY + charHeight, mark those top/bottom points.
Image: for every call to drawImage(), it looks like there are two ways to figure out where it was drawn. First is using the coords from the last call to appendRectangle() and second is using the last calls to moveTo(), multiple lineTo(), and closePath(). I give the latter one priority. If I can't find any path (I found it in one PDF, in another, before drawImage(), I only found appendRectangle()), I use the former. If none of them exist, I have no clue what to do. Here's how I'm assuming PDFBox marks image coords using moveTo()/lineTo()/closePath():
Here is my current implementation:
...ANSWER
Answered 2020-Feb-10 at 14:37This answer suffers from the same issues as the original iText version does.
A port of thePageVerticalAnalyzer
One can port the PageVerticalAnalyzer
as follows from iText to PDFBox:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install testarea-itext5
You can use testarea-itext5 like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the testarea-itext5 component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page