sayanee / angularjs-pdf

:page_facing_up: An AngularJS directive <ng-pdf> to display PDF files with PDFJS
http://sayan.ee/angularjs-pdf/
MIT License
494 stars 248 forks source link

Unable to load PDF file larger than 128K on iOS 10.2 #170

Closed jyxzfw closed 7 years ago

jyxzfw commented 7 years ago

Hi, I am trying to use angular-pdf on my ionic APP to display pdf file. I set the parameters $scope.pdfUrl to "http://xxx.xxx.xxx.xxx:xx/FileStoreService/DownPDF.ashx?fileNumber=xxxxxxxx". And it worked very well on iOS 8.2, until I upgraded IOS to 10.2. I find that when PDF is less than 128K, it works properly.And no errors in the logs too.Why? Thanks for every help

dennybiasiolli commented 7 years ago

Hi @jyxzfw , thanks for the issue! Are you sure you don't have any kind of restrictions on your app, eventually introduced on IOS 10?

jyxzfw commented 7 years ago

Hi @dennybiasiolli , thank you for your prompt reply! Restrictions on my app? No. I don't even know where to set restrictions. In my Xcode? I'll describe my problem in detail again: At last year, I used angularjs-pdf on iOS 8.2, and it works very well. All my PDF files on the file server, so I took $scope.pdfUrl to "http://xxx.xxx.xxx.xxx:xx/FileStoreService/DownPDF.ashx?fileNumber=xxxxxxxx". Recently, I upgraded my phone to iOS 10.2, and then it didn't work. I checked the console and found It can only load up to 131072 bytes of data. This means that only PDF less than 128KB can be loaded.
This is the progress of the log: 2017-01-17 15:04:19.756391 移动OA[17087:4488448] {"loaded":3511,"total":272348} 2017-01-17 15:04:19.802841 移动OA[17087:4488448] {"loaded":65536,"total":272348} 2017-01-17 15:04:19.820034 移动OA[17087:4488448] {"loaded":65536,"total":272348} 2017-01-17 15:04:19.820183 移动OA[17087:4488448] {"loaded":131072,"total":272348} See, it should have loaded into the 272348, but it only loaded 131072. And in the console,there is no other log. When the second time I open the PDF, it prompts me an exception: 2017-01-17 15:05:01.591878 移动OA[17087:4488448] UnexpectedResponseException: Unexpected server response (206) while retrieving PDF "http://xxx.xxx.xxx.xxx:xx/FileStoreService/DownPDF.ashx?fileNumber=xxxxxxxx". I have been suffering by this problem for several days. Thanks again for your help

dennybiasiolli commented 7 years ago

According to this issue, it seems a problem with an older version of pdf.js, resolved by this PR What version of pdf.js do you use? If you try to update your pdf.js, does the error remains?

jyxzfw commented 7 years ago

Yes, it is also so. I used the latest version(v 1.5.0), and had built a test ionic project. log: 2017-01-18 10:37:44.102043 newTestAngularjsPDF[17300:4589611] {"loaded":2211,"total":272348} 2017-01-18 10:37:44.156635 newTestAngularjsPDF[17300:4589611] {"loaded":54211,"total":272348} 2017-01-18 10:37:44.175461 newTestAngularjsPDF[17300:4589611] {"loaded":65536,"total":272348} 2017-01-18 10:37:44.206529 newTestAngularjsPDF[17300:4589611] {"loaded":65536,"total":272348} 2017-01-18 10:37:44.206900 newTestAngularjsPDF[17300:4589611] {"loaded":131072,"total":272348} It also loaded only 131072 bytes. But I found that the example you provided were good. I set $scope.pdfUrl="http://xxx.xxx.xxx.xxx:xx/FileStoreService/DownPDF.ashx?fileNumber=xxxxxxxx", then open with Safari. It works very well! So I guess angularjs-pdf doesn't support the latest IOS.

dennybiasiolli commented 7 years ago

Not only latest version of angarjs-pdf but pdfjs itself. What version of pdfjs or pdfjs-dist are you using? Latest is 1.6.463, please try to install this version with npm i pdfjs-dist or bower install pdfjs-dist

On Wed, Jan 18, 2017, 04:22 jyxzfw notifications@github.com wrote:

Yes, it is also so. I used the latest version(v 1.5.0), and had built a test ionic project. log: 2017-01-18 10:37:44.102043 newTestAngularjsPDF[17300:4589611] {"loaded":2211,"total":272348} 2017-01-18 10:37:44.156635 newTestAngularjsPDF[17300:4589611] {"loaded":54211,"total":272348} 2017-01-18 10:37:44.175461 newTestAngularjsPDF[17300:4589611] {"loaded":65536,"total":272348} 2017-01-18 10:37:44.206529 newTestAngularjsPDF[17300:4589611] {"loaded":65536,"total":272348} 2017-01-18 10:37:44.206900 newTestAngularjsPDF[17300:4589611] {"loaded":131072,"total":272348} It also loaded only 131072 bytes. But I found that the example you provided were good. I set $scope.pdfUrl=" http://xxx.xxx.xxx.xxx:xx/FileStoreService/DownPDF.ashx?fileNumber=xxxxxxxx", then open with Safari. It works very well! So I guess angularjs-pdf doesn't support the latest IOS.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/sayanee/angularjs-pdf/issues/170#issuecomment-273372377, or mute the thread https://github.com/notifications/unsubscribe-auth/ALHBtweVKT5tqvWk-5adXAM1X93RntTcks5rTYVqgaJpZM4LkUhU .

jyxzfw commented 7 years ago

I did what you said. I have tried to install this version with npm i pdfjs-dist. pdfjs-dist@1.6.463 node_modules/pdfjs-dist └── node-ensure@0.0.0 But unfortunately, it is still so. : (

dennybiasiolli commented 7 years ago

Hi @jyxzfw, Can you provide us an example project so we can inspect more? Thanks!