Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | "Dr.UgoGagliardelli" <do.not.spam@me.please> |
| Newsgroups | it.comp.java |
| Subject | Re: Accessing a PDF Document with the Acrobat Viewer JavaBean |
| Date | Thu, 12 Nov 2015 10:08:25 +0100 |
| Organization | Aioe.org NNTP Server |
| Lines | 92 |
| Message-ID | <n21kuo$ols$1@speranza.aioe.org> (permalink) |
| References | <n1n8ti$9c3$1@speranza.aioe.org> <n1pq4g$urs$1@speranza.aioe.org> <n1qbg3$ajn$1@speranza.aioe.org> <n1qhr0$qm1$1@speranza.aioe.org> <n1reqk$si2$1@speranza.aioe.org> <n1se2k$kaj$1@speranza.aioe.org> <n20hji$s27$1@speranza.aioe.org> |
| NNTP-Posting-Host | dV/rlRLZvEq97tAgOAs20w.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-15; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com it.comp.java:8784 |
Show key headers only | View raw
Il 12.11.2015 00.02, Gulp® ha scritto:
> Il 10/11/15 10:40, Dr.UgoGagliardelli ha scritto:
>> Comunque c'e' un open source gratuito molto flessibile, quello che uso
>> io, che si chiama ICE PDF Viewer lo trovi qui:
>> http://www.icesoft.org/java/projects/ICEpdf/overview.jsf
>
> E' possibile con installazione adeguata avere disponibile il componente
> nella palette del design di Netbeans? Come dovrei fare? Ho scaricato la
> seguente directory:
>
> ICEpdf-6.0.0-P01-bin
>
> Se non è possibile quanto sopra, installo normalmente nelle librerie
> disponibili, come faccio sempre i file *.jar, in particolare:
>
> icepdf-viewer.jar
> icepdf-core.jar
>
Non lo so, come ti dicevo non uso NetBeans.
In ogni caso l'icepdf-viewer e' abbastanza semplice da utilizzare.
Considera che alla fine della fiera si tratta di aggiungere un JPanel
alla tua frame.
I metodo fondamentali sono questi:
SwingController viewController = new SwingController();
URL pdfviewerProperties =
getClass().getClassLoader().getResource("pdfviewer.properties");
PropertiesManager propertiesManager = new
PropertiesManager(System.getProperties(),
pdfviewerProperties .getPath(), null);
SwingViewBuilder viewBuilder =
new SwingViewBuilder(viewController , propertiesManager);
JPanel viewerPanel = viewBuilder.buildViewerPanel();
File pdfFile = new File("documento.pdf")
URL pdfDocument = pdfFile.toURI().toURL();
viewController.openDocument(pdfDocument);
Il file pdfviewer.properties (che nell'esempio sopra si da' per certo
che si trovi nel classPath) contiene tutte le proprieta' per
visualizzare il pdf, compresi gli switch per mostrare i vari tools del
viewer.
il file pdfFile (che nell'esempio sopra si da' per certo che si trovi
nella directory corrente) potrebbe in relta' essere ricavato facilmente
con un JFileChooser che e' un componente molto semplice da utilizzare.
Considerando che gli oggetti del viewer non cambiano mai, potresti
incapsularli in metodi singletone, ad esempio:
private SwingController getViewController() {
if (viewController == null)
viewController = new SwingController();
return viewController;
}
private PropertiesManager getPropertiesManager() {
if (propertiesManager == null {
URL pdfviewerProperties = getClass().getClassLoader()
.getResource("pdfviewer.properties");
propertiesManager = new PropertiesManager(System.getProperties(),
pdfviewerProperties.getPath(), null);
}
return propertiesManager;
}
private SwingViewBuilder getViewBuilder() {
if (viewBuilder == null)
viewBuilder = new SwingViewBuilder(getViewController(),
getPropertiesManager());
return viewBuilder;
}
Se dai un'occhiata alla documentazione qui
https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
c'e' un esempio semplice semplice che adattato al tuo caso diventa:
private URL getpdfDocument() {
JFileChooser chooser = new JFileChooser();
URL pdfDocument = null;
FileNameExtensionFilter filter = new FileNameExtensionFilter("pdf");
chooser.setFileFilter(filter);
int returnVal = chooser.showOpenDialog(parent);
if(returnVal == JFileChooser.APPROVE_OPTION) {
pdfDocument = chooser.getSelectedFile().toURI().toURL();
}
return pdfDocument;
}
per cui, nell'esempio sopra diventa:
URL pdfDocument = getpdfDocument();
if (pdfDocument != null) {
JPanel viewerPanel = getViewBuilder().buildViewerPanel();
container.add(viewerPanel);
getViewController().openDocument(pdfDocument);
}
Back to it.comp.java | Previous | Next — Previous in thread | Next in thread | Find similar
Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-08 11:39 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-09 10:47 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-09 15:40 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-09 17:32 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-10 01:44 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-10 10:40 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Gulp®" <Adebval@email.it> - 2015-11-11 09:06 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-12 00:02 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-12 10:08 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-12 10:16 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-12 16:24 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-13 21:01 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-12 17:43 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-13 20:58 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Gulp®" <Adebval@email.it> - 2015-11-16 10:04 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-12 18:39 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-13 20:59 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "CarMas" <carmas@jpknet.com> - 2015-11-10 17:13 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean Gulp® <gulp@hotmail.it> - 2015-11-10 17:54 +0100
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean 4ndre4 <a.laforgia@gmail.com> - 2015-11-10 15:14 -0800
Re: Accessing a PDF Document with the Acrobat Viewer JavaBean "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-11-11 17:09 +0100
csiph-web