how to get a high resolution picture from the clipboard?

That is what you think. Do you know how to use Preview on OS X ? (to still get PDF data into a copy of a part of a pdf ?)

Screen copy here have a 144dpi… resolution. (both OS X and WIndows 10, <> laptops).

Some minutes after I pressed the button to send this answer, I realized why I had trouble with them !

The top answer means that I can make a copy of a pdf using Preview and the second part tells that when I make copy using Preview I get them at 144 dpi.

The first is 100% true,

the second, is I made a screen shot as meant by Michel is 100 % true too, but can be interpreted differently.

Sorry for the eventual misleading. ASk if I am not crystal clear now.

[quote=257020:@Michel Bujardet]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.
.[/quote]

no sorry - preview put the pdf copy and the tiff preview in the clipboard - I checked that.
select a pdf in preview, do copy, then file-new and you get a full resolution pdf of what you selected before

Jean-Yves,

while you have the pdf data in the clipboard, using AppleScript, you can get an idea on what really is in the Clipboard (beside teh PDF data):

return clipboard info

the line above while executed can gives you:

{{«class PDF », 1027376}, {TIFF picture, 29530}, {«class 8BPS», 97866}, {GIF picture, 13058}, {«class jp2 », 16798}, {JPEG picture, 26732}, {«class PNGf», 22665}, {«class BMP », 254678}, {«class TPIC», 45674}}

as I wrote earlier, cmd-n will create a band new window with the Clipboad contents («class PDF » data in this case). Pasting the clipboard will give different results depending on how the application deals with the PDF and/or image kinds as seen above.

But I am not sure that this will resolve your trouble.

Here’s how to do it using Core Graphics declares. I’m not as familiar with the NS pathway Sam mentioned, maybe that’s simpler, but even with CG it’s relatively easy. The code is just demonstration, Mac only, 32bit, not checking for all errors, maybe not releasing something it should. I moved the code into 2 small classes XPDFDocument and XPDFPage to make it a bit more readable. I could post all the code but the long declare lines are rough.

This is the button action that goes from clipboard to a large picture, 1300px wide and proportional height.

[code]Sub Action()

//get pdf raw data off clipboard
dim cb As new Clipboard
if not cb.RawDataAvailable(“com.adobe.pdf”) then
MsgBox “no pdf on clipboard”
return
end
dim rawData As String = cb.RawData(“com.adobe.pdf”)

//make pdfdocument from data
dim doc As new XPDFDocument(rawData)

//get first page
dim page As XPDFPage = doc.getPage(1)

//render to picture
dim pic As Picture = page.pictureAtWidth(1300)

//show
Canvas1.Backdrop = pic

End Sub[/code]

Apart from declares or plugins I don’t see how to do this (but that’s not saying much :slight_smile: )

This will also open from files and list all the pages.
http://trochoid.weebly.com/uploads/6/2/6/4/62644133/pastepdf.zip

[quote=257034:@Emile Schwarz]Jean-Yves,

while you have the pdf data in the clipboard, using AppleScript, you can get an idea on what really is in the Clipboard (beside teh PDF data):

return clipboard info

the line above while executed can gives you:

{{«class PDF », 1027376}, {TIFF picture, 29530}, {«class 8BPS», 97866}, {GIF picture, 13058}, {«class jp2 », 16798}, {JPEG picture, 26732}, {«class PNGf», 22665}, {«class BMP », 254678}, {«class TPIC», 45674}}

as I wrote earlier, cmd-n will create a band new window with the Clipboad contents («class PDF » data in this case). Pasting the clipboard will give different results depending on how the application deals with the PDF and/or image kinds as seen above.

But I am not sure that this will resolve your trouble.[/quote]

I’m using the same pdf to test my app so here is the result of my 1.6Mb pdf in the clipboard

{{«class PDF », 1631153}, {TIFF picture, 97898}, {«class 8BPS», 421756}, {«class BMP », 310854}, {«class TPIC», 231468}, {«class PNGf», 87156}, {«class jp2 », 18818}, {GIF picture, 20029}, {JPEG picture, 38631}}

when I use clipboard viewer I only get this 4 elements :

  • com.adobe.pdf (1.6Mb)
  • apple pdf pasteboard type (1.6Mb)
  • public.tiff (97kb)
  • next tiff v4.0 pasteboard type (97kb)

Good luck.

just understood : applescript gives a carbon answer, and clipboard viewer gives a cocoa answer
macoslib has the 2 versions of nspasteboard that explains this difference
so I now have to try to get other elements of the clipboard, like the BMP or the JPEG that seems heavier in size

[quote=257131:@Jean-Yves Pochez]just understood : applescript gives a carbon answer, and clipboard viewer gives a cocoa answer
macoslib has the 2 versions of nspasteboard that explains this difference
so I now have to try to get other elements of the clipboard, like the BMP or the JPEG that seems heavier in size[/quote]
Theyre no higher resolution
Just different image formats of the same data

No, you want the RawData(“com.adobe.pdf”) as that’s the actual vector pdf data which can be crisply drawn at any size.

Using Picture.FromData though is just creating a default rendering. For a custom size you need to render it yourself at that size. That’s what my Core Graphics code above does. You can find the same Core Graphics stuff in MacOSLib.

thanks, Will, your pastepdf example works fine with my clipboard image
i have to adapt it to my app but it’s ok

another question: is there a possible way to make it work under windows, does windows have the same equivalent coregraphics ?
my aim is to display database images at more than 72dpi on mac and windows.

Windows will have it’s own pdf handling framework requiring it’s own set of declares. Maybe it’s Windows.Data.Pdf, I don’t really know, I don’t do Windows.

There may be cross platform libraries that can be declared into in the same way. Or maybe a command line app run through a shell, like cpdf, free for non-commercial but I can’t tell if it renders.

Maybe GIMP or ImageMagick can be shelled out to? The only hassle free cross platform pdf renderer I know of is in mbs, am I wrong?

You can use DynaPDF Plugin for PDF handling in cross platform apps.
Mac, Windows, Linux, even Raspberry Pi.