Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Ive installed ViewerJS on a webpage of my website and cant seem to figure out how to upload pdf files and make them viewable in the pdf reader...I studied some documentation over uploading files and how it says that I can uncomment the couch upload directory to point to a folder on my website but dont want to do that for every thing I upload....The code I have so far is
Code: Select all
<cms:editable name='PDF_document' label='Downloadable PDF File' desc='Upload the file here'
type='file'  />


Code: Select all
<iframe style="text-align:center;" src="<a href="<cms:show my_document />" >Download file</a>" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe> 


the original code for ViewerJs states that I have to put the document in the ViewerJS folder.

Code: Select all
<iframe style="text-align:center;" src="/ViewerJS/pdf/odoc.pdf" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe> 
.
Is there a way to upload pdf documents to this and make this work?
Hi,

You can upload the PDFs to the default location used by Couch - no need to change the path from config.

So assuming that you have installed ViewerJS in the site's root, try putting the following link in your template (modify the path if ViewerJS is not in site's root) -
Code: Select all
<a href="<cms:show k_site_link />ViewerJS/">View PDF</a>

Clicking the link should invoke ViewerJS. It will, of course, show up empty because we have not specified any PDF for it to show.

Now (assuming your 'file' editable region is named 'my_document'), modify the link above as follows to add the file to the link
<a href="<cms:show k_site_link />ViewerJS/#<cms:show my_document />">View PDF</a>

That should now show your PDF file in ViewerJS.

You can use the same technique while using ViewerJS in an embedded manner (i.e. IFrame) -
Code: Select all
<iframe src="<cms:show k_site_link />ViewerJS/#<cms:show my_document />" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>

Hope it helps.
Is there also a way to cloak the url in a way as to let people view the pdf but cant download it or print it? Ive attempted the cloak url core concept tutorial and got it however Id like the document to be there just not downloadable or printable-locked unless a level 4 access is achieved
a way as to let people view the pdf but cant download it or print it?
I don't that is possible. ViewerJS is a client-side program and will require access to the PDF in order to display it. And once a PDF is available that way, the cat is out of the bag (so to say).
4 posts Page 1 of 1