Show PDF in a Vaadin View - pdf

I want to show a PDF in a Vaadin view. I create a BrowserFrame and I pass the StreamResource of the PDF:
StreamResource streamResource = new StreamResource(
getPresenter().createPdfStreamSource(), report.getName() + ".pdf");
BrowserFrame pdf = new BrowserFrame(null, streamResource);
pdf.setSizeFull();
content.addComponent(pdf);
This code creates an iframe with the following source:
http://localhost:8080/my-app/vaadinServlet/APP/connector/0/134/source/mypdf.pdf
If I point the browser to this URL, it shows the PDF properly. However in my application the PDF view doesn't show. What am I doing wrong?
I am testing this in Google Chrome.
Edit: I downloaded the plugin PDF Viewer based on PDF.js and my app works fine. Does the Chrome PDF reader plugin need special configuration?

An iframe is probably not the best option to render a PDF, especially on mobile browsers. Check the WT PDF Viewer add-on which is based on pdf.js for a more compatible solution.

Related

Android camera, take picture(s) and save as multipage PDF, then upload to server via <input type="file" />

I have a webform with and want to open it on smartphone - than take pictures of some documents which need to be merged in one PDF, and on the end this file need to be uploaded to server.
My solution is to use Google Drive to upload PDF (scan) to GDrive and then somehow download this file from gdrive to server via some sort of widget (any links appreciate) installed on website.
Maybe someone have a better idea?
I know its late but my answer might help others. I also face the same challenge and implemented a custom solution based on Javascript and Since you are using web form so this solution will perfectly fits on your need.
You have to use JSPdf javascript library, JSPdf provide you pdf object in your browser and you can upload it download it and there are many other thing to play with.
First you have to initialize JSPdf object as per your requirement. I am creating PDF with page size width:500px and height 500px.
pdf = new jsPDF("l", "pt", [500,500]);
Simply when you will take picture from camera you will have each picture in form of base64, that base64 format you have to insert in JSPdf object
pdf.addImage(imgData, 'JPEG', 0, 0);
you can repeat the above code to add pictures from camera as much as you want, at the back-end these images are compiling and creating pdf document where each page have each images in sequence.
Once you are done, you can get PDF object in form of base64 object using below code that you can upload to any server.
pdf.output('datauristring')
above is only pdf part, you can find complete working example including camera part here Javascript Component to Scan Document

Display pdf in iframe using ssl/https based

I want to Showing PDF inside iframe for user preview before download the file or print,
i use byte array convert my report file to pdf then showing it.
everything was perfect until i need something in ssl/https.
because of that i must change my application to ssl/https can some one show me how can i show pdf in this condition.
thanks for listening and reading my prob.
here my code
reportDocument.Load(reportPath);
reportDocument.SetDataSource(dataSet);
_contentBytes = StreamToBytes(reportDocument.ExportToStream(ExportFormatType.PortableDocFormat));
.....
//setting header
.....
//then flush
stream.Flush();
i found the solution in
PDF conversion suddenly fails if reading stylesheet from SSL
the problem is the pdf reader inside my chrome browser.
so i updating my chrome reader in store search pdf viewer..
just it..

XPage - Open scans in browser

I need to display uploaded scans (JPG, PNG, TIFF, PDF, etc.) in the browser's window instead downloading them to a local pc and using external apps like Acrobat Reader.
I made some research in the web on that issue but wasn't really successful.
Does anyone have hints, code snippets, how to achieve that ?
EDIT :
Since I am not looking for a solution which supports viewing scans in a typical browser like Chrome, FireFox, etc. but supports viewing scans in an XPage view within Notes I need to ask my question again.
What is the best (recommended) way to view different types of scans, uploaded as PDF, JPG, TIFF, PNG, etc., in Notes within an XPage view ?
Take a look here, XPages: Embed PDF and possibly Office files
Here is some code that I have in an app for PDF's.
I tried using Bumpbox, and pdf.js and while I could get them working, iframes seemed to work best for me with using normal Domino attachment urls in xpages
I am not sure if this solution is right or not, but it works well for an app I have that only has PDFs. It does work on mobile too, at least on iOS.
<iframe
src="#{javascript:
var url = 'https://app.nsf/';
var doc = sessionScope.docID;
var atname = #RightBack(sessionScope.aname,'Body');
var end = '/$file'+atname;
return url+doc+end}"
width="800" height="1000">
</iframe>
If you are looking at using different file types you need to use a renderer, give it the attachment URL, and then display what the renderer returns with. I haven't looked at this in a while so things might have changed. Look for a lightbox clone that can display pdf. I think Orangebox was one, bumpbox looks to not be updated but I was able to get that working for me.
This method will display everything inline. I would love to see some type of renderer like pdf.js for xpages.

how to use pdf.js or viewerJS to display pdf in browser

i need a tuto about using pdf.js or viewejs to view pdf via browser. I found viewerjs.org but it doesn't help.
Any help thx in advance.
Try out pdf.js as it is very simple. Download the latest version here.
To show the pdf files traverse to web/viewer.html and it should load its default pdf.
As to the question about how to show your pdf's use: viewer.html?file=relative/path/to/your/pdf.
Say for example inside the web folder(the one in which viewer.html is there) of your pdf.js you create a directory say named pdfFiles and in it you add a pdf named say mypdf.pdf in it then to display it use: viewer.html?file=pdfFiles/mypdf.pdf and it will display it.
Almost all browsers are supported. Look here to know more about which all browsers are currently being supported.

Display PDF in browser (except pdf.js and Adobe Reader plugin)

I try to find solutions for display PDF in browser.
A couple of restrictions:
PDF should be downloaded to client as-is. Conversion like PDF -> HTML on server is not allowed.
Installation of additional software, like browser plugins is not allowed. But it is assumed, that user has widespread plugins, like Flash, Adobe reader ...
I know about next solutions:
Adobe Reader plugin.
PDF.js
FlexPaper (but not sure if it render pdf on on client side or convert PDF to series of Flash objects...)
What you can advice else?
== UPDATE
More possible solutions are:
Silverlight component
JavaApplet component