Also, you can look through the platform source code in IDEA: required functionality is presented on the ‘Administration - External Files’ screen (com.haulmont.cuba.gui.app.core.file.FileBrowser).
public void onDownloadButtonClick(Component source) {
FileDescriptor fd = contractAttachment.getSingleSelected().getAttachment();
if (fd!=null){
AppConfig.createExportDisplay(ContractEdit.this).show(fd,null);
}
}
Files are downloaded by calling the ExportDisplay.show() method.
Now, when the ‘Download’ button is pressed, highlighted attachment will be downloaded.
Thanks for the sample app. It worked when I connected my iPhone to view the PDF document but didn’t work in my Mac. On the other hand, JPEG file is previewed in Mac but not in my iPhone. I have cleaned and Assembled the project but no improvement! Wonder what could be the reason. Any clue?
public void onShowButtonClick(Component source) {
FileDescriptor fd = attachTable.getSingleSelected().getAttachment();
pdfView.setSource(String.format("pdf-preview%s.pdf", fd.getUuid()), new FileDataProvider(fd));
}
I’m not sure why it behave like this.
By the way, I only built it to preview pdf, not images.
I have only tried it on Chrome and Firefox on Windows an Android.
Please share experiences on other platforms and devices in this topic here.
You are free to do what you like with the source.
New experience is much welcome.
It will help others in Cuba-platform also.
Hi Mortoza,
Unfortunately, we cannot reproduce the problem. Please, send us more details about the version of your OS and browser. Moreover, which version of the platform do you use?
Hi
I have tested this file preview in several environments and browsers. Here is the result which is consistent with my previous feedback:
Does display pdf file successfully but not image file
a) Mac OS 10.11.4 and Safari 9.1
b) iOS 9.3.5 and Safari
Doesn’t display pdf file but does the image
a) Mac OS 10.11.4 and Chrome v 53.0.2785
b) Windows 10 and Microsoft Edge 25.10586.0.0
c) Windows 10 and Firefox 46.0.1
d) Windows 10 and Chrome 53.0.2785
Thanks for any further ideas. Please also help how can I display image file
Hi,
I know this is an old post but I not found a solution.
Also at mine project not work function displayPdf() on linux and windows with browser: Chrome, Edge and Opera but work (Pdf is displayed) on iPad with browser Chrome and Safari.
I have two questions:
How can fix this (to work with all browsers and all platforms (linux, windows, ))
Is possible two see all pages from pdf files, because now is displayed only first page (on iPad)
This is my code