I'm working on an upgrade to iText to version 2.17. It's a java application, jdk 1.6.
Our old iText 1.0 code takes some rtf files and converts them to pdf and it works fine. However, on certain pdf documents, I'm seeing some blank rows added in. After looking at them, it looks like there is a table and the location on the page where it goes is where the extra blank space is occurring. The table still gets put on, but it forces the document to add another page. I think somehow the method call for this code must have been changed to accommodate the new api methods and that is the problem.
Any ideas as to how to track this down? I'm going back to the api's and my code changes to get it to compile with the new version; however, it's brute force search trying to figure out which of the changes effected this and I'm wondering what I can do to improve the process?
Thanks,
James
Ouch. 1.0, seriously?! Wow.
The API has evolved quite a bit since I signed on with 1.44(paulo), so going back to the dark ages... wow.
There's no conversion guide. You really are going to have to "brute force" your code update. Furthermore, some classes (text.Table, HeaderFooter, all the RTF output support) were flat out removed. There Are Ways to get the same sorts of results, (PdfPTable, PdfPageEventHandler) but you've got some catching up to do.
I really recommend you get the book: iText in Action (2nd edition). Chapter 2 and chapter 6 are available for free online, as is the source to all the examples.
Also keep in mind that starting with 5.0, iText is released under the APL (or you can buy a commercial license). The APL is a variant of the GPL expanded to encompass "the web service problem". Anyone with access to the OUTPUT of your code must have access to your code.
Well, I found this api page and it's helped a lot! Hopefully it will be of use to someone else:
http://www.jarvana.com/jarvana/view/com/lowagie/itext/2.0.8/itext-2.0.8-javadoc.jar!/index.html?overview-summary.html
What I've done is look at the deprecated api methods and the recommendation for the correct use for their change to the new version that were listed on this page.
HTH,
James
Related
I have a bunch of PDF files created by iText which i want to convert to images. I'm using JPedal to do so and it works in 99% of the cases but sometimes the images are incomplete. That means the content of forms or tables is missing or if the page contains only a picture (scan of a page) the resulting image is completely blank.
I have noticed that this only happens if the PDF file contains scanned pages. These are not exactly A4 like the rest of the document.
I tried to read the files with iText, create a new one in a temporary bytearray which contains only A4 pages and give this to JPedal. Also i set flattening to true. But nothing has changed.
Any ideas what causes this problem?
EDIT: I'm using jpedal-lgpl.jar in version 4.70. I searched for a more recent package and found version 4.92b23. With this one the content of forms gets converted correctly but the scanned pages are still blank with parts that look like what old TVs show when they have no signal.
I'd love to use the newest version but i can't find a download link. Did IDR Solutions stop publishing a lgpl version?
Did you use the flattening functionality of iText or of jPedal?
The "classic" jpedal LGPL version stopped since version 4.92b23. The first version not released under LGPL was 4.93 and later 5.0. The author removed it completely from sourceforge a while ago which contradicts the open source idea imho but that is another story...
However depending on the java version you are using there is a new LGPL JPedal. Instead of Swing/AWT it uses JavaFX but you can still transform your images like before. So if you can use Java 1.8 then you can use that LGPL version and see if that fixes your problem...
Update:
To fix the problems with your forms you can also flatten with jpedal: -Dorg.jpedal.flattenForm=true (or System.setProperty("org.jpedal.flattenForm","true"); )
One last possibility which comes to mind would be to fiddle around with the other jpedal options: https://www.idrsolutions.com/jpedal/support/jvm-flags/
Do you have the possibility to supply such an problematic PDF file for analysis?
We are paying customer of JPedal and we stumbled accross some threading issues some while ago. The problem got fixed quite quickly by IDR.
Try rendering in a synchronized block and see if the problem still persists.
I am trying to write a program that creates an Apple Keynote Slide. I was hoping to find some answers about creating apple's xml format (apxl) from scratch using Java. I have found a few documents pertaining to older versions of Keynote that allow such creation using Java DOM, but as far as the latest version of Keynote goes, I haven't had much luck. (btw I know that the .key file is a package, and that the apxl file is compressed .gz)
I have already read the following documents:
[1] https://developer.apple.com/appleapplications/keynote-apxl.html
[2] http://www.xml.com/pub/a/2004/01/07/keynote.html
... and many others. (stackoverflow will only let me post two links as a new person)
A google search will show you that there's not much documentation past 2004.
My question is, has anyone here successfully written something in Java to create, or add to, an apxl file for use with keynote? If so, could you point me toward the documentation, tutorials, or sample code that you used?
I'm not looking for your code, I just can't find a viable set of instructions wherever I look.
Thanks
My colleague used the next approach to generate big MS .xls/.doc 2003 documents. He had a goal to make reports contained >10^6 rows. He just produced xml and made zip file - as does it MS Word/Excel.
The format of xml can be simply retrieved from sample documents: e.g. if you'd like to know how do text formatting - just create simple documents with it and analyse output files.
Of couse we had very tiny set of abilities, but basic text formatting and layout markups were implemented.
I'm not sure how many features do you need. But you may implement the same xml generation procedures after separate investigation of every formatting feature.
I'm working on an existing Java web application (HTML/CSS/JS/JSP/Servlets and Java classes in this particular app) that currently uses an applet to print checks.
My boss recently came to me and informed me that there are errors coming back on user's machines when testing the check printing against the latest versions of Java.
He is wondering how we could set up the application to print checks off without using an applet.
In the past, I've used Crystal Reports to lay out forms and print them but that was in asp.net.
I know there are Java PDF libraries available but I'm not at all familiar with any of them and not sure that they could be used to format and print checks in a Java web application.
So, I'm ultimately wanting to know about what has worked for those who have implemented check or form printing using Java/JSP/Servlets.
2012-02-24 # 13:15EST edit
I mentioned "Java PDF libraries" above but have since found out that PDF cannot be used as end-users should not be able to save the check documents (unless PDF's can be made to not be saveable and just printable). All of the data is managed right on the database (Oracle in our case).
I've used iText to create PDF files before for things like this. PDF is your answer, since the whole point of the format is that it never really changes. Much better than an Applet.
http://itextpdf.com/
I ended up digging deeper into using iText and came across flying-saucer which makes it super-easy to render a PDF from XML or XHTML.
Check it out at http://code.google.com/p/flying-saucer/
I also found out how to partially hide the save functionality by rendering the PDF inside a hidden iframe: Create a "print-only" PDF with itext
I am trying to link some user docs to my Java Swing application. The user docs are pdf and I would like to be able to click on a button in my application which opens up some sort of pdf renderer to display my userdoc.pdf.
I do not want to use the runtime exec command
I have tried the following with not much success --
pdfRenderer -- this seems to not work for the current version of pdfs (seems to want older pdfs)
acrobat viewer -- I keep getting font errors (the document is displayed but everytime I go to a new page, I get an error)
JPedal pdfHelp - This sounds cool and if it will work, it would be the best for me. But for some reason, I am unable to open any file here. No pdf file that I have loads in the window (The pdfHelp panel comes up with a list of pdfs as promised, but when I right click one of them and say "OpenPDF", I just get a progress bar and the file does not load, I have tried a few files on this and checked file permissions)
JPedal SimpleViewer -- So far this one seems to be the most promising. I would like to remove some of the functionality of this viewer though and am not able to edit the xml to do this. When I edit the xml, then I seem to get xml parsing errors.
Has anybody done anything similar that worked? Help please
PS. I need this to work on Linux machines (IcePDF seems to works only for Windows). I would very much prefer something that is free!
Would Java's Desktop API meet your requirements? It does launch another process, but it's not through you calling Runtime.exec().
The Desktop API uses your host operating system's file associations to launch applications associated with specific file types.
Update: pdfHelp from IDR solutions (creators of JPedal) works now. The latest version (4.0) has fixed the bug and it reads my pdf files (and I am sure more of the latest pdf files). Just playing around with the product today and it is great! There are few minor bugs but I really appreciate how quickly Mark Stephens(?) responded to the first bug. Good work guys!
I chose pdfbox for a similar use case - it's not perfect with every PDF, but works pretty well and is under active development. From the PDDocument you can get a list of PDPage objects, which have a convertToImage() method that gives you a BufferedImage you can draw on screen. I switched to this from pdf-renderer because I felt it gave better results in general.
PdfHelp has moved to its own domain at http://www.pdfhelp.org and have been updated to fix your issues and add some other improvements...
I've recently been charged with creating a Android & iphone app for work. That being said, I'm a css/php designer-developer with a bit of javascript in the mix.
I need to write a bit of Java (not javascript) that will convert a table based layout into a div based layout so that I can then have control over positioning, padding, and what not.
I see many similar post, but these post involve more "designer" oriented goals rather than functional control over positioning, layout and so on.
A good resource would be greatly appreciated as I can't seem to google an appropriate search string. My searches tend to yield more "free javascript code", "Java tutorials about making flashing banners", "How to make fading menus" and countless other rabbit holes that lead to wonderland.
Oh, Currently using eclipse with Android SDK & ADT plugins installed.
It would be much more easier if you have predefinied a set of rules how the conversion should actually be taken place. There is namely fairly a lot which needs to be taken into account. This is really not going to be a bit of Java.
If you're looking for an existing tool, in Adobe Dreamweaver you can do that by Modify > Convert > Tables to AP divs. But still, I question if those kind of tools provides exactly that what you need. As said, there's fairly a lot which needs to be taken into account and it's shooting in the dark without a clear set of rules/requirements.
you may have to write more than a bit of java. you will need parse the html (http://www.benmccann.com/dev-blog/java-html-parsing-library-comparison/) and walk the dom (How to search in a HTML file for some tags?). that's fairly straightforward (assuming that your html is well formed), but i suspect that turning each table element into a div will require a moderate amount of code.
as BalusC pointed out, there may be tools that can get you part of the way, so you might try to do it in two passes.