Is it possible to open or create a PDF file in a Java desktop application just like we can create text file?
From my search I got that it is possible only with web java. Is that true?
To open an existing PDF file in the desktop default reader you can use the following code:
File pdf = new File("/path/to/your.pdf");
Desktop.getDesktop().open(pdf);
(needs Java 6)
You can use iText to do this. Here is a nice tutorial.
There is an OS PDF plugin for Netbeans at http://www.jpedal.org/support_siNetBeans.php
You can not create PDF just like a normal Text file, you will need PDF Library to create one. Opening an existing PDF is possible like *a_horse_with_no_name* mentioned in his answer.
You can find some PDF Libraries here.
Related
Is there a way to open an existing PDF file with some template and continue drawing on it?
I'm using https://developer.android.com/reference/android/print/pdf/PrintedPdfDocument but it only works with new files.
There is nothing in the Android SDK that allows you to modify existing PDF files for any purpose, let alone printing. You will need to look at third-party libraries for that (e.g., iText).
I'm creating a JAVA application
and I want to create and display and print a PDF file.
Like this example:
http://img11.hostingpics.net/pics/331702Sanstitre.jpg
So can you give the right way to do it ?
I mean is this a pdf file displayed into a JPanel or something else ?
and thnx alot.
For working with PDF files I would recommend using a library such as Apache PDFBox which has the ability to write, read, and print PDF files using org.apache.pdfbox.PrintPDF
The API can be found Here
As for displaying it in the JFrame, you can simply read the text and print it out in a Swing Text Area
For generation of pdf files you can use Jasper Reports library. It is popular API for creation pdf files from template in which specific data is inserted. Template files have ".jrxml" extension and can be created and edited by Jaspersoft Studio. These files look like forms with variable fields, this is very useful for generating different kinds of reports.
The API for Jasper Reports Library can be found here.
I am OK with any command line utility too. Basically I want to convert AutoCAD files to PDF using AutoCAD. I know there are several PDF virtual printer drivers that do this even without AutoCAD installed but I am looking at high quality PDF generation.
Thanks,
Nitesh
All you need is Adobe Acrobat. See:
http://help.adobe.com/en_US/acrobat/X/pro/using/WS58a04a822e3e50102bd615109794195ff-7f35.w.html
Actually I am attempting to extract the data from a PDF file but I didn't find any example in the internet and I am asking if there is any possibility that I can use the JPedal library to open to read the data from a PDF file.
You can use PDFBox from Apache.
I am not familiar with JPedal, but I write lots of code that generates and processes pdf files. I use IText and highly recommend it. If you have a specific question on how to process a pdf file, let me know.
I would like to open a pdf file in a new Jframe.
the pdf file exist. I just need to open it and show it in a new Jframe.
I user itext to create the pdf file. do I need the same tool to open it.
please show me how.
thanks in advance.
It is not that easy and straightforward to open PDF inside Swing's JFrame. You can consider purchasing commercial tools such as pdfviewer or use embedded browser like JDIC and display your PDF using embedded PDF Viewer (i.e. Adobe Reader) inside an embedded browser but that is tricky as well.
I would rather seriously consider opening your PDF in OS default PDF viewer using java.awt.Desktop.open() method which is designed to be cross-platform. Note however, that Desktop class is available in Java 1.6 and later.