Best vector image format for Mac

It would appear to be a Safari / HTMLViewer issue. If I open my test file in Chrome it is able to copy the image correctly and paste into Pages.

Format: image/svg+xml

You could “inject” such content into the clipboard and people could paste such circle (or any vector image) this way.

The example above could be reproduced for 100s of duplicates with different data. Users can select a series of variables and have them output to a single (HTML) file, each with its own graph.

To do what you suggest I would have to only allow the user to copy and paste one at a time. I would also have to get rid of the context menu on the HTMLViewer and then create my own. Which is possible, I know, but I’d also have to detect the selection and act accordingly. Seems quite a lot of work for something that should just work.

Well, I don’t know what to say except to point out that macOS and iOS/iPadOS all have PDF literally baked into the core graphics routines. Anything that can be drawn to the screen can be transparently redirected into a PDF data store. And the OS supports directly loading PDFs into representations that preserve all the vector data, including embedded fonts, that you can draw to the screen or printer with zero loss of fidelity.

In fact, the early OS X’s graphics layer used to be called Display PDF due to it replacing Next’s Display Postscript graphics subsystem. It’s literally based on the PDF imaging model.

There is no such deep, rich support for SVG.

You might be right that there is no official guideline saying “use PDF on the clipboard”. But that’s the de facto standard: a huge majority of applications are going to support it due to the excellent tools Apple provides for the task. Just because you don’t approve, for reasons that are impossible to divine from your comments, or wish it to be different, does not change reality. On the Mac, PDF is the vector interchange standard.

2 Likes

Giving the user the ability to selectively copy is going to cause a lot of problems, because they might find some way to only select 99% of the graph and copy it. I would suggest letting them copy the upper text as per normal but let them press a Copy button for the graph. You’d also want to disallow them from selecting the graph to prevent the partial copy issue.

From the Copy button, you could run Xojo code that actually does the work of placing the data on the clipboard.

If you are on the Mac, I’m virtually certain that 100% of browsers will support an embedded PDF image if you want to go that direction. I am less certain whether you’ll be able to copy it, which will make the Copy button an attractive alternative.

To make your PDF data directly from Xojo, you’ll want to work with a plugin, or get your hands dirty with declares into Core Graphics. This approach lets you reuse any Xojo Graphics code to create the PDF and may be useful in other contexts as well. The macOSLib project can really help here.

I am happy to switch if I knew it would work. However, I don’t want to spend significant time altering everything and then find out it isn’t any better. I suppose I need to find a good way of converting HTML / SVG into vector based PDF. Printing to PDF doesn’t achieve that so I can’t do that.

How do you do that ?

I always be able to get vector in pdf with REAL/Real/Xojo until recently when I get bitmaps (but I may be wrong that day, I never investigate why I get bitmap).

I have my HTML and SVG in Safari and select print from the file menu. On the print dialog there’s a PDF popup menu and you can choose Save As PDF. It will render anything that can be printed as a PDF file. You don’t get any control over the process and the result is a perfect reproduction, but is pretty useless as a document structure.

I was thinking to print the data inside a Xojo application
 Sorry.

No problems. I’ve been testing conversion using an online and PDF doesn’t seem to offer anything useful in terms of coping and pasting. If fact it doesn’t seem to offer anything paste-able.

1 Like

Yeah that confirms my suspicion that you might not be able to copy an embedded PDF out of a web page. You could manually place it on the clipboard, though, via Xojo code.

I’ve built a mechanism around copying the graphs from my SVG implementation into the clipboard as raw SVG images. The problem is Pages does not see it as a valid source to paste, so bang goes that idea.

If it was PDF data, I promise you it would work. :grin: There might be a tool you could use to make that conversion. Let me see what I can find.




You can use Inkscape, a free vector illustration program, to do the conversion in command line mode:

https://blog.jstassen.com/2021/04/batch-conversion-of-svg-to-pdf-updated/

My advice would be to do a proof-of-concept with some generic PDF data first before building the rendering pipeline for your graphics.

By the way - I found a bug report for Firefox from a few years ago where the problem was the inability to copy and paste a SVG from Firefox to Pages. The bug was an obscure clipboard issue, but I noticed that Firefox was rendering the SVG down to a TIFF file before placing it on the clipboard.

In thinking through this I realized that SVG is not a self-contained file format: it can contain references to URLs, for example, that contain resources like fonts necessary for rendering. A lot of programs aren’t going to go to the bother of supporting this kind of complex resource handling. PDFs are (or at least can be, and almost always are) completely self-contained.

TIFF files are flat files of pixel data (no vector) and very widely supported, which is probably why Firefox chose it. If you want to preserve the vector nature of your data, PDF is the best self-contained way to go.

Here’s a cute little bit of code that allows you to select a file, which it loads into a string and places on the clipboard as PDF data:

dim f as FolderItem

f=getopenfolderitem("")

dim b as BinaryStream

b=BinaryStream.Open(f)

dim s as string

s=b.read(b.Length)

b.close

dim c as clipboard

c=new Clipboard

c.RawData("com.adobe.pdf")=s

c.close

Run it and select a PDF file, and then paste it into Pages. Voila!

Thanks for that. I does prove that a PDF based image can be copied to the clipboard and pasted into Pages. However, everything in the PDF end up in a single image pasted into the document. My design is for tables and other output to be along side of graphs. I’ll look at embedding PDF images within a larger HTML framework.

Flying off-topic, but I miss the days of SunOS 4.x where the display manager used Display PDF on top of X11 :slight_smile: .

So you’re contemplating copying a block of stuff out of a browser, some of which will be text (the stuff above your graph) and the graph itself, and after pasting have that end up as individual elements in the target application?

Actually, SunOS 4.0 predates PDF. It appears to have used Display Postscript, which is what Next used. :slight_smile:

That would be ideal. Or the user should be able to copy and paste a single graph.

If I was using HTML and png, or any other bitmap image format, I would be fine. Safari creates a webarchive and puts it on the clipboard. Pages can paste that into a document.

Obviously, I want a vector format and thus this question.