Closed rubyFeedback closed 1 year ago
I found test code at test/hexapdf/type/test_image.rb but I am not sure which part of that could be used to store an image into a .pdf and then save the .pdf.
The simplest case would be
require 'hexapdf'
doc = HexaPDF::Document.new
doc.pages.add.canvas.
image(path_to_file, at: [100, 100], width: 197, height: 91)
doc.write('out.pdf')
This would add the given image at (100, 100) with the specified width and height (leave one of them out to retain the aspect ratio).
The graphics primitives example at https://hexapdf.gettalong.org/examples/graphics.html also shows image embedding.
What do you mean by "adorning a header with an image would also be nice." ?
Yeah, I can add an example similar to the arcs one.
Done - will be visible with the new release.
Hey there and servas gettalong,
Would it be possible to add a simple example to showcase how to embed an image?
The simplest use case I have would be like a foto or some other image, but adorning a header with an image would also be nice.
I had a look at https://hexapdf.gettalong.org/examples/index.html but I was unable to find an image example specifically (that is, to embed an image there). I grepped in examples/ for "Image" but could not find it; I only saw it on the rdoc documentation or so. Would be nice if there is an example too if you ever have some time on some upcoming weekend. Does not have to be too advanced either.
In prawn, looking at my local (outdated) knowledge base, I can do this:
Not sure whether that could work for hexapdf.