| View previous topic :: View next topic |
| Author |
Message |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Wed Mar 10, 2010 7:48 am Post subject: [JS] Possible to generate pdf with text and images? |
|
|
Hello everyone.
JSPDF does not work correctly in internet explorer. Basically it creates a pdf in a buffer and includes as a data uri. While this is good it does not work very well in modern browsers. So does anyone know a good way of doing this.
If you are going to tell me another api it has to be open source and therefor also free.
edit:
| Code: | | window.open('data:application/pdf;base64,'+Base64.encode(buffer),'_blank'); |
This code gives me an error that you need to intall an application. _________________
Intel over amd yes.
Last edited by NINTENDO on Wed Mar 10, 2010 10:21 am; edited 2 times in total |
|
| Back to top |
|
 |
shhac Expert Cheater
Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Wed Mar 10, 2010 8:58 am Post subject: |
|
|
the app it probably wants you to install would be called adobe reader, to view the .pdf in your browser or because it doesn't know how to handle the data:, which really looks like something that should've been sent in the page header anyway.
Also, the conversion probably needs to be done server-side, not client-side, in which case there are much faster options available than JS. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
|
| Back to top |
|
 |
shhac Expert Cheater
Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Wed Mar 10, 2010 1:53 pm Post subject: |
|
|
If it works in chrome but not others then try debugging for them:
1. See if using <object> works
| Code: | var elm = document.createElement('object');
elm.type = 'application/pdf';
elm.data = 'data:application/pdf;base64,'+Base64.encode(buffer);
document.body.appendChild(elm); |
2. Check that Base64 is working on its own, i.e. | Code: | alert(Base64.encode(buffer));
or
console.log(Base64.encode(buffer)); |
3. Not sure what happens when trying to access image data via JavaScript when using FireFox/IE/Opera, you might not have permission by default. Hence try just text/just images see what happens there.
4. (well this could be 1, depending) Make sure that everything is properly defined, e.g. you didn't say how buffer is set, or how Base64 was defined (though I'm guessing you're using webtoolkit.base64.js). |
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Thu Mar 11, 2010 9:41 pm Post subject: |
|
|
| PDF generation would best be done on the server-side using PHP. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Apr 15, 2010 2:39 am Post subject: |
|
|
| rapion124 wrote: | | PDF generation would best be done on the server-side using PHP. |
I don't have no server in my case. _________________
Intel over amd yes. |
|
| Back to top |
|
 |
|