Board index » jbuilder » Opening a PDF File

Opening a PDF File


2004-10-28 05:20:14 AM
jbuilder4
I am a former FoxPro developer migrating to Java. How would I open a PDF file for viewing in Java?
 
 

Re:Opening a PDF File

Matt wrote:
Quote
I am a former FoxPro developer
migrating to Java. How would I open
a PDF file for viewing in Java?
I'm not sure you can "view in Java", but
if you can settle for opening a PDF in
a native viewer like Acrobat, you could
try something like
Runtime.exec("Acrobat", filename);
(That's just off the top of my head;
you'll have to do some research on
the exec() method. Google is your
friend; use it to search the archives
of these newsgroups and other resources
on the keyword of "runtime.exec" -- use
double-quotes to indicate an exact phrase
search requirement.)
If what you want to do is read and write
PDF source, you might want to check
one of several PDF/Java libraries.
One is
www.lowagie.com/iText/
Another is PJ
www.etymon.com/epub.html
Again, Google is your friend: think, enter
search pattern, press return.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:Opening a PDF File

On 10/27/2004 at 11:27:23 PM, Paul Furbacher [TeamB] wrote:
Quote
>I am a former FoxPro developer
>migrating to Java. How would I open
>a PDF file for viewing in Java?

I'm not sure you can "view in Java", but
if you can settle for opening a PDF in
a native viewer like Acrobat, you could
try something like
Adobe produced a an all-Java Acrobat Viewer quite a while back. I tried
it and as I recall, it was rather slow, but it seemed to work well. It
looks like it is still available, but I am not sure if it is viable with
current JDKs. It is available here:
www.pacific.adobe.com/products/acrviewer/main.html
There are other all-Java PDF viewers available. I know that IceSoft has
one. FYI, these are the guys who produce the HTML viewer used in JBuilder.
www.icesoft.com/
Quote
Again, Google is your friend: think, enter search pattern, press return.
Yes, that should always be the first thing to try.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html
 

{smallsort}

Re:Opening a PDF File

"John McGrath [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
On 10/27/2004 at 11:27:23 PM, Paul Furbacher [TeamB] wrote:

>>I am a former FoxPro developer
>>migrating to Java. How would I open
>>a PDF file for viewing in Java?
>
>I'm not sure you can "view in Java", but
>if you can settle for opening a PDF in
>a native viewer like Acrobat, you could
>try something like

Adobe produced a an all-Java Acrobat Viewer quite a while back. I tried
it and as I recall, it was rather slow, but it seemed to work well. It
looks like it is still available, but I am not sure if it is viable with
current JDKs. It is available here:

www.pacific.adobe.com/products/acrviewer/main.html

There are other all-Java PDF viewers available. I know that IceSoft has
one. FYI, these are the guys who produce the HTML viewer used in JBuilder.

www.icesoft.com/

>Again, Google is your friend: think, enter search pattern, press return.

Yes, that should always be the first thing to try.

--
Regards,

John McGrath [TeamB]
I would like to be able to open the pdf file through its native viewer. I tried various variations of the following code that I found on the net:
cmd = "ls df6900.pdf";
Process rt = Runtime.getRuntime().exec(cmd);
DataInputStream showIt = new DataInputStream(rt.getInputStream());
I substituted various commands for cmd. I received an IO error for EVERY command that I entered. Is there a piece to the puzzle that I missed? Thank you very much for your time and patience.
Respectfully,
Matt
Quote

---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html
 

Re:Opening a PDF File

"Matt" < XXXX@XXXXX.COM >writes:
Quote
I substituted various commands for cmd. I received an IO error for
EVERY command that I entered. Is there a piece to the puzzle that I
missed? Thank you very much for your time and patience.
That Runtime.exec() does not use the PATH for security reasons. You
need to be explicit ("/bin/ls" in this case) as to where a program is
located.
For Windows it's somewhat easier in that you can use "start" to invoke
any file's default viewer.
Also, using the single-String method has risks related to escaping
spaces in filenames etc. You should ALWAYS use the String[] method for
this reason, where you split the commandline before the shell gets at
it.
 

Re:Opening a PDF File

Tor Iver Wilhelmsen [TeamB] wrote:
Quote
For Windows it's somewhat easier in that
you can use "start" to invoke
any file's default viewer.
Likewise, with OS X, you can use
Runtime.getRuntime().exec(
new String[] { "open", "pdfFilename" });
where variable pdfFilename is the
/path/to/file/filename.pdf
From an OS X Terminal session, do a
man open
to read the details. I'd advise doing
a quick test from the command-line
in the Terminal to see that the command is
correct before putting it into code.
For instance, I just did
% open /Users/pf/Desktop/*.pdf
It worked, maybe too well, because I didn't
realize that I had some rather large PDFs
sitting on my Desktop. The hard disk cranked
for a while, apparently while it opened the
"Subversion" book.
If the PDFs are in sub-directories of the
user.dir, you probably can use relative
paths, as you could from the command-line:
[PFs-Computer:~/Desktop] pf% open ./Subversion.pdf
(Incidentally, this same kind of question came
up in the macintosh newsgroup the other day.
I'm just expanding on the solution arrived at
there.)
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:Opening a PDF File

Dear All,
I have a database containing HTML.
I have written an IW app which does a good job of displaying it, including
the embedded image tags which are in the form
<src="/Files/Images/FileName.jpg">.
I pass the content into a TIWText object with RawText := true; and it shows
in the browser very nicely.
The same content contains links to pdf files in the form:
<a HREF = "/Files/ProjectTechnicalReports/R5732_2PS.pdf">Leaflet: Tree
fodders for livestock on smallholder farms</a>
... These segments show as HTML links & I had hoped that clicking them would
open the PDF ... but it does not.
Is there a work-around for this, or how do I achieve this functionality?
Adam
 

Re:Opening a PDF File

As far as I remember IW doesn't allow access to Subdirs by default. You are
putting your PDF file inside a Subdirectory. There was an option to overcome
this. Something like AllowSubDirs in the SessionManger.
"adam brett" < XXXX@XXXXX.COM >wrote in message
Quote
Dear All,

I have a database containing HTML.

I have written an IW app which does a good job of displaying it, including
the embedded image tags which are in the form
<src="/Files/Images/FileName.jpg">.
I pass the content into a TIWText object with RawText := true; and it
shows in the browser very nicely.

The same content contains links to pdf files in the form:
<a HREF = "/Files/ProjectTechnicalReports/R5732_2PS.pdf">Leaflet: Tree
fodders for livestock on smallholder farms</a>

... These segments show as HTML links & I had hoped that clicking them
would open the PDF ... but it does not.

Is there a work-around for this, or how do I achieve this functionality?

Adam

 

Re:Opening a PDF File

Thanks for this, but I already have ServerController.AllowSubFolders :=
true;
The key issue is that all my images are loading fine, whether the path
contains sub-folders or not. However the links embedded in the HTML don't
run.
A decent clue (though I haven't figured out a solution) is that when I hover
the mouse over the link I can see the following in the browsers status-bar
(at the bottom of the page)
www.mydomain.co.uk/myissapiappname.isa/EXEC/40/\files\library\RNRSSOutputs\Filename.pdf
... note that this is not a valid URL. The first part is the URL for the
page (up to the "40") the section after that is the part for the file-link.
1. Can I put a Java script on the page that would respond to the above URL
correctly opening the pdf file?
2. Can I re-write the link (the "\files\library\RNRSSOutputs\Filename.pdf"
part) so that it would work?
3. ... or is there another way!
Adam
"Farshad" < XXXX@XXXXX.COM >wrote in message
Quote
As far as I remember IW doesn't allow access to Subdirs by default. You
are putting your PDF file inside a Subdirectory. There was an option to
overcome this. Something like AllowSubDirs in the SessionManger.

 

Re:Opening a PDF File

Interesting!
I wrote a small program and assigned below code to IWText1 and it works
fine.
IWText1.Lines.Add('<a
href="/Files/ProjectTechnicalReports/R5732_2PS.pdf">Link</a>');
When I hover over the Link it correctly displays the desired path:
127.0.0.1/Files/ProjectTechnicalReports/R5732_2PS.pdf
 

Re:Opening a PDF File

Hi Adam,
Quote
A decent clue (though I haven't figured out a solution) is that when I hover
the mouse over the link I can see the following in the browsers status-bar
(at the bottom of the page)

www.mydomain.co.uk/myissapiappname.isa/EXEC/40/\files\library\RNRSSOutputs\Filename.pdf
Are you using \ or / to specify the path to your files? It may be that
you specified it using \ instead of / in one or more places...
Quote
Adam
Groetjes,
Bob Swart
--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
CodeGear Technology Partner -- CodeGear RAD Studio Reseller (BeNeLux)
Blog: www.drbob42.com/blog - RSS: eBob42.com/weblog.xml
 

Re:Opening a PDF File

Thanks for both of these responses. It actually seems like I may have a more
deep-seated problem.
In order to get around my first problem with the TIWText component, I have
created a URL component & tried several methods to navigate to a URL from
it.
In every case my IWApp just gives a "Timeout" error when I click on the item
... whether it is an IWText, an IWURL or even a button with the code
WebApplication.NewWindow('www.stepsystemsdata.co.uk/html/cgi-bin/Files/Help/index.htm');
in it.
... is there something I have to set in my IWApplication to allow it to
navigate "out" to other pages??
Adam
"Farshad" < XXXX@XXXXX.COM >wrote in message
Quote
Interesting!
I wrote a small program and assigned below code to IWText1 and it works
fine.

IWText1.Lines.Add('<a
href="/Files/ProjectTechnicalReports/R5732_2PS.pdf">Link</a>');

When I hover over the Link it correctly displays the desired path:

127.0.0.1/Files/ProjectTechnicalReports/R5732_2PS.pdf

 

Re:Opening a PDF File

Quote
WebApplication.NewWindow('www.stepsystemsdata.co.uk/html/cgi-bin/Files
/Help/index.htm');
This is not a valid fully qualified URL. It would be looking for the file
at something like: www.youriwserverurl.co.uk/exec/0/12093102301233123/www.stepsystemsdata.co.uk/html/cgi-bin/Files/Help/index.htm
You probably just need to include the http:// to the beginning of the URL
line.
 

Re:Opening a PDF File

"adam brett" < XXXX@XXXXX.COM >wrote:
Quote
Thanks for both of these responses. It actually seems like I may have a more
deep-seated problem.

Did you manage to sort this out? I have a similar sort of problem, trying to user a TIWLink or a TIWURL to open help files in another Window. I noticed that the ServerController has an InternalFilesDir and InternalFilesURL. Are they relevant?
Peter