-
29 Nov 2011 6:31 AM #1
Answered: Add pdf to a panel
Answered: Add pdf to a panel
Hey,
Im trying to add a pdf file to a panel. My code looks like this now:
So, in Chrome everything works fine, in safari the files are downloaded to the pc and in the ipad simulator it wont render.Code:subjectpanel = new Ext.Panel({ floating: true, scroll: 'both', modal: true, centered: true, width: '90%', height: '90%', html: '<iframe width="100%" height="100%" src="data/pdf/subject3.1.pdf" ></iframe>' });
I have tried a solution I found on the forum, this involved google docs. This is not the best option because the app is going to get used offline alot.
Thanks in advance.
-
Best Answer Posted by mitchellsimoens
-
29 Nov 2011 1:13 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
It's up to the mobile device on how it handles PDF.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Nov 2011 12:10 AM #3
So there is no standarized code to handle a pdf in Sencha?
-
30 Nov 2011 7:17 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Dec 2011 1:03 AM #5
Of course, that's right, but the iPhone Browser is able to display PDFs for example if you call window.open(PDF)!
Everything works fine, pinch/zoom, rendering, ... But how to get this work inside a panel?
There is a workaround to use an iFrame, but then you have trouble with scrolling, zooming, etc. Here's a working example for an iFrame
I tried to use this code inside a panel, but it doesn't work:
I would appreciate your help!Code:var panel = new Ext.Panel({ id: 'PDFPanel', layout: 'fit', scroll: 'both', html: '<div id="scroller" style="height: 500px; width: 100%; overflow: auto;"><iframe height="100%" id="iframe" scrolling="no" width="100%" id="iframe" src="URL" /></div>', listeners: { beforeshow: function() { setTimeout(function () { var startY = 0; var startX = 0; var b = document.body; alert('Body added!'); b.addEventListener('touchstart', function (event) { parent.window.scrollTo(0, 1); startY = event.targetTouches[0].pageY; startX = event.targetTouches[0].pageX; }); b.addEventListener('touchmove', function (event) { event.preventDefault(); var posy = event.targetTouches[0].pageY; var h = parent.document.getElementById("scroller"); var sty = h.scrollTop; var posx = event.targetTouches[0].pageX; var stx = h.scrollLeft; h.scrollTop = sty - (posy - startY); h.scrollLeft = stx - (posx - startX); startY = posy; startX = posx; }); }, 1000); } } });
-
7 Dec 2011 1:12 AM #6
pdf on mobile devices
pdf on mobile devices
Hey,
I fixed it with two solutions, one for chrome and 1 for safari. For chrome i have an iframe, with the pdf inside it. For safari I have a div with the pdf as an image.
this is my code:
Code:var pdfurl = []; if (App.browser == "Safari") { console.log('Safari') pdfurl = ['<div class="pdf"><img src="data/pdf/' + target.id + '.pdf" width="100%" /></div>']; }else if (App.browser == "Chrome"){ console.log('Chrome'); pdfurl = ['<iframe src="data/pdf/' + target.id + '.pdf" width="100%" height="100%"></iframe>']; }
-
7 Dec 2011 1:54 AM #7
Thanks for your reply!
But pinch to zoom doesn't work, right?
-
16 Jan 2012 7:53 PM #8
img src .pdf displays only first page
img src .pdf displays only first page
Hi everyone,
I have tried the solution of putting the pdf inside an image tag but on my ipad it only displays the first page of the pdf document.
Do I need to add something in order to scroll through the whole document.
Thanks
-
17 Jan 2012 2:34 AM #9
You cant scroll. Due to this problem I have implemented the Google Docs PDF viewer. This is a very nice viewer, does all the things the pc version can do.
Hope this helps
-
17 Jan 2012 8:19 PM #10
My problem is that my application will be used offline and the pdf files will be stored locally.


Reply With Quote