Add text to PDF [Error can't open file...]

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
Baloon
Posts: 2
Joined: Tue Mar 24, 2020 6:54 pm

Add text to PDF [Error can't open file...]

Post by Baloon » Tue Mar 24, 2020 6:58 pm

I would like add text to pdf by command:

Code: Select all

nconvert -in pdf -text_font arial 36 -text_flag top-center -text "llll" 838.pdf
utilities returns error, is it possible add?

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Add text to PDF

Post by cday » Tue Mar 24, 2020 7:52 pm

Do you have Ghostscript installed, same x32 or x64 as the version of NConvert you are using?

It is needed I think to open the PDF, to rasterise the image, and you need to set a suitable DPI value using -dpi depending on the quality you need.

Note: The -in PDF term in your code isn't needed in practice, and you should be able to remove it, but I don't think it is likely to cause a problem.

Baloon
Posts: 2
Joined: Tue Mar 24, 2020 6:54 pm

Re: Add text to PDF

Post by Baloon » Tue Mar 24, 2020 8:02 pm

I installed ghostscript
message
Error: Don't know how to read this picture (838.pdf)

if delete -in pdf
message

Error: Don't know how to read this picture (838.pdf)

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Add text to PDF

Post by cday » Tue Mar 24, 2020 8:14 pm

Baloon wrote:
Tue Mar 24, 2020 8:02 pm
I installed ghostscript
The same x32 or x64 version as the version of NConvert you are using, whichever version of Windows you are using, presumably?

Some PDF files cannot be opened in XnView software for a currently unknown reason I think, are you able to test another PDF file?

And if you have XnView Classic or 'MP installed, with the same x32 or x64 as NConvert, could you try opening the file with one of those?

If necessary, are you able to upload the 838.pdf file, or another that doesn't open, although I'm not sure when I will be able to look at it and test your code, in case the error lies elsewhere?

[Edited]

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Add text to PDF

Post by cday » Tue Mar 24, 2020 8:39 pm

To complicate matters, I've recalled that there was actually a compatibility problem with a recent version of Ghostscript due to a change in Ghostscript, I don't have the thread immediately to hand, but if you are unable to make progress you could test a slightly older version of NConvert with an earlier version of Ghostscript...

Which versions of NConvert and Ghostscript are you currenty using?

[Edited]

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Add text to PDF

Post by cday » Thu Apr 02, 2020 8:20 am

cday wrote:
Tue Mar 24, 2020 8:39 pm
I've recalled that there was actually a compatibility problem with a recent version of Ghostscript due to a change in Ghostscript...
I can now confirm that NConvert 7.39 and Ghostscript 9.52 versions are compatible, so those or later versions of either should work together... :D

Use 32-bit GS with 32-bit NConvert, and 64-bit GS with 64-bit NConvert versions.

Post Reply