meyer.wil Posted September 12, 2019 Share Posted September 12, 2019 I am working on a technical volume in which I need to insert formatted code to illustrate various programming issues. Some editing tools offer syntax highlighters; others permit me to insert formatted code. In Affinity Publisher, the best solution I have found is to copy the formatted code from my development tool, paste into MS Word, adjust the font as I wish, then paste into Publisher. Although this works, it is certainly tedious, and as I work through revisions, it will become unacceptable. Is there a way to define a paragraph style which will not alter character color and weight? Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 3 hours ago, meyer.wil said: Is there a way to define a paragraph style which will not alter character color and weight? Yes. But it would help to have an example of what you want to accomplish, and/or a better specification of what you do want to change. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
meyer.wil Posted September 12, 2019 Author Share Posted September 12, 2019 7 minutes ago, walt.farrell said: Yes. But it would help to have an example of what you want to accomplish, and/or a better specification of what you do want to change. Simple example: Right now, I can copy that from the development environment, and paste to Word. I can do there as I like, changing font, size, and indentation. Then copy to clipboard and paste to Publisher. But if I paste the original to Publisher, rather than to Word, I get plain text. If I paste to Notepad, or to Notepad++, I see plain text, so I assume the issue is that the clipboard data is converted within the limits of the target application. As alternatives to the normal clipboard format, I am able to get either RTF or HTML. What I would like is to be able to create a style which alters the font name, the size, and the indent level of all lines, but leave unaltered the colors, weights, and whatnot. Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 Thanks. It seems odd that you would get formatted text pasting to Word, but plain text pasting to Publisher. (It is not surprising that you get plain text pasting to Notepad or to Notepad++, as those are plain text editors and do not have the concept of italic or bold; but Publisher does, and if the formatting information is on the clipboard it should be used by Publisher.) What is the development environment you're copying from? And, I guess I'm still a bit confused. If you're planning to paste initially into Publisher, and if when you paste initially into Publisher you get plain text, where will the colors, weights, etc. come from that you don't want to disturb? Something about your intended workflow is still not making sense to me. Sorry. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
meyer.wil Posted September 12, 2019 Author Share Posted September 12, 2019 2 hours ago, walt.farrell said: Thanks. It seems odd that you would get formatted text pasting to Word, but plain text pasting to Publisher. (It is not surprising that you get plain text pasting to Notepad or to Notepad++, as those are plain text editors and do not have the concept of italic or bold; but Publisher does, and if the formatting information is on the clipboard it should be used by Publisher.) Yes, and all the more curious that the metadata pasted to Word shows formatted text, but the same clipboard data pasted to Publisher does not. And then, the formatted text in Word copied and pasted to Publisher is fine. 2 hours ago, walt.farrell said: What is the development environment you're copying from? From Delphi, using a plug-in which copies formatted to the clipboard. 2 hours ago, walt.farrell said: And, I guess I'm still a bit confused. If you're planning to paste initially into Publisher, and if when you paste initially into Publisher you get plain text, where will the colors, weights, etc. come from that you don't want to disturb? Something about your intended workflow is still not making sense to me. Sorry. It should be simple. Obviously, the clipboard content produces what I expect when pasted to Word. Or, for that matter, to PowerPoint. The intended workflow is: Copy from Delphi, Paste to Publisher. But at present, it seems that I must use Word to apply any and all formatting I need, and then paste to Publisher, and leave it alone. At a guess, the observed behavior suggests that Publisher is overlooking something in pasting from the clipboard. Quote Link to comment Share on other sites More sharing options...
Alfred Posted September 12, 2019 Share Posted September 12, 2019 2 minutes ago, meyer.wil said: At a guess, the observed behavior suggests that Publisher is overlooking something in pasting from the clipboard. It should be possible to identify that with the help of a clipboard viewer. Quote Alfred Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen) Link to comment Share on other sites More sharing options...
meyer.wil Posted September 12, 2019 Author Share Posted September 12, 2019 13 minutes ago, Alfred said: It should be possible to identify that with the help of a clipboard viewer. Can you suggest a suitable tool? Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 Thanks. 2 minutes ago, meyer.wil said: It should be simple. Obviously, the clipboard content produces what I expect when pasted to Word. Or, for that matter, to PowerPoint. The intended workflow is: Copy from Delphi, Paste to Publisher. But at present, it seems that I must use Word to apply any and all formatting I need, and then paste to Publisher, and leave it alone. My confusion, I think, came from your desire to have a paragraph style that will set the font, and size, and indent level, but leave the color, weight, etc. alone. That seemed to indicate that you're doing some of the "styling" in Word, but not all of it. But perhaps you mean that you want to use Word as a passthrough, doing none of the work there but simply getting the text, weight, and color passed along to Publisher. If you want to retain those characteristics, but override others such as font, size, and indent level then: Create a new paragraph style based on "no style". In the Character/Font section of the definition, specify the Font Family you want, and the font size you want. You can leave any value at [No Change] if you don't want it modified. In the Paragraph/Spacing section set the left-indent to the value you want (which will also set the first-line indent). Again, leave anything you don't want to change set to [No Change]. But if you figure out what clipboard aspect Publisher is missing, I suggest creating a bug report unless it's simply Delphi creating a format that Publisher doesn't understand at all. In that case it would be worth a feature request, but it wouldn't be a bug. Delphi is probably putting multiple formats into the clipboard, and it may simply be supplying the default/expected format of "plain text" and then perhaps something "Delphi Text" that Word knows about but Publisher doesn't. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
meyer.wil Posted September 12, 2019 Author Share Posted September 12, 2019 Just now, walt.farrell said: My confusion, I think, came from your desire to have a paragraph style that will set the font, and size, and indent level, but leave the color, weight, etc. alone. Mine comes from needing to use MS Word as intermediary, which I certainly do not wish to do. If/when I can learn of a viewer which will let me diagnose the issue, I can surely create a defect report, or work with the maintainer of the Delphi plug-in, to be sure who owns the issue. Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 I have just tried http://www.freeclipboardviewer.com and it looks pretty good. (I don't use Delphi, so I can't help with further direct diagnosis.) Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
meyer.wil Posted September 12, 2019 Author Share Posted September 12, 2019 Tried it. Looks good, but to no great surprise, I see that from the Delphi plug-in, I get about 3K of text in the HTML view, and from MS Word, 44K. Makes it very hard to guess what may be making the difference. As an alternative, is there any way to import either RTF or HTML to Publisher? I have not found one so far. Quote Link to comment Share on other sites More sharing options...
Move Along People Posted September 12, 2019 Share Posted September 12, 2019 - Quote Move Along people,nothing to see here Link to comment Share on other sites More sharing options...
Alfred Posted September 12, 2019 Share Posted September 12, 2019 34 minutes ago, walt.farrell said: I have just tried http://www.freeclipboardviewer.com and it looks pretty good. That looks quite reasonable. InsideClipboard has been revised more recently (2017) but that doesn’t mean it’s any better than a utility which happens to be two years older! Quote Alfred Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen) Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 6 minutes ago, Alfred said: That looks quite reasonable. InsideClipboard has been revised more recently (2017) but that doesn’t mean it’s any better than a utility which happens to be two years older! FreeClipBoardViewer came up first in a Google search, and when I downloaded it Norton Security didn't complain about it Alfred 1 Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
walt.farrell Posted September 12, 2019 Share Posted September 12, 2019 26 minutes ago, meyer.wil said: Tried it. Looks good, but to no great surprise, I see that from the Delphi plug-in, I get about 3K of text in the HTML view, and from MS Word, 44K. Makes it very hard to guess what may be making the difference. As an alternative, is there any way to import either RTF or HTML to Publisher? I have not found one so far. What formats did the clipboard viewer say were available? Just HTML and plain or UTF-8 text? I wouldn't expect Publisher to support HTML at this point. But I might expect it to support RTF text if available. In Publisher, after you have copied from Delphi, what do you see if you use Edit > Paste Special? As Haakoo said, you can drag/drop an RTF file onto a text frame, or File > Place it. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
MikeW Posted September 13, 2019 Share Posted September 13, 2019 8 hours ago, meyer.wil said: As an alternative, is there any way to import either RTF or HTML to Publisher? I have not found one so far. Did you try Paste Special? My code editor can copy as RTF and using Paste Special I have RTF as one of the paste formats and syntax colors come in. Quote Link to comment Share on other sites More sharing options...
firstdefence Posted September 13, 2019 Share Posted September 13, 2019 What about asking the Delphi plugin dev how the text is formatted when exported to clipboard, might be xml. Quote iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9 (Please refrain from licking the screen while using this forum) Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions Link to comment Share on other sites More sharing options...
MikeW Posted September 13, 2019 Share Posted September 13, 2019 16 hours ago, meyer.wil said: ...Is there a way to define a paragraph style which will not alter character color and weight? As regards this issue, define a paragraph style. I simply used the name code for the paragraph style in this example. I am using Consolas in my text editor, so after the Paste Special, I apply the paragraph style using this right-click option: This sets the code style to those paragraphs. The paragraphs look like: But at any time, I can change the code paragraph style and the color coding is retained while the font changes. Here I'm simply choosing an obvious font change to show the syntax highlighting remains: walt.farrell 1 Quote Link to comment Share on other sites More sharing options...
Move Along People Posted September 13, 2019 Share Posted September 13, 2019 - Quote Move Along people,nothing to see here Link to comment Share on other sites More sharing options...
meyer.wil Posted September 13, 2019 Author Share Posted September 13, 2019 7 hours ago, MikeW said: Did you try Paste Special? My code editor can copy as RTF and using Paste Special I have RTF as one of the paste formats and syntax colors come in. Paste Special shows only Unicode Text in its list. Tried anyway, with exported RTF in the clipboard, but it treated as literal. Quote Link to comment Share on other sites More sharing options...
meyer.wil Posted September 13, 2019 Author Share Posted September 13, 2019 15 hours ago, walt.farrell said: As Haakoo said, you can drag/drop an RTF file onto a text frame, or File > Place it. So far, this is the only alternative which works. But it means pasting to an editor, to save to a file, so slightly less than my current workflow, in that I now have a paragraph style that works, thanks to your instructions above. I can live with the paste and save steps; the more important issue is that I can now accomplish -- and therefore alter -- the style in Publisher. walt.farrell 1 Quote Link to comment Share on other sites More sharing options...
MikeW Posted September 13, 2019 Share Posted September 13, 2019 Did you try pasting into Word, select all, copying and then pasting into APub? Quote Link to comment Share on other sites More sharing options...
Davide.Barranca Posted September 18, 2019 Share Posted September 18, 2019 Hi, I have similar needs (code syntax highlighting) and I've found that copying from Visual Studio Code and pasting directly into a Text frame doesn't retain the metadata. An intermediate step pasting to Text Editor doesn't help either. Instead, pasting to Pages, copying from it and eventually pasting to Affinity seems to work – almost, for to apply the specific font glyphs (I use Fira Code, which has super fancy substitutions for stuff like ===, !=, =>, etc.) it's better to re-apply a Style. All in all, it is quite a cumbersome process; frankly I don't know how other page design applications deal with that need – so far I've been using either Leanpub or Softcover, that get markdown in and output pdf with an intermediate LaTeX step – syntax highlighting come as a built-in feature, and it is language-specific (JavaScript has a different highlighting from C, etc) Would that be a sensible feature request? Technical publishing isn't a small niche I suppose :-) Thank you, Davide Barranca Quote Link to comment Share on other sites More sharing options...
MikeW Posted September 18, 2019 Share Posted September 18, 2019 My programming text editor on the right, APub on the left and I had already used Paste Special. My text editor also uses different syntax coloring for different languages. But perhaps it is really putting RTF onto the clipboard. My coding also pastes into Word and LibreOffice Writer properly, which can then also be copied/pasted into APub properly. Quote Link to comment Share on other sites More sharing options...
walt.farrell Posted September 18, 2019 Share Posted September 18, 2019 15 minutes ago, MikeW said: and I had already used Paste Special. I'm curious, Mike, whether you need to use Paste Special? I would think it would be better for Publisher to automatically picks the most feature-rich version in the clipboard, but if that were happening you should just be able to do a Paste. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. iPad: iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1 Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.