Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse previously added images #120

Closed
wants to merge 2 commits into from

Conversation

super-triangle
Copy link

Hello, I added in support for reusing images that have already been added into the PDF, per issue #99. I tried to follow the style conventions I noticed in the plugin already, but if I've done anything you don't like, feel free to clean up or tell me how to clean it up. :)

The new functionality can be used in the way suggested by n8v:

doc.addImage(imgData, 'JPEG', 15, 40, 180, 180, 'Octonyan');
doc.addImage('Octonyan', 'JPEG', 15, 400, 180, 180);

addImage accepts an optional imageName param. When used, the image can
be referenced more than once without reembedding the image.
@chrismaximin
Copy link

+1
Thanks! Worked really well for me while adding 9 full Letter-sized pages on Google Chrome 29.0.1547.65; jsPDF was constantly crashing without that.

@MrRio
Copy link
Member

MrRio commented Feb 4, 2014

I like this. Perhaps we need to look at the syntax for the image function though.

We could turn this into key/value pairs. For example:

doc.addImage({
  name: 'xyz', // optional
  data: 'dataurihere', // optional if name provided
  x: 0,
  y: 0,
  type: 'jpeg', // optional if detected for datauri 
  width: 100,
  height: 20
});

@super-triangle
Copy link
Author

Hi there. I like that as a format. I won't have time in the near future to work on that; but I'll keep it in mind when I have freetime again someday. :)

diegocr added a commit to diegocr/jsPDF that referenced this pull request Feb 4, 2014
@diegocr diegocr closed this in e6150e8 Feb 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants