gilbertoaleces / jspdf

Automatically exported from code.google.com/p/jspdf
0 stars 0 forks source link

iOs - Generated file not viewed in adobe reader, but ok in chrome pdf reader, and all sorts of other reader #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Generate pdf in phonegap with jspdf, on iPad
2. Save to file with phonegap file api, and open it with fileopene2 plugin 
https://github.com/pwlin/cordova-plugin-file-opener2
3. Choose adobe reader as viewer application

What is the expected output? What do you see instead?
I see the file, page layout (a4 landscape or portrait) seems fine, but all is 
blank, no text is output.

What version of the product are you using? On what operating system?
I use latest jspdf trunk version of lastweek (2014/05/21)

Please provide any additional information below.
All is working good on android. It seems to me that is a file content problem 
(encoding / blob / ?). I attach the corrupted file

Original issue reported on code.google.com by olivier....@gmail.com on 28 May 2014 at 7:17

Attachments:

GoogleCodeExporter commented 8 years ago
After many other tests, the bug description is incorrect : the pdf is 
corrupted, whatever the Os.

But it opens correctly in every pdf reader, exception adobe pdf reader. How sad 
...

Original comment by olivier....@gmail.com on 28 May 2014 at 12:15

GoogleCodeExporter commented 8 years ago
The results is that there is no bug in jspdf, but the generated string can't be 
used directly in phonegap.

It has to be converted to a binary array, then written in file and opened.

example : 

...
var pdfContent = doc.output();

var buffer = new ArrayBuffer(pdfContent.length);
var array = new Uint8Array(buffer);
for (var i = 0; i < pdfContent.length; i++) {
  array[i] = pdfContent.charCodeAt(i);
}

... phonegapFileEntry.write(buffer);

The difficulty was that all readers except Adobe reader were successful in 
reading file.

Original comment by olivier....@gmail.com on 28 May 2014 at 3:15