bugGNU TeXmacs - Bugs: bug #59611, Copy to image/PDF does not work in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #59611: Copy to image/PDF does not work in macOS

Submitter:  Basile <baudoly>
Submitted:  Thu 03 Dec 2020 01:11:29 PM UTC
   
 
Category:  MacOS port Priority:  5 - Normal
Item Group:  Error Status:  Fixed
Privacy:  Public Assigned to:  mgubi
Originator Name:  Open/Closed:  Closed
Release:  None Release:  1.99.16
Fixed Release:  None Fixed Release: 
Keywords: 

Jump to the original submission

Sat 13 Mar 2021 09:57:09 AM UTC, comment #12: 

Philippe, do you mind share the code? I wanted to run another of these coding sessions and could be interesting to look at some scheme hacking.

Also, in the LyX code we used as inspiration there were some additional tweaks for Windows. Do we know if mime types works already ok in Windows or if we have problems on that platform?

It was also suggested that we can encode some information in the PDF snippet to be able to "reimport" it and edit again in TeXMacs (as LaTeXIt seems to be able to do). What do you think?


Massimiliano Gubinelli <mgubi>
Group administrator
Fri 12 Mar 2021 10:56:00 PM UTC, comment #11: 

Good job Basile and Max!

You are right Max, the present export-selection-as-graphics function is rudimentary and fails in the case you describe. You can work around it by selecting the entire math tag (or making a new one), but you would soon find other shortcomings.

I already have a much better code for that function but it's getting quite large and I think some restructuring with better modularity is in order. That's on my TODO list.

Philippe Joyez <pjoyez>
Group Member
Fri 12 Mar 2021 06:14:51 PM UTC, comment #10: 

This is fixed now in revision 13392. However there seems to be still a bug since when selecting inside an equation the math environment is not propagated correctly and the content is rendered incorrectly in text mode. It seems somehow that the related scheme code in the scheme function 'export-selection-as-graphics' in 'tmimage.scm' does not work properly for some reason I do not understand.


Massimiliano Gubinelli <mgubi>
Group administrator
Fri 12 Mar 2021 08:09:15 AM UTC, comment #9: 

What that we need can be found here:
https://www.lyx.org/trac/browser/lyxsvn/lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp?rev=24894

See the implementation of the QMacPasteboardMimeGraphics class that converts between the (pdf_mime_type = "application/pdf") mime type and Apple's "com.adobe.pdf" universal type identifier.

We need to write such a class and instantiate it once (see line 344 of this file) in a mac-only section of the source code. Once the class is instantiated, it registers itself automatically and gets called automatically when the corresponding conversion is needed.

Basile <baudoly>
Thu 11 Mar 2021 02:35:08 PM UTC, comment #8: 

I did some further investigation using Clipboard\ Viewer.app (it is an app that shows the available data types in the current clipboard). My understanding is as follows. TeXmacs correctly calls Qt4 with "application/pdf" type. However, this mime type does not seem to be recognized by Qt by default (probably because Qt4 goes back to 2004?) As a result, Qt prepends "com.trolltech.anytime" to the mime type, i.e., changes it to "com.trolltech.anytime.image--pdf", which is not recognized by macOS.

Here is where to look into:

TeXmacs/src/src/Plugins/Qt/qt_gui.cpp qt_gui_rep::put_graphics_on_clipboard (url file)
 > assigns mime type « application/pdf » if URL extension is pdf

qt4/src/gui/kernel/qmime_mac.cpp
 > includes a list of default supported mime types on the mac platform, which does not include pdf

qt4/src/gui/kernel/qclipboard_mac.cpp QMacPasteboard::setMimeData(QMimeData *mime_src)
 > matches data provided by user with known mime types

To debug further, I would need to be able to run the Qt library in debug mode, but that seems a little daunting to me.

As a work-around, we could add a "Save selection as…" menu in addition to the existing "Copy/Paste to…" menus.

Basile <baudoly>
Sat 06 Mar 2021 06:55:12 PM UTC, comment #7: 

I have no idea why the texmacs places on the MacOs clipboard data of type com.trolltech.anytime.application--pdf. In the code, we declate a mimetype application/pdf (see qt_gui.cpp line ~ 1029). However, it's notorious that mimetypes are deficient and it's probably no wonder Apple replaced them by something else. So one needs to understand what they use instead of mimetypes and how one can implement that in Texmacs for MacOS, but I cannot help on that, sorry.

Philippe Joyez <pjoyez>
Group Member
Wed 03 Mar 2021 10:49:18 AM UTC, comment #6: 

After copying from mathematica in PDF format, two "content types" are present in the clipboard:

  • com.adobe.pdf
  • Apple PDF pasteboard type

Both content types are linked to the same PDF file containing the actual data.

These same two types (along with additional ones) are also present when copying from Preview.app as PDF.

By contrast, the only type that is present in the clipboard after copying from TeXmacs as PDF is com.trolltech.anytime.application--pdf: it seems that this type is not recognized as PDF by the OS.

Basile <baudoly>
Tue 02 Mar 2021 04:11:14 PM UTC, comment #5: 

Basile: could you show us what information Mathematica provides (and which is lacking when we paste to the clipboard)?

Philippe: any ideas on how to fix this?

Joris van der Hoeven <vdhoeven>
Group administrator
Mon 11 Jan 2021 09:40:33 PM UTC, comment #4: 

two additional observations, in macOS:

  • copying to png works normally


  • the clipboard content can be analyzed using the application ClipboardViewer.app (available from Apple). The result after attempting to copy to PDF from TeXmacs is shown in the attached image. There are far fewer types available that after a typical copy operation on a PDF document outside of TeXmacs — in particular, "Apple PDF pasteboard type" is missing.



Basile <baudoly>
Thu 10 Dec 2020 12:13:33 PM UTC, comment #3: 

Sure, in macOS you can 'copy to PDF' from Wolfram Mathematica and paste into Preview.app, it works. Apologies for messing up in my previous reply.

Basile <baudoly>
Thu 10 Dec 2020 12:11:40 PM UTC, comment #2: 


comment #1:

> Do you know of a situation where a macOS application B receives pdf data that was put on the Clipboard by an application A (not TeXmacs)?
>
> Maybe it is supposed to work in macOS or windows, but in linux with mate desktop none of the applications I use can do that,  AFAICT. If it is indeed known to work with some application B, we should try pasting texmacs-generated pdf in that app see if it works or not.

> If there are no known situations where such copy-pasting is supposed to work, that option should simply be removed.
>
>

Basile <baudoly>
Thu 10 Dec 2020 11:01:12 AM UTC, comment #1: 

Do you know of a situation where a macOS application B receives pdf data that was put on the Clipboard by an application A (not TeXmacs)?

Maybe it is supposed to work in macOS or windows, but in linux with mate desktop none of the applications I use can do that,  AFAICT. If it is indeed known to work with some application B, we should try pasting texmacs-generated pdf in that app see if it works or not.
 
If there are no known situations where such copy-pasting is supposed to work, that option should simply be removed.


Philippe Joyez <pjoyez>
Group Member
Thu 03 Dec 2020 01:11:29 PM UTC, original submission:  

With the default image format set to PDF in Preferences > Convert > Image > TeXmacs->Image, if I select <math|a+b>, choose Edit > Copy to… > Image and then try to paste in Preview.app or Inkscape.app, then nothing happens: it looks like the clipboard is empty.

Not sure if the problem is limited to macOS.

Basile <baudoly>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mgubi (Posted a comment)
  • -email is unavailable- added by vdhoeven (Posted a comment)
  • -email is unavailable- added by pjoyez (Posted a comment)
  • -email is unavailable- added by baudoly (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-12 mgubi StatusNeed Info Fixed
        Assigned topjoyez mgubi
        Open/ClosedOpen Closed
    2021-03-02 vdhoeven StatusNone Need Info
        Assigned toNone pjoyez
    2021-01-11 baudoly Attached File- Added ClipboardAterCopyToPDF.png, #50702

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code