I'm building an app that displays a local pdf with AirPrint. When I print it from the app it doesn't fill the whole page similar to how it prints from safari. The app print is on the bottom, safari is on the top. Here is what it looks like http://i.imgur.com/0USYXf0.jpg
My code to print is straight from the sample code PrintWebView that apple provides. It has to be something in the code that apple provides because it prints the same way from their PrintWebView app.
What do I need to change to fix this?
Edit
I now believe that it is not cutting the pages short but that the pdf pages may be longer than the standard 8.5x11 page size. I think that I need to change the page size that is in the printing code. Still not sure how to get the page to scale similar to how it does in safari on the iPad.
I have figured out what the problem was. It was within PrintPageRenderer.h. All you have to do to fix it is change:
#define SIMPLE_LAYOUT 0
When you change it to 0 it scales the pages correctly for the PDF.
Related
We have some text in a UIWebView. It appears when the app is rotated, that the text looks bigger in landscape. Is anyone else seeing this, and is this the expected behavior?
yes, that will happen if the content doesn't have any viewport setting.
have a read on how to config your page on apple docs https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html and/or use css to style the page.
We have a main page in which we are having pdf links. On click of these links the page will redirect to another page which contains iframe. The pdf document will be displayed in that iframe. This scenario is working in other OS other than IOS. In IOS the iframe is showing only the pdf part of screen size. It is not providing scroll bar as well for us to scroll down. We tried changing css Overflow: scroll but did not work.
If you are using iOS 8, there is a bug with displaying PDFs in iframes that basically truncates the PDF file to display only the first page like an image would display. Apple has yet to come out with a fix for this (4+ major releases into iOS 8). This affected an application used by my salesforce in the filed on their tablets/phones so I have to create a work-around. Until Apple fixes their issue this is working for us.
Interim solution: Use Google Docs Viewer as pass through for documents
Little know feature of google docs is the ability to pass through a URL to a PDF. Works like a charm in iOS 8.
//url of your PDF hosted wherever you currently keep it
var pdfurl = 'http://www.manning.com/crowther/HH5aCSS3_SampleCh-01.pdf';
//wrap the url with the google docs gview url
pdfurl = 'http://docs.google.com/gview?url=' + pdfurl + '&embedded=true';
Maybe this workaround can help you too.
JSFiddle Demo
My upcoming mobile web project requires viewing dynamically chosen pdf files inside the webpage. I am using iFrame to display the pdf file and the file can be scrolled using two-finger scrolling. But the problems I am facing are:
The first page of the file is not displayed completely on the iPad and gets cut off along the width unlike when I view it on the desktop browsers where the first page of the pdf is always entirely displayed although zoomed out to fit in the iFrame area.
There is no visual indication for the users that the pdf document can be scrolled, i.e., there is no scroll bar on the pdf document.
The controls (page navigation, zoom etc.) for the pdf viewer (Adobe reader) don't appear on the document unlike when I see it on the desktop browsers.
What is the best way to achieve what I am trying to do? Do any of you experts know any solutions/workarounds to the problems I am facing? An entirely different approach using anything other than iFrame can also be considered.
The reason why the pdf should be inside the html page is that, the list of pdf files will be on a menu bar on the left side of the page and the user can click on any of them to view on the same page. Ideally, they will have the capability to toggle between full screen view and that view.
Any help is appreciated.
I created a tiny JavaScript module that helps you to show a PDF inline and be able to scroll it. But I also couldn't figure out a way to make it fit the total width of the parent container.
Check it out: https://github.com/williamrjribeiro/ipdf-scroll
Cheers.
I came across this Recommended way to embed PDF in HTML? while researching on the web to find an answer.
The mentioned link discusses about some options that I can use and the google document viewer works for me though don't know if there is anything (like data limit) I need to be aware of before using it on the website. Also I have no idea if it is a good solution (though the full screen mode is not available, but zoom-in/zoom-out and next/prev page buttons are there are show up in the mobile safari on the iPad) to use for an web app that will be run on the iPad.
Anyway, I will keep researching for a better solution and if i don't find any, I'll stick to the google document viewer.
The issue appears to be a bug with Safari on the IPad.
I didn't find a solution for embedding the pdf in html but I did find this:
If you return FileStreamResult from your controller action instead of a view, the pdf will open in a new tab, it's not embedded html but at least your user is not having to download files and open them manually.
I had the same problem of the pdf not being displayed completely. The only thing I found to fix this was the change the size of the div containing the pdf.
For example if the element containing the pdf is a div then I change its width to any value and the rollback to the value it had before. Changing Width or height any one works.
Sometimes I had to wait a little using a setTimeout before calling my resizable method
How does Chrome browser capture a thumbnail image of most visited URLs and show me over a blank page under Most visited??
I am interested in knowing how I would implement it using for my website or an extension.. to take take screenshot.
Lalith
I can only tell you how would I implement it. Once you would go to a site, I will add 1 to a counter if how many times you've entered it. If it's in the top 10, I would also take a screen shot of the site (chrome has a window in the class "Chrome_RenderWidgetHostHWND" which is the window that only contains the site, not the buttons and menus around it).
I can only guess it's not too far from what the guys in Google did.
If you want to write an extension that captures a screenshot of a current site then there is chrome.tabs.captureVisibleTab() method.
I think that it takes a screenshot from the last time you visited the page and saves it in the "Top Sites" SQLite database file that can be found in your profile folder.
I just recently upgraded to 436 from 419, and have found that fitExactly will no longer have any effect.
You can see an example here:
(With 419)
(With 436)
The javascript config is in the page head.
I checked the versions in between, and the latest it works with is 419.
I could adjust the width in the Javascript configuration, but then there would be a gap left on the side of the dropcap I'm using it on, and the fact that I'm integrating it with a Wordpress theme that automatically applies sifr (other than the one in the example), meaning that each can't be adjusted by changing the width or font size.
I would much prefer to use 436, especially due to there being less page shifting, so, is there a remedy?
Thanks for your time.
If you compare the width and height of the Flash movie on both pages, you'll see that it's the same. In other words, it looks like fitExactly works fine. I wouldn't know though why Flash is clipping the rendered text.
Just to test, could you open the r436 JavaScript file, search for '419' and replace by '436', and then use the r419 Flash movie? Perhaps that provides further clues.