Embed PDF from C Drive

Hi All,

I have been trying to implement
Sami’s example code
which embeds a PDF.

However after i execute the code there is only a blank window. I am passing in the path to the pdf as a String. I have also tried to pass in the full filepath to the setSource method escaping the windows backslashes and tried with forward slashes.

My code is as follows:

EmbedPDF(String fullPathToFile){
		Window sub = new Window();
		Embedded em = new Embedded();
		
		try{
			em.setSource(new ExternalResource(fullPathToFile));
		}catch(Exception e){
			e.printStackTrace();
		}
		em.setType(Embedded.TYPE_BROWSER);
		em.setSizeFull();
		em.setImmediate(true);
		em.setMimeType("application/pdf");
		
		sub.addComponent(em);
		 
		MyApplication.getProject().getMainWindow().addWindow(sub);
	}

Any pointers to what i am doing wrong?

Thanks

S.

Hello Sierra Bravo,

I had the same problem once. After many researchs i found that its quite IMPOSSIBLE to do it. What i found are some hints on how to embed it inside HTML !!!

ive decided not to embed the PDF but rather to promt the user to save the file.

The following post is very useful:

http://vaadin.com/forum/-/message_boards/message/308689

Thanks

Santiago