17
Views
20
Comments
How to preview a pdf/word file without download it?

Hi All,

I want to ask, how can I preview the file without download it? the file type can be in PDF/Word/Excel. And if you ok, please give me an example about how to do it.  

Thank you


Regards,

Riesta

Rank: #133

Hi Riesta,


There is a component called Reactive Web Previewer which allows you to preview documents in Reactive applications.

It also includes a Demo where you can test and see how to implement it.


Hope it helps.


Cheers,

João

Rank: #1492
Rank: #133

Hi Riesta,


For Traditional Web, you can use the Web Previewer and you even have this sample to see how it works.


Hope it helps.


Cheers,

João

Rank: #133

Hi riesta,


You need to pass a parameter of the type Binary (the file itself) and it seems you are passing an id.


Cheers,

João

Rank: #133

Hi riesta,


Now that I'm looking to the component it asks for an input of type File structure. That being said, when you hover the left side of the File parameter, you'll see a +.

Once you you click, it will expand into the attributes

Now you can fill the Filename, the Binary in the BinaryData parameter and on the FileType, you should fill the following depending on the type of document:


  • Word document: application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • Excel document: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • Powerpoint document: application/vnd.openxmlformats-officedocument.presentationml.presentation
  • PDF document: application/pdf
  • Image. image/png


The types above are the mime types, these are some examples but you can search more on the internet about them.


Hope it helps.


Cheers,

João

Rank: #133

Have you set the parameter FileType with the values I mentioned according to the type as I mentioned above?

The parameter needs to be filled according to the type of the file.


  • Word document: application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • Excel document: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • Powerpoint document: application/vnd.openxmlformats-officedocument.presentationml.presentation
  • PDF document: application/pdf
  • Image. image/png


Cheers,

João

Rank: #133

Hi riesta,


Which values do you have in the database on the table Attachment, on the attribute FileType for the files that you are failing to preview?

Rank: #133

Hi riesta,


What I meant was that if it is not working for the other types of documents is because your FileType value is not a correct mime type.

Since you are filling the parameter from the database, you can check what you have in the database for the table Assignment. In order to do that, you right click the table Assignment on the tab and select option View Data:

When you do that, you will see the records you have in your table Attachment (in my screenshot empty but on your with results) and you can see if the FileType is correct according to the examples I showed you:

If your file is of type PDF, then your FileType field in the database should be application/pdf in order to work, and for the Excel and Word like I mentioned above.


Cheers,

João

Rank: #133

Hi Riesta,


With empty values, it is not going to work, right?

Working with the sample, I manage to upload a PDF file and have it working as you can see on the image below (I just uploaded the file and then clicked on the name of the file):


So, if you are using the same code and it is only working for images, it is something to do with data.

I think now the best thing you can do is to debug and see which mime types work for your files.


Cheers,

João