Skip to content

Commit

Permalink
Added support for PDF.js
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertHajbok committed Aug 8, 2017
1 parent febd4ca commit f4b24b9
Show file tree
Hide file tree
Showing 373 changed files with 90,336 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ You can configure the following parameters of the viewer:
* Height: sets the height of the iframe
* FilePath: path to the file to be render on the HTML page
* TempDirectoryPath: path for the temporary converted to PDF files (see Word, PowerPoint and Excel sections below).
* PdfRenderer: is used by documents converted to PDFs (see below) and you can choose between [PDF.js](https://mozilla.github.io/pdf.js/) and [Adobe Reader](https://acrobat.adobe.com/uk/en/). Adobe Reader is used by default now, but this requires Adobe to be installed client-side. PDF.js is relying only on JavaScript, but the library is still developing. For further information check their websites.
### How to embed PDF documents?
For PDF documents, a simple iframe is generated, so the following line is enough to embed a document:
Expand All @@ -42,15 +43,18 @@ For PDF documents, a simple iframe is generated, so the following line is enough
<cc:DocumentViewer runat="server" Width="500" Height="500" FilePath="~/sample.pdf" />
```

You can additionally set the PdfRenderer parameter if you want to use PDF.js.

### How to embed Word documents?
Word documents are converted to PDF documents, then rendered in iframe. You should have Microsoft Office installed on the server for this to work.
You can embed a Word document as shown below:

```html
<cc:DocumentViewer runat="server" Width="500" Height="500" FilePath="sample.docx" TempDirectoryPath="~/TempFiles" />
<cc:DocumentViewer runat="server" Width="500" Height="500" FilePath="sample.docx" TempDirectoryPath="~/TempFiles" PdfRenderer="PdfJs" />
```

If TempDirectoryPath is not supplied, the converted documents can be found in the Temp directory of the project root.
If PdfRenderer is not supplied, Adobe Reader is used by default.


### How to embed PowerPoint documents?
Expand All @@ -62,6 +66,7 @@ You can embed a PowerPoint document as shown below:
```

If TempDirectoryPath is not supplied, the converted documents can be found in the Temp directory of the project root.
You can additionally set the PdfRenderer parameter if you want to use PDF.js.

### How to embed Excel documents?
Excel documents are converted to HTML files, then rendered in iframe. You should have Microsoft Office installed on the server for this to work.
Expand All @@ -72,6 +77,7 @@ You can embed an Excel document as shown below:
```

If TempDirectoryPath is not supplied, the converted documents can be found in the Temp directory of the project root.
You can additionally set the PdfRenderer parameter if you want to use PDF.js.

### Do you have an issue?
Have a bug or a feature request? Please search for existing and closed issues before submitting a new one. If your problem or idea is not addressed yet, please open a new issue.
Expand Down
6 changes: 4 additions & 2 deletions WebFormsDocumentViewer.UI/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
<div class="card text-center">
<div class="card-block">
<h4 class="card-title">PDF Viewer</h4>
<p class="card-text">This renders a PDF document in an iframe.</p>
<cc:DocumentViewer runat="server" Width="500" Height="500" FilePath="~/Samples/sample.pdf" />
<p class="card-text">This renders a PDF document in an iframe and uses
<a href="https://mozilla.github.io/pdf.js/" target="_blank">PDF.js</a> as the PDF renderer
instead of <a href="https://acrobat.adobe.com/uk/en/"> target="_blank"Adobe Reader</a>.</p>
<cc:DocumentViewer runat="server" Width="500" Height="500" FilePath="~/Samples/sample.pdf" PdfRenderer="PdfJs" />
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit f4b24b9

Please sign in to comment.