How to call PDF Text Replacer Command Line (pdftr.exe) from Excel or Outlook by VB Script and capture the console text message?

Interested in this product for a project I'm working on. I have a couple of questions before making a decision.

1. My output file was specified as "C:\test.pdf", this ended up in "C:\users\p*****n\appdata\local\virtualstore" - is this because it's the demo version or something else?

2. Is there a silent option without the pages and pages of output on the command line window?

Regards.
Customer
--------------------------------------
>>Interested in this product for a project I'm working on. I have a couple of questions before making a decision.
>>1. My output file was specified as "C:\test.pdf", this ended up in "C:\users\p*****n\appdata\local\virtualstore" - is this because it's the demo version or something else?

Thanks for your message, it seems pdfprint.exe or pdftr.exe created a temporary PDF file for optimization, and then print this optimized PDF file from temporary folder, this is normal, please don't worry about this matter.

>>2. Is there a silent option without the pages and pages of output on the command line window?

You can simple add a "> nul" to the end of command line to suppress all console message, for example,

pdfprint.exe D:\test.pdf > nul

D:\VeryPDF\pdftr.exe -searchandoverlaytext "My Name=>Your Name" D:\in.pdf D:\out.pdf > nul

We hope this method will useful to you, please give it a try.

VeryPDF
--------------------------------------
This part is resolved. The output was going somewhere else because it didn't have rights in the root of C: as I didn't open cmd with admin rights.

However, now I want to use this prog in anger, I need it to run from within excel or outlook. This part is fine, but I need a return value of how many text replaces it's made and test if zero = error (found nothing)

Any way of doing this?
Customer
--------------------------------------


>>However, now I want to use this prog in anger, I need it to run from within excel or outlook. This part is fine, but I need a return value of how many text replaces it's made and test if zero = error (found nothing)

You can use VB Script to call pdftr.exe application, and capture the console text message which outputted by pdftr.exe application, parse the text message, then you can get how many text words be replaced by this command line.

For example,

Dim WshShell, oExec
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("D:\VeryPDF\pdftr.exe -searchandoverlaytext ""My Name=>Your Name"" D:\in.pdf D:\out.pdf")
x = oExec.StdOut.ReadLine
Wscript.Echo x

You can also redirect output to a file and then read the file:

return = WshShell.Run("D:\VeryPDF\pdftr.exe -searchandoverlaytext ""My Name=>Your Name"" D:\in.pdf D:\out.pdf > c:\temp\output.txt", 0, true)

Set fso  = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("c:\temp\output.txt", 1)
text = file.ReadAll
file.Close

We hope above solutions will useful to you, you may give them a try.

VeryPDF

灯泡 See Also:

PDF Editor-replace text in PDF in batch
https://www.verypdf.com/wordpress/201303/pdf-editor-replace-text-in-pdf-in-batch-35624.html

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!