-3

is it possible to merge jar file with pdf as I am developing an application which i want people to use if they want to download my PDF file.

james
  • 91
  • 1
  • 3
  • 6

3 Answers3

1

If what you mean is that you want to embed a jar in a .pdf, you could use a PDF portfolio to do that, which is a misfeature in Acrobat that allows you to embed arbitrary files and files with viruses (did I say viruses? Yeah.), so you could embed a .jar into a PDF.

If what you mean is that you want to physically put a PDF into a JAR, you can do that easily since a jar is a glorified .zip file. There's nothing to stop you from doing that.

If what you mean is to create PDF from a java application on the fly. There are a number of tools that can do that, including iText, and JoltPdf.

If what you mean is to execute a java application/applet from a PDF, likely no, although in theory it could be done with either an embedded or remote go-to action attached to some object within the PDF, but these are a pain to create, your jar would have to live either embedded or as a side-car file and you'd have to hope that on target systems there would be something to sanely open and execute a jar, and likely Acrobat would warn the hell out of any user taking that action since it is a vector for Trojan horses (I sure as hell wouldn't allow it).

If what you mean is to create a more interactive experience within Acrobat via Java, Adobe's answer is to use javascript and good luck. In theory, you could write an extension (FWIW, I helped develop the plug-in architecture in Acrobat and that's a big firehose to drink from) that could add Applet annotations to PDF and work that way, but in order for the extension to work, it would need to be signed by Adobe in order to run and you'd then have to host a Java VM for every plug-in instance.

plinth
  • 48,267
  • 11
  • 78
  • 120
0

The way you have worded your question it sounds like you want to display a java application inside a pdf file? That just is not possible.

If you were interested in putting a PDF file inside a Jar file, look at this
Create PDF with Java

Community
  • 1
  • 1
LROBERTS
  • 11
  • 1
-2

How to download and save a file from Internet using Java?

You can do something like the following:

URL website = new URL("http://www.website.com/information.asp");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("information.html");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
Community
  • 1
  • 1
Bioto
  • 1,127
  • 8
  • 21