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 !
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=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.
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).
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.
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
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 ?