PDF in Swing
How to open PDF through swings
String command="AcroRd32.exe file.pdf";
Runtime.getRuntime().exec(
"rundll32 SHELL32.DLL,ShellExec_RunDLL " + command);
Similar Messages
-
Hi Java GURUS
Firts of all, I would like to start with my introduction. My self Prashant Kadam. Right now i am developing a small system in java for my organization. This application is realted with art. And here we are dealing with PDF files. So application needs to open a PDF file within the frame / applet.
I have tried my level best to creack this problem. But still i am unable to solve it. I will be thank full to you, if i get solution from your end. I have also tried with some APIS. but they don't allow me to draw on this.
Thanks in adavnce
Waiting for a reply
Regards
Prashant KadamHello,
The following should help:
http://sourceforge.net/projects/itext/
http://www.oreillynet.com/pub/d/1305
http://sourceforge.net/projects/gnujpdf/
http://sourceforge.net/projects/pdfbox/
Best regards,
Bert Szoghy
Quadmore Software Services
http://www.quadmore.com
"Home of Java Rollout for Windows" -
I have a url for a pdf file and I want to open that file in a swing jpanel.I have upgraded to Java 1.6.0_27 and previously had 1.5.0_06
In Java 1.5 ,I was using jdic to do this for that the user needed to download jdic setup on their desktop to view images
but now I dont find any documentaion for java 1.6.0_27 and jdic setup.So i thought of doing this without the jdic .In java 5, I was using the beow code to show the pdf in swing jpanel.This basically embedds pdf in a web browser and then add it to swing jpanel.
import org.jdesktop.jdic.browser.*;
import org.jdesktop.jdic.browser.internal.*;
WebBrowserUtil.enableDebugMessages(false);
WebBrowserUtil.getDebug();
WebBrowser webBrowser = null;
URL pdfURL = testUrils.getPdf("Pathof .pdf");
try {
webBrowser = new WebBrowser();
webBrowser.setDebug(false);
webBrowser.setURL(pdfURL);
} catch (java.lang.UnsatisfiedLinkError el) {
catch (Exception e) {
//System.out.println(e.getMessage());
System.out.println("Error: " + e.getStackTrace());
JPanel pantestBrowser= new JPanel();
pantestBrowser.setLayout(new BorderLayout());
pantestBrowser.setPreferredSize(new Dimension(700, 500));
pantestBrowser.setLocation(0,0);
pantestBrowser.add(webBrowser, BorderLayout.CENTER);
I want to do the same thing without the jdic webbrowser.Is there a way out to do this?
I tried to do with java.awt.desktop
Desktop desktop=Desktop.getDesktop
desktop.browse(pdfurl.toURI())
This opens the pdf in a new adobe window and not inside the jpanel.
Thanks,885522 wrote:
I have a url for a pdf file and I want to open that file in a swing jpanel.I have upgraded to Java 1.6.0_27 and previously had 1.5.0_06
In Java 1.5 ,I was using jdic to do this for that the user needed to download jdic setup on their desktop to view images
but now I dont find any documentaion for java 1.6.0_27 and jdic setup.Have you tried to install and use jdic with 1.6 exactly as with 1.5?
To be honest I don't find any documentation either, that would state jdic is independent of the JRE version (various links broken). But since jdic essentially provides a wrapping API to deal with native resources, I would assume it is relatively independant of changes that have occurred in the JRE between 1.5 and 1.6. At least I would try it :o)
So i thought of doing this without the jdic .In java 5, I was using the beow code to show the pdf in swing jpanel.This basically embedds pdf in a web browser and then add it to swing jpanel.Does this code work with 1.6?
I want to do the same thing without the jdic webbrowser.Is there a way out to do this?
I tried to do with java.awt.desktop
This opens the pdf in a new adobe window and not inside the jpanel.Yes, as documented by the Javadoc.
Good luck.
J.
EDIT: please use code tags when posting code, to display it properly formatted. Like this: {noformat}this.isFormattedCode(){noformat}:
this.isFormattedCode() -
Sqlldr with error: non-numeric character was found when numeric number
Hi,
I have been struggling with this problem for long, can't get to anywhere.
I am trying to use sqlldr to load a CSV file into table, the table looks like this :
AD_ID NUMBER(38)
CNTCT_ID VARCHAR2(60)
AD_FILE_NAME VARCHAR2(80)
AD_TITLE VARCHAR2(300)
AGCY_APRVL_DATE DATE
CORE_APRVL_DATE DATE
ENTR_CMNT CLOB
IC_APRVL_DATE DATE
PURP_TEXT CLOB
RVW_BRD_APRVL_DATE DATE
ACTIVE_FLAG VARCHAR2(1)
.......................................more fields
The control file looks like this:
LOAD DATA
INFILE "C:\ORACLE_IRTMB\IRPADS\SQL_DATA\ADS_T.CSV"
BADFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.BAD"
DISCARDFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.DSC"
truncate INTO TABLE ADS_T
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
AD_ID INTEGER ,
CNTCT_ID char ,
AD_FILE_NAME char ,
AD_TITLE char nullif (AD_TITLE=BLANKS) ,
AGCY_APRVL_DATE DATE "MM/DD/YYYY" nullif (AGCY_APRVL_DATE=BLANKS) ,
CORE_APRVL_DATE DATE "MM/DD/YYYY" ,
ENTR_CMNT CHAR(7000) nullif (ENTR_CMNT=BLANKS) ,
PURP_TEXT CHAR(7000) nullif (ENTR_CMNT=BLANKS) ,
RVW_BRD_APRVL_DATE DATE "MM/DD/YYYY" ,
ACTIVE_FLAG char ,
....more fields
The Data file looks like this:
10132,simpsonl,PMSDHHStemplate.pdf,"Depression, Irritability, Mood Swings Sound Familiar?",1/13/2003,11/14/2002,,1/13/2003,"The NIMH is conducting research on premenstrual
10133,jolkovsl,10133ClozapineDHHS ver 0.pdf,Mood Swings? Unpredictable Moods? Are These Moods hard to Treat?,1/28/2003,11/14/2002,,1/28/2003,"The NIMH is conducting a study to test the efficacy of ...
--- and log file looks like this:
Record 5: Rejected - Error on table ADS_T, column RVW_BRD_APRVL_DATE.
second enclosure string not present
Record 7: Rejected - Error on table ADS_T, column RVW_BRD_APRVL_DATE.
second enclosure string not present
Record 9: Rejected - Error on table ADS_T, column RVW_BRD_APRVL_DATE.
second enclosure string not present
Record 2: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01858: a non-numeric character was found where a numeric was expected
Record 4: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01858: a non-numeric character was found where a numeric was expected
Record 6: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01858: a non-numeric character was found where a numeric was expected
IF I use to_date in control file:
LOAD DATA
INFILE "C:\ORACLE_IRTMB\IRPADS\SQL_DATA\ADS_T.CSV"
BADFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.BAD"
DISCARDFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.DSC"
truncate INTO TABLE ADS_T
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
AD_ID INTEGER ,
CNTCT_ID char ,
AD_FILE_NAME char ,
AD_TITLE char nullif (AD_TITLE=BLANKS) ,
AGCY_APRVL_DATE "to_date(:AGCY_APRVL_DATE,'MM/DD/YYYY')" ,
CORE_APRVL_DATE DATE "MM/DD/YYYY" ,
ENTR_CMNT CHAR(7000) nullif (ENTR_CMNT=BLANKS) ,
IC_APRVL_DATE DATE "MM/DD/YYYY" ,
PURP_TEXT CHAR(10000) nullif (PURP_TEXT=BLANKS) ,
RVW_BRD_APRVL_DATE DATE "MM/DD/YYYY" ,
I got extracctly same error message as above...
If I use to_char in control file:
LOAD DATA
INFILE "C:\ORACLE_IRTMB\IRPADS\SQL_DATA\ADS_T.CSV"
BADFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.BAD"
DISCARDFILE "C:\ORACLE_IRTMB\IRPADS\ADS_T.DSC"
truncate INTO TABLE ADS_T
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
AD_ID INTEGER ,
CNTCT_ID char ,
AD_FILE_NAME char ,
AD_TITLE char nullif (AD_TITLE=BLANKS) ,
AGCY_APRVL_DATE "to_char(:AGCY_APRVL_DATE,'MMDDYYYY')" ,
Then it's said a not valid number
Record 2: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01722: invalid number
Record 4: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01722: invalid number
Record 6: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01722: invalid number
Record 8: Rejected - Error on table ADS_T, column AGCY_APRVL_DATE.
ORA-01722: invalid number
someone, please help me out here.
Thanks a lot.
Weihello
pls use to_date
If your session is set to default date format of DD-MON-YY, execute the following and you will receive the error message:
SQL> select to_date('20-JAN-2010', 'DD-MM-YYYY') from dual;
ERROR:
ORA-01858: a non-numeric character was found where a numeric was expected
no rows selected
When you are converting a string to a date, you have specified that the date is being passed in DD-MM-YYYY format. But you have passed the date in DD-MON-YYYY format. As the month is expected as a number by oracle, but you have passed a character, oracle is unable to translate the string to a number.
Do one of the following:
SQL> select to_date('20-JAN-2010', 'DD-MON-YYYY') from dual
2 /
TO_DATE
20-JAN-2010
OR
SQL> select to_date('20-10-2010', 'DD-MM-YYYY') from dual
2 /
TO_DATE
20-JAN-2010
or you can use alter sessin set nls_date_format='.....................';
regards -
How can i manipulate pdf files with my swing application
hi all,
in my database i have a column (blob type) in which i want to store pdf files from swing.
is any body have solution.
i need it urgently.
thanksthanks bryano for repling.
but i really don't know how to do.
if you can give me a how to do or an exemple.
plz it is really urgent.
i have to return work as soon as possible -
How to generate jasper report in pdf format using swing
hi all,
im new to swing and jasper.. can anybody provide me some example on how to generate the jasper report in pdf format? i will call the reportManager from sessionBean.. below is my code:
1)delegate:
public GenerateReportDto generateIntoPdfReport(String fileName, String outputFileName, Map parameters){
GenerateReportDto generateReportDto = getAuditTrailServiceRemote().generateIntoPdfReport(fileName, outputFileName, parameters);
return generateReportDto;
2)sessionBean:
public GenerateReportDto generateIntoPdfReport(String fileName, String outputFileName, Map parameters){
//Map parameters = new HashMap();
ReportManager reportManager = new ReportManager();
3)ReportManager()
public void generateIntoPdfReport(String fileName, String outputFileName, Map parameters) {
Connection conn = null;
try {
conn = dataSource.getConnection();
//Generate the report to bytes
File reportFile = new File(fileName);
byte[] bytes =
JasperRunManager.runReportToPdf(
reportFile.getPath(),
parameters,
conn
//conn.close();
//Write the bytes to a file
ByteBuffer buf = ByteBuffer.wrap(bytes);
File file = new File(outputFileName);
// (if the file exists)
boolean append = false;
// Create a writable file channel
FileChannel wChannel = new FileOutputStream(file, append).getChannel();
// Write the ByteBuffer contents; the bytes between the ByteBuffer's
// position and the limit is written to the file
wChannel.write(buf);
// Close the file
wChannel.close();
} finally {
if (conn != null) {
conn.close();
Any help would be highly appreciated. Thanks in advanceHi ,
One 'simple' way is by using the DBMS_SCHEDULER db package and the procedure CREATE_JOB(....) using as job_type the value 'EXECUTABLE'...
Read for further info in 'PL/SQL Packages and Types Reference'.
If you have access to OEM ... you can configure this there using wizard.....
Other way is to use the External Procedure call capabiblity of Oracle DB Server...:
http://www.oracle.com/pls/db102/ranked?word=external+procedure+call&remark=federated_search
My greetings,
Sim -
How to generate pdf report in swing
Hello,
can you help me?
i want to generate pdf report in my swing based project but i don't know about any idea of this report generating
procedure . Please help me.shesh_07 wrote:
Hello,
can you help me?Can you help yourself? Two suggestions I have for posting to a technical forum are:
1) Add an upper case letter to the start of each sentence. This helps the reader to scan the text quickly, looking for the important parts. It also helps to dispel the impression that the writer is just lazy.
2) Try to do some research on your own, summarise it and state any conclusions you have reached. Ask a specific question and generally, try not to sound so pathetic.
i want to generate pdf report ..Search for [Java PDF|http://lmgtfy.com/?q=java+pdf] *(<- link).*
Figure how to generate a PDF report in a class used from the command line, then..
..in my swing based project .....wrap a GUI around that class. For details on the latter, see the [Swing tutorial|http://java.sun.com/docs/books/tutorial/uiswing/] *(<- link).*
..but i don't know about any idea of this report generating
procedure . Please help me.Please help yourself. -
How to print a PDF file from Swing(JFC/swing)
Hi,
I am able to dislay a PDF file in Swing but how can I print it from there. I want to do it without using Acrobat reader.You can use the "System Exec.vi". The command line should have the following structure:
"<Path to AcroRd32.exe>" /t "<Path to document>" "Printer name"
For example"
"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" /t "C:\myreport.pdf" "Tektronix Phaser 300i"
Regards;
Enrique
www.vartortech.com -
Opening a PDF file from a swing application in MAC
HI everyone,
Actually I am developing a swing application which should be executable in both windows and Mac (even other) platformes. In my panel I have an icon which leads to a pdf file. I saw in the following thread:
http://forum.java.sun.com/thread.jspa?forumID=17&threadID=617767
that we can use
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);to open what ever file in windows. I want to know what should I do if this application is running on Mac or Linux! I have never worked with these OS so I do not have any idea how to resolve the problem.
Can anyone help me with this matter?? That would be really nice of you to reply :)
Thanx and have a great day.Thank you for replaying so soon..
Well you are right by using a widget and etc.. but the problem is that I have been told that this application should open a PDF file that has bookmarks to each chapter of the text and one can make a search on this text by using pdf search.. So I do not have any other choice than opening a pdf :D and my time is unfortunately limit.
For solving the problem that the user may not have PDF reader.. well I have been told that user should install the pdf reader, so in my application package I am putting the installation file of PDF.
But going back to my problem.. I guess is someway I have to get the OS type of the user and I have to do a SWITCH or something on the OS type and then change the content of the Runtime.exec(). But the question is how can I get the OS type and what should I change in Runtime.exec().
So now any idea? any solution?? -
Working with pdf files in swing applications
Hi,
I have a swing application which displays a pdf file and contains a text box. i want to display the current page number of the pdf file in the text box.
Can any one please guide me how to implement the above functionality.
Regards,
TommyHow can i downsave pdf file in CC 2014?
This is very unfortune, because we use some VB script together with illustrator. That process is stopping now because of this message!!!
Dont know how i can solve this issue! -
Font Size problem : Swing font looks smaller than pdf font
Hi
I'm facing a problem with font size in my swing application. I'm showing some text with a certain predefined font size. Using the same font size and type on same m/c, I 'm generating some pdf text.
The problem is that the text in swing looks smaller than the same text in pdf. Is there a way to achieve
consistency in font sizes.please don't cross-post. pick the appropriate forum and use it. close your cross-thread.
-
Viewing and printing a PDF file from Java Swing Application
Hello,
I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
Thank you
Sumana SomareddyIf you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
Regards,
Tak. -
PDF document in a Swing Applet?
How can you display a PDF document in a Swing Applet?
I have implemented a document archiving solution that provides a Swing UI to search a database for available documents. All the documents in the archive are in the PDF format. To accomplish this I use an html frameset where a Swing applet is displayed in one frame and the PDF document is displayed in the lower frame. I use LiveConnect to have my javascript communicate with the applet. My applet calls a javascript function that causes the URL of the lower frame point to the PDF document. This works fine, but I would rather use an all Java UI instead of depending on the browser and javascript.
How can we get Adobe or Sun to address this need? -
Create a PDF file from swing component and print
Hi,
Suppose i have a JFrame where in i add a JScrollpane which has a JPanel with some painting on it, suppose i want to create a pdf file of the total JPanel, and not of what i see on screen like taking a screen shot, or print the total JPanel, and not only the screen that is displayed
how can i do it
I am attaching the code below, how can i create a pdf for MyPanel and print it
//start code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestDisplaySize extends JFrame
JScrollPane scrollPane ;
public TestDisplaySize()
super("layered pane");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
MyPanel panel = new MyPanel();
scrollPane = new JScrollPane(panel);
Container contentPane = this.getContentPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
setSize(new Dimension(800,600));
this.setVisible(true);
JViewport viewPort = scrollPane.getViewport();
class MyPanel extends JPanel
public MyPanel()
setPreferredSize(new Dimension(2000,600) );
this.setBackground(Color.white);
this.setOpaque(true);
public void paintComponent(Graphics g)
super.paintComponent(g);
setBackground(Color.white);
Rectangle r = scrollPane.getViewport().getViewRect();
g.setClip((Shape)r);
g.setColor(Color.blue);
int x = 0;
for(int i = 0; i < 60; i++)
x +=60;
g.drawLine(x, 0, x, 600);
g.drawString(String.valueOf(i), x, 50);
public static void main(String args[])
new TestDisplaySize();
//end codecreate a class wich implements printable, redefine the print method of this class with the this you want to print
and at the end of the constructor...
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat myFormat = new PageFormat();
myFormat.setOrientation(PageFormat.LANDSCAPE);
myFormat.setPaper(ps.getMyPaper());
printJob.setPrintable(this, myFormat);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception pe) {
System.out.println(pe); -
Pdf print and view using swing
hello
i am created one pdf file from original pdf file with data using itext library,but now my problem is how can view this file and print this pdf file using swing printing apibut how to print?
Note: Just because the PDF DocFlavor exists doesn't mean you can use it to print a PDF file. When you lookup the PrintService for the PDF flavor,it will report unsupported flavor. That means there is no print service for the flavor. Sun doesn't provide one for PDF files. To the best of my knowledge,nobody else makes one available either. Until such a time as someone does,you can't print PDF files using the new Print Service API.
??? is there another way to print a pdf-file directly from filesystem without using the command line like:
C:\..\Acrobat 5.0\Reader>acrord32.exe/t test.pdf
thanks for replys
mfg
Maybe you are looking for
-
Any way to change picture timezones?
Hi, I'm cleaning an older Aperture library and I've discovered a number of pictures that are listed with the incorrect timezone. Is there any way to change this after the files are already imported? To clarify: Aperture seems to store (in its own met
-
Looking for Security Best Practices documentation for Sybase ASE 15.x
Hello, I'm looking for SAP/Sybase best practice documentation speaking to security configurations for Sybase ASE 15.x. Something similar to this: Sybase ASE 15 Best Practices: Query Processing & Optimization White Paper-Technical: Database Manage
-
Java Matching and Patterns - help please.
Ok, so I'm trying to take a CSV file and store it as an XML file using Java. Here's a sample line of the data file I'm working with: 1001,"Fitzsimmons, Des Marteau, Beale and Nunn",109,"COD","Standard",,109,8/14/1998 8:50:02 I'm trying to use regular
-
Airport Utility 6.3 won't recognize my Airport Extreme.
In the process of adding an Airport Express to my home network I updated Airport Utility to version 6.3. Now the utility will not recognize my Airport Extreme (4th Gen.). After 2-1/2 hours on the phone with Apple Care they were adamant that it was a
-
i updated my lww befor to ics then my mobile ged slow rotation ,heets up with browsing even the browser not enlarging words but zooms in. so i downgraded to gb 2.3 dose the new update solved thees isues