Need help in adding image file to pdf which I created

You must Login before you can answer or comment on any questions.

Hi All,

I am doing development in iPhone , using latest titanium sdk 2.1.1.

I am using jspdf to generate pdf file , but the problem is I can only make pdf which include only text content , and unable to include images in PDF , Please help me to do this , or please provide me solution of how to make pdf using combination of text and images.

Thanks

3 Answers

Accepted Answer

Hi

I have a working prototype and hope to have it ready to share within 24 hours. I am having to rewrite portions of the original library to allow images to work.

I am using the latest version of the library so everything is as up to date as possible and the library does seem reasonably feature complete.

Fingers crossed

— answered 6 months ago by Malcolm Hollingsworth
answer permalink
9 Comments
  • Thats great News :) Thanks , I know you can do it :)))

    — commented 6 months ago by Moiz Chhatriwala

  • Looking forward to seeing it Malcolm.

    — commented 6 months ago by Anthony Decena

  • Quick Update:

    The whole thing works perfectly and inserts images wherever needed using the same syntax as original jSPDF library.

    I am currently re-factoring the code in order to provide the solution as a plug-in using the jsPDF plug-in syntax. This is so as few changes (hopefully none) are required to the original library. This is to allow upgrades to the original library without breaking the Titanium image support I have built.

    In order to get this far I have already created multiple versions using a variety of techniques, the one I am using now is actually surprisingly simple.

    So whilst not currently ready it will be very shortly.

    I will be providing the code as a private beta for a limited number of people (max 10) on a first come first served basis. This is in order to focus the bug checking before making it freely available. Anyone interested send me a devmail and if you are early enough I will let you have the beta code to check.

    Yes Moiz you are first on the list and I assume Dan Williams and Anthony Decena are interested in the beta code as well.

    — commented 6 months ago by Malcolm Hollingsworth

  • Show 6 more comments

A few things here. When you have a problem with a 3rd party library, the proper way to handle issues would be to first contact the author of that library. They will more than likely be the best source to resolving your issues.

It looks like you downloaded JSPDF from a Google code repository where the latest zip was built in 2009. 2009?!?! Thats like 100 years in javascript years. I'm sure if you were to contact the author he would tell you that the Google code repo was very old, and that you could get the latest code from his GitHub Repo. Then, I'm sure he would tell you that you can see code demos on his Demo Page, on which the Image demo is in the Graphic Elements tab at the very bottom.

— answered 8 months ago by Anthony Decena
answer permalink
9 Comments
  • Thanks Anthony , but this demo does not work on images , If we need to add images to pdf we can't do with help of this demo.

    — commented 6 months ago by Moiz Chhatriwala

  • I actually haven't seen any successful images added to a Titanium app using this lib. I think its because the image adding function uses the js new Image() method. Since there is no document object in a titanium app, there is no way to add this image to the app. The library would need to be modified in order to facilitate the addition of images in the pdf.

    — commented 6 months ago by Anthony Decena

  • Is there any other way to get this done , can you suggest any alternative to do this , because I am trying to get it do from a long time.

    — commented 6 months ago by Moiz Chhatriwala

  • Show 6 more comments

See this article and referred code:

— answered 5 months ago by Fabian Schuetz
answer permalink
5 Comments
  • Hi Fabian

    For most developers using the layout system of the jsPDF library is very easy and not at all cumbersome. I am interested to know how using HTML web pages to layout elements is any easier when you still have to create web pages that have inherit layout that you could have programmatically created with the jsPDF library..

    Do you have an example of the PDF created using the code you have proposed? Does the resulting render as an image or native vector based elements?

    I see this is iOS only, do you have plans for an Android or Blackberry version?

    I am not sure if you spotted in the comments but I have a working version of the jsPDF library with full image support without any modules so it works cross platform. Let me know if you are interested in having a play.

    — commented 5 months ago by Malcolm Hollingsworth

  • Hi Malcom,

    I think HTML templating is a well-known, well-documented and wide-spread approach to layouting. For my part, I would definitely prefer creating a document with these techniques, i.e. HTML and CSS, than with some library, that might or might not turn out to suit my needs in the end.

    However it is great you got your solution to work, as of course it is platform independent and mine is not. I was actually thinking about creating an implementation of my solution for Android as well, but unfortunately my app won't run on Android. I have already posted bugs about that on jira.

    So yeah. An Android solution will most likely come, but I do not have plans for a Blackberry solution.

    Having a play? Don't really understand what you mean, but sure :)

    — commented 5 months ago by Fabian Schuetz

  • Sorry - my comments were not meant negatively, I was asking what benefits you see in html layout as opposed to programmatic. Obviously we are coming at it from two different directions so I was after your thoughts.

    The "..having a play.." was part of the there is a JS version - did you want a copy to have a playe with? I know what you said about preferring HTML layouts, but thought I would offer.

    — commented 5 months ago by Malcolm Hollingsworth

  • Show 2 more comments

Your Answer

Think you can help? Login to answer this question!