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...
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 have a application which is created on ZK Framework , i want to give user a functionality where user can open a saved file in edit mode and then again saved the changed in database can any one know which API can help me to do this?
You could use Google Apps to do so and set Google Docs to edit your DOC, PDF or even XLS extension files. For more help on setting it up, feel free to ask again. :)
The problem you're posing doesn't have a simple answer, unfortunately.
There are two general approaches you could take..
The low hanging fruit is to provide an interface for the user to download a file and upload it after they make edits using whichever editing software they choose / is appropriate.
The other approach would be to provide a GUI to edit files. Regardless of the web framework you are using, this is a daunting task to say the least. As #userRandom mentioned, this is a large part of what Google Drive (formerly Google Docs) is attempting to solve.. but even Google's solution is not perfect and very much a work in progress.
I would strongly suggest evaluating the scope of your project before proceeding.
If you choose to move forward, consider a simple solution that works for .txt files. Then, consider how you might handle .doc files. Then, PDF files, XLS files, etc.
Folks here will be able to answer specific questions.
In a work-related project, we want users to be able to write a document (in say Word) then upload this to our central web server. When they want to make changes, they visit the website and downloads the document. When changes are registered, the document is uploaded automatically.
I have written a few Java classes that does the work for me (FTP upload/download, File monitoring etc), but I'd like some input on how to solve the practical part of it.
Should the web page include a Java Applet that contains a Download button? When clicked, the document is downloaded and the associated editor is opened.
If so, how should I proceed? If the user closes his browser, wont be applet be terminated as well?
I have never worked on a such project before, and since Stackoverflow is filled with incredible smart people, maybe some of you could come up with some ideas?
PS: I'm new to posting on Stack, so please let me know if I should be more specific / add more information etc. :)
Best regards!
EDIT:
The application is only going to be used internally in our offices. Sorry if I caused confusion. :)
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
Can someone explain how does this website accesses the contents of the clipboard and displays it?
http://snag.gy
I am working on a similar project and need to make use of this functionality where users can ctrl+v paste an image. Also, if the site is using Java plug-in, why doesn't my chrome pop up out-of-date warning?
Any help is appreciated!
Thank you.
You should be able to tell that by looking at the source (http://snag.gy/assets/js/index.min.js). The code will be unreadable since it's minified, but you can make it readable with a code beautifier (such as http://jsbeautifier.org/).
It uses a java applet to read your clipboard (it's adding it to the page dynamically). It also contains a reference to http://code.google.com/p/zeroclipboard/ which is a flash-based solution mentioned here . I saw that it also makes use of the clipboardData object.
Looks like there are several fallbacks depending on the browser, and also it uses different mechanisms based on the origin of the copied data. You could start with How does the paste image from clipboard functionality work in Gmail and Google Chrome 12+? and fallback to a java applet if the browser is older.