# Replace text to image in PDF and specify image width and height

VeryPDF PDF Text Replacer Command Line not only can be used to replace text by text  in PDF file. It also can be used to replace text by image and it allows you to specify the image width and height.  By this function, you do not worry that image size is too big to be displayed properly in the output PDF. In the following part, I will show you how to use this software.

• There are two versions PDF Text Replacer: GUI version and command line version. Both of two version can be used to replace text by image but in this article, I will take the command line version for example.

Step 2. Replace Text by Image

Usage:pdftr.exe [options] <Input-file> <Output-file>
Examples

• When you need to simply replace text by text, please refer to the following command line.
pdftr.exe -contentreplace "My Name=>Your Name" D:\in.pdf D:\out.pdf
-contentreplace <string>      : this parameter is an order to replace text in page content objects directly
• When you need to replace text by image singly, please refer to the following template.
• pdftr.exe -oldtext "Old Text" -image D:\test.png D:\in.pdf D:\out.pdf
Please note the image file format only can be one of the following three file formats:JPEG, PNG and TIFF
-oldtext <string> :this parameter is an order to specify text to replace
-image <string> : this parameter is an order to specify image to replace with, support JPEG, PNG and TIFF

• Here come to the key point. When we need to replace text by image and specify the image width and height, please refer to the following templates.
• pdftr.exe -oldtext "Old Text" -image D:\test.png -imgwidth 20 -imgheight 50 D:\in.pdf D:\out.pdf
pdftr.exe -oldtext "Old Text" -image D:\test.png -imgwidth -1 -imgheight -1 D:\in.pdf D:\out.pd
-imgwidth <int>   : set width for the new image, unit: pixel, default is 0 for auto, -1 for full image width
-imgheight <int>  : set height for the new image, unit: pixel, default is 0 for auto, -1 for full image height
Note: please pay attention to the value:
0: default or set width or height automatically.
-1: for full image width or height

Now let us make field practice in the MS Dos Windows. All the replacing detail information will be shown in the MS Dos Windows.

• Now let us check the replacing effect.