how to get a high resolution picture from the clipboard?

hi to all,
I’m trying to get a pdf that is in the clipboard into a picture to display in my app
I use rawdata(“com.adobe.pdf”) to get the pdf part of what’s inside the clipboard
then transform it to a memoryblock
then use picture.fromdata to get a picture
but that picture is 72dpi !!!
is there a way to have a better dpi from that pdf in the clipboard ?
thanks.

PS : ( for Christian… ) please native xojo code without any plugin !

Mac? Win?

We have NSPasteboardMBS
http://monkeybreadsoftware.net/class-nspasteboardmbs.shtml

so you can have the image data, an NSImage for it or get the PDF data.

:stuck_out_tongue:

He wants a plugin free solution

What happens if you draw it into a picture that has 2x the height & width but then show that in the same space ?
PDF’s are fundamentally vector based so depending on when the image is converted to a raster (bitmap) that might give you a higher res image
I’m just not sure when that is off the top of my head

[quote=256957:@Christian Schmitz]Mac? Win?

We have NSPasteboardMBS …[/quote]

… before the April 1 ends.

Cool newspaper.

Jean can still take my idea and use declares…
Others can simply use plugin.

[quote=256955:@Jean-Yves Pochez]I’m trying to get a pdf that is in the clipboard into a picture to display in my app
I use rawdata(“com.adobe.pdf”) to get the pdf part of what’s inside the clipboard
then transform it to a memoryblock[/quote]

First thing I would look at is what exactly you are getting. If it is PDF it is very recognizable by the endless PostScript jumbo mumbo. Then on Mac you can feed that into a Canvas. On windows there are utilities to turn PDF into picture.

If it is a picture, it probably is just the same resolution as the display.

would like it to work on both …

PDF is not a ‘picture’, it is a glorified vector format. Could it be possible that your code is simply displaying a 72dpi rendered preview of the actual document? (an image stored in the PDF that is a 72 dpi preview of the document).

picture.fromdata does not support PDF files…

Exactly what I suspect. Since Jean-Yves did not follow up that will remain an hypothesis.

PDF files can contain image data. They are not always vector, nor do the default to vector. However, the vector format is in general much more compact.

If one has Adobe Illustrator, the vector and image components of many (but not all) pdf files can be observed, and the vector components manipulated. However, the image portion must be transferred to Adobe Photoshop for manipulation.

PDF’s can contain a LOT of types including movies & audio

You are absolutely correct. I did not mean to imply that pdfs only contained image and vector data. Thanks.
I look forward to seeing the Xojo export of pdfs.

[quote=256983:@Robert Birge]You are absolutely correct. I did not mean to imply that pdfs only contained image and vector data.
[/quote]
Wasnt trying to correct you - more adding that PDF can contain a lot of other types as well

I look forward to owning a unicorn :stuck_out_tongue:

You can’t own a unicorn. You can only give them a safe place to stay. I learned that from Harry Potter. However, he uses C++ so what does he know.

I would rather have a Hoonicorn

You’re going to need a whole bunch of declares if you don’t want a plugin.

While the Retina Kit doesn’t have any specific code for the clipboard, it could be arranged. Otherwise if you can use the macOSLib framework and create a NSImage from the NSPasteboard and then draw the NSImage into any image size that you like.

You’d have to create a large pixel image to compensate for the DPI. So if you want 500 x 500 at 360 DPI, you’d use 500 * 6 x 500 * 6.

strange I answered yesterday and the forum destroyed my answer ???
anyway,
I cannot make a new picture because I dont know the size of the pdf I try to tranform
I use this method :

[code]Function ToPicture(extends aString as String) As Picture
’ transforme une chaine issue du Clipboard ou d’une Database en image prete tre affiche

dim mb as MemoryBlock
dim res as Picture

mb = new MemoryBlock( aString.LenB)
mb.StringValue(0,aString.LenB) = aString

//res = new Picture (???,???,32)

Return Picture.FromData( mb)

End Function
[/code]
and so I cannot force any size of the picture ? nor can I set the H and V resolution afterwards.
the pdf I tried to display is 1.6Mb and the resulting picture is 72dpi and 83Kb !!!
the FromData method seems to be forgetting some datas …
it’s already awfull on my non retina macbook, I imagine what it would on a retina mac …

for now the method is : I have a pdf that I open with preview to select some parts of it and copy-paste to my application
preview issues a pdf and a tiff image in the clipboard when I do “copy”
the tiff image is 72dpi, the pdf is “good”
I extract only the pdf string, then feed it in the method of my previous post, and get a picture … of 72dpi exactly the same as the tiff image of the clipboard althought I filtered it !
is it possible that the pdf contains also the low resolution image, and that FromData fetches that image of the pdf ?

Possibly.
You can open a PDF from a folderitem as a picture and what you get is a 72dpi low res image of the result.

What you are doing is a screen copy. Preview will give you 72 dpi. You are dealing with a picture, not the PDF POstSCript source.

Norman suggestion is quite valid. Make the picture twice as big, and it will be 144dpi in the end.

For a single page PDF, instead of copying you can load it into a canvas and use Drawinto to get that to a picture.

Otherwise, you want to look at utilities that turn a PDF into a picture.

I will mention DynaPDF for others reading this thread later as a valid solution as well.