How to print a .pdf file from Java without using Adobe AcrobatReader (portable code) from an applet

Hi everybody,

I have an applet and i want to preview and print a .pdf file.
The applet must be platform independent, the file must be printed on one of the local printers, so the solution shouldn't be using acrobat reader.

10x

valipotor
LVL 6
valipotorAsked:
Who is Participating?
 
Giant2Commented:
Agree with colr_,
you cannot ask the printer if the print job is finished and paper was printed correctly. It cannot answer for it.
0
 
objectsCommented:
0
 
Giant2Commented:
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Giant2Commented:
Even PDF4Java:
http://sourceforge.net/projects/pdf4j

Bye, Giant.
0
 
valipotorAuthor Commented:
Hi Giant,

pdf4j - This project has not yet created any file release packages.

As for the first link, I was expecting a more precise info. The matter is of urgent nature, that's why i gave 500 points for this question.

Hi objects,
 I 'm now downloading pdfbox ... however, the lib has about 3MB. This can be a problem if used from an applet.

valipotor
0
 
hoomanvCommented:
Java libraries to read and write PDF files
http://schmidt.devlib.org/java/libraries-pdf.html
0
 
valipotorAuthor Commented:
Hi hoomanv,
I am trying to print an exisiting pdf file to a printer, not create a pdf file.
And because i am writing an applet, i also need the .jar file to be small, let's say under 500k.

10x
0
 
objectsCommented:
I'm not aware of anything that meets those requirements sorry
0
 
colr__Commented:
If this is an applet, then you are going to either have to embed any Java PDF code you manage to find (which as Objects says, there isnt a package that meets your requirenemtns, to my knowledge).

Why do you ned to explicitly control how the pdf is sent to the printer, when Adobe reader perfoms all that for you (and nearly all clients have that s/w installed).

Your certainly not going to be able to do this in under 500k - youll need code to breakdown the pdf and send it to the printer in an acceptbale format, which is a lot of code to do something quite simlpe. Id recomend that you reconsider the adobe suite. Its reliable, popular, and you can almost rely on your clients as having it installed.

colr__
0
 
valipotorAuthor Commented:
Hi colr,

I need the posibility to control the print process. That is, after i have printed something, i have to mark the document as unmodifiable.
Using acrobat reader is no good, I must be able to determine if the user has printed the document or not.

And here are some other issues:

See the article at
http://princeoflightning.blogspot.com/2005/12/silent-print-pdf-print-pdf.html

One such product capable of doing that is the free Adobe Acrobat Reader. This well-known product does have it's limitations however. Command line options to print the PDF are undocumented / unsupported by Adobe. The Acrobat Reader process is known to start, print and continue running even after a silent print via command line; a bug that's not yet fixed by Adobe. Which means - you should expect to see a blank Acrobat Reader window after the "silent print". There are "beat around the bush" methods to attain certain amount of success using the commandline options - not for those who want "da perfect solution".
Inter Application Communication (IAC PDF reference file available at link) with the free Acrobat Reader cannot be done via OLE automation give the fact that Acrobat Reader is not a OLE server; you can get some luck only with Acrobat Standard or Pro. Only DDE messages can help a programmer write an application to achieve this. DDE will have restrictions that are not faced by an OLE Server. [If you don't know the difference then you musn't be doing this anyway].

Best regards,
valipotor
0
 
colr__Commented:
Is it not enough to assume that if the print button is pressed that the print will have occured? I take it you want to know for sure that the document has been printed, in that the button has been pressed and the paper has actually been ejected from the printer?

Would it be possible to simplify the process and ask the user if the print was succesfull?

An interesting problem...

colr__
0
 
valipotorAuthor Commented:
Giant2:
Nope, i don't want that. I want to be able to see if the button was pressed (and the confirmation dialog button, and so on ...), or if I use an external program such as Adobe then this is not possible.

That's why I wanted to try a silent print ... to be able to determine if the print has at least started.

colr_:
>>Would it be possible to simplify the process and ask the user if the print was succesfull?

This would mean to change the specs, this will be the last solution, if nothing else works.

valipotor
0
 
colr__Commented:
Im afraid that might be your only option. As soon as you press the print button, your java code will send the print command to the OS/print driver. At this point the print dialogue (or not, if using a silent print) would appear and you would lose control from your java program (the print dialoge (or silent) is launched in a completely seperate process).

Sorry, but there isnt any way of doing this w/o having some code that could directly interfae with the print process (this would typicallty invlove JNI, which is bad news as your code wouldnt be cross-platform compatible and would need some low-leeval coding, typically c/c++).

Sorry, but hope we helped!

colr__
0
 
valipotorAuthor Commented:
Hi guys,

I haven't found anything that could solve my problem, so i decided to change the specs. I am now downloading the file to the local computer, and then , using JDIC I will launch the default viewer for the .pdf file.
The user will have to specify that the file was printed.

0
 
colr__Commented:
yeh, I think thats the best (only!) solution.

colr__
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.