How to replace png image with PDF version and keep size and spacing?

Everything related to our flagship word processor.
Post Reply
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

How to replace png image with PDF version and keep size and spacing?

Post by withoutFeathers »

Hi,
Background to the problem:
I've discovered that, somehow, my pdf drawings in files made in Nisus Version 2 have all been converted into .png format (when opened in Version 2 or in Version 3; the original .pdf seems to be gone.)

I understand that that should only happen with copy/paste imports, but I'm reasonably sure I didn't use copy paste. So it seems somehow version 2 has translated my pdfs into pngs. The only thing that comes to mind is that I've upgraded my MacOS twice, and maybe there's a weird change happened in how Nisus/Apple deals with these images embedded in rtf files.

Anyway, what I need today is to fix them all. I'm working in Nisus 3.2.1 now, and replacing these unwanted png files with the original PDFs (which I still have, luckily).

This works, but while doing them I'd also like an easy way to keep the original layout that I did in version 2: essentially the resizing and padding values.

In other words, my question specifically is:
If I have a "Foo1.png" that's embedded in the Nisus file, is there a way to import and place "Foo1.PDF", the original, so that the size and spacing of "Foo1.png" in Nisus is preserved with "Foo1.PDF" ?

I could of course write down the numbers, and apply them again after, but I'm hoping there's a way to do this directly.

I tried the "Copy Shape Appearance" "Paste Shape Appearance", that pops up with the images on right click, which looked promising, but nothing happened -- the values didn't transfer.

wF
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to replace png image with PDF version and keep size and spacing?

Post by phspaelti »

If you select an image and use "Insert Image" does the replacing image not maintain the size?

If you do need to replace the images and maintain the size it shouldn't be too hard to write a macro to do that, at least as long the filenames can be correctly deduced.
philip
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: How to replace png image with PDF version and keep size and spacing?

Post by withoutFeathers »

phspaelti wrote: 2021-01-24 08:07:02 If you select an image and use "Insert Image" does the replacing image not maintain the size?
I did try that; and just tried again to doublecheck:

what happens is "insert image" is greyed-out. Apparently I can't insert an image with one selected.

My memory of Version 2 was that I could do this, so perhaps this has changed.

As far as I can tell, in version 3 I'm forced to insert it somewhere else, and start over. It inserts as 'inline' and I have to change to 'floats on page of paragraph', and then place it exactly where I want it, including getting it to attach to the corrrect paragraph and resetting the measurements for size and padding.

wF
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to replace png image with PDF version and keep size and spacing?

Post by phspaelti »

The behavior you describe sounds strange to me, but I'm not really confident about these things myself.

As I said, worst comes to worst, you should be able to accomplish what you want with a macro. Here is one you could try (on a copy of your document, please).

The macro will prompt you for a folder, which should contain files with the same names as your images with extension ".pdf". No allowances have been made in case there are any mismatches. :D
Attachments
Replace images in File.nwm
(5.96 KiB) Downloaded 379 times
philip
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: How to replace png image with PDF version and keep size and spacing?

Post by withoutFeathers »

phspaelti wrote: 2021-01-24 18:12:31 The behavior you describe sounds strange to me, but I'm not really confident about these things myself.

As I said, worst comes to worst, you should be able to accomplish what you want with a macro. Here is one you could try (on a copy of your document, please).

The macro will prompt you for a folder, which should contain files with the same names as your images with extension ".pdf". No allowances have been made in case there are any mismatches. :D
Thanks for the effort phspaelti. I've actually done them all by hand in a new draft of this current file already, but I will try it out in a test of the earlier problem file in case I need it in future work (which I might, if the same problem crops up). However I need to clarify a couple things before I try, so I'll know how to prepare:

1) To clarify the naming: the names of the images in my original problem file, which seem to have been automatically created by Nisus, already have [.png] appended to the original [.pdf], so that the name in the file is: [Foo1.pdf.png]. So, what you're saying is the macro will look for a file with that name, except with .pdf appended. So it will look for a file, in the folder, named: [Foo1.pdf.png.pdf]. Correct?

2) Is it going to search my whole file and do all of the images in it at once, or is it one at a time; so that I'll re-invoke the macro for each one? (I don't mind either way, but I'll prepare my test differently depending).

wF
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to replace png image with PDF version and keep size and spacing?

Post by phspaelti »

withoutFeathers wrote: 2021-01-24 18:51:57 Thanks for the effort phspaelti. I've actually done them all by hand in a new draft of this current file already, but I will try it out in a test of the earlier problem file in case I need it in future work (which I might, if the same problem crops up). However I need to clarify a couple things before I try, so I'll know how to prepare:

1) To clarify the naming: the names of the images in my original problem file, which seem to have been automatically created by Nisus, already have [.png] appended to the original [.pdf], so that the name in the file is: [Foo1.pdf.png]. So, what you're saying is the macro will look for a file with that name, except with .pdf appended. So it will look for a file, in the folder, named: [Foo1.pdf.png.pdf]. Correct?
Actually I'm not quite sure. I'm using a Nisus macro language feature called ".barefilename". So my prediction would be that it will look for either [Foo1.pdf] or [Foo1.pdf.pdf]. It will definitely strip the ".png"
withoutFeathers wrote: 2021-01-24 18:51:57 2) Is it going to search my whole file and do all of the images in it at once, or is it one at a time; so that I'll re-invoke the macro for each one? (I don't mind either way, but I'll prepare my test differently depending).
It's intended to search the whole file [Document.allImages].
Since you want to run a test, I will try adding a check to make it a bit more robust.
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to replace png image with PDF version and keep size and spacing?

Post by phspaelti »

phspaelti wrote: 2021-01-25 00:48:18 Actually I'm not quite sure. I'm using a Nisus macro language feature called ".barefilename". So my prediction would be that it will look for either [Foo1.pdf] or [Foo1.pdf.pdf]. It will definitely strip the ".png"
I just checked and it seems it would use [Foo1.pdf.pdf]. But I will try to make it a bit smarter about this, so that it only attaches the pdf if necessary.
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to replace png image with PDF version and keep size and spacing?

Post by phspaelti »

So here is an improved version that should skip images for which it has no pdf file.
Attachments
Replace images in File.nwm
(6.19 KiB) Downloaded 393 times
philip
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: How to replace png image with PDF version and keep size and spacing?

Post by withoutFeathers »

phspaelti wrote: 2021-01-25 01:21:46 So here is an improved version that should skip images for which it has no pdf file.
Hi Philip,
Thank you. I lodaded it and I got an error, and I'm unsure I'm using it correctly. When the very first dialog box opens from the macro, should I choose the folder that has the original pdf files? That's what I'm doing. Error repeatedly:

"There was an error on line 28 in the macro "Replace images in File".
"The given index (1) is out of bounds for the array (count 1)."

I also tried changing one of the file names to "pdf.pdf", just to see. Same error.

So... to be clear, I'm not asking or expecting you to make another version of the macro. In fact I'd be happy just to stop now, since my file has already been fixed, I don't actually need it at the moment, and I know software development can be a rabbit-hole of time. :)

But maybe someone from Nisus (Martin?) could chime in about why individual images can't be replaced with other images and keep their layout characteristics? Couldn't that be added as a feature?

Long-term, IMO that's a better solution than replacing with pdfs, since such replacement ideally should work for other image types than just pdf.

wF
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: How to replace png image with PDF version and keep size and spacing?

Post by martin »

withoutFeathers wrote: 2021-01-25 09:47:22But maybe someone from Nisus (Martin?) could chime in about why individual images can't be replaced with other images and keep their layout characteristics? Couldn't that be added as a feature?
This is the correct solution in the long-term. Nisus Writer should allow you to somehow replace an image and keep its existing image options/formatting intact, eg: size, padding, border, transparency, etc. Thanks for the suggestion, I'll file it as something we need to address.
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: How to replace png image with PDF version and keep size and spacing?

Post by withoutFeathers »

martin wrote: 2021-01-25 11:10:51 Thanks for the suggestion, I'll file it as something we need to address.
:)

wF
Post Reply