CutePDF или командная строка

11287
Ash King

Можно ли запустить команду, которая автоматически печатает в файл, используя CutePDF ?

Я попробовал это и до сих пор не повезло print C:\test.doc /D:CPW2

Если нет каких-либо других предложений о том, как автоматизировать печать в pdf / конвертировать в pdf через командную строку без вывода сообщений (бесплатная)

4
Что это за файлы? Программа, используемая для отображения, редактирования и печати файла, определит, какую команду терминала следует использовать, если она вообще существует. daxlerod 10 лет назад 0
какое сообщение об ошибке вы получаете? golimar 10 лет назад 0
Вам нужен конкретный выходной путь или это может быть тот же путь, что и входной? Например, `print C: \ test.doc` создаст новый файл PDF под` C: ` nixda 10 лет назад 0
Путь на самом деле не имеет значения, предпочел бы, чтобы он был таким же, как и вход, но его можно изменить соответствующим образом, ошибка, которую я получаю: «Невозможно инициализировать CPW2 устройства». Хотя в принтерах это правильный порт. Я не уверен, что это как-то связано с самим cutepdf Ash King 10 лет назад 0
@AshKing Здравствуйте, я был бы рад, если бы вы могли оставить отзыв, чтобы узнать, должен ли я улучшить свой ответ. nixda 10 лет назад 0

1 ответ на вопрос

5
nixda

Simple solution

If the output path doesn't matter, you could try PDFCreator with the following commandline:

C:\Program Files (x86)\PDFCreator>PDFCreator.exe /NOSTART /PF"C:\test.doc" 
  1. Per GUI you have to enable Use Auto-save and set a auto-save path once.
    From now on, this path will be used every time you execute the command above
  2. You have to set PDFCreator as your default printer

Tip:
Per GUI you can save your settings in a profile (.INI file) which can then be selected when you execute your command line. This way, you don't have to use Auto-save as default for every normal print (e.g. from Word or Excel)

PDFCreator.exe /NoStart /OptionsFile"C:\myprofile.ini" /PF"C:\test.doc" 

Advanced solution

The advantage of the second solution is, that you don't have to set PDFCreator as your default printer and you have full control over the output file path and name

  1. Install PDFCreator together with its COM module

  2. Copy & paste this code to a textfile and save it as Convert2PDF.vbs

    Set PDFCreator = Wscript.CreateObject("PDFCreator.clsPDFCreator", "PDFCreator_") With PDFCreator ReadyState = 0 .cStart "/NoProcessingAtStartup" .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveFormat") = 0 .cOption("AutosaveStartStandardProgram") = 0 DefaultPrinter = .cDefaultprinter .cDefaultprinter = "PDFCreator" .cClearcache .cPrinterStop = false .cOption("AutosaveDirectory") = WScript.Arguments(1) .cOption("AutosaveFilename") = WScript.Arguments(2) .cPrintfile cStr(WScript.Arguments(0)) c = 0 Do While (ReadyState = 0) and (c < 120) c = c + 1 Wscript.Sleep 250 Loop .cDefaultprinter = DefaultPrinter .cClearcache WScript.Sleep 200 .cClose End With Public Sub PDFCreator_eReady() ReadyState = 1 End Sub 
  3. You can execute your VBScript file from the command line with this syntax:
    Convert2PDF.vbs "C:\input.doc" "C:\outputfolder" "outputfilename"

Personally I use a slightly different version where the input and output folder+filename stays the same. I created a shortcut in my shell:sendto folder to easily convert files per right-click

enter image description here

Я только что попробовал ваш продвинутый метод, но ничего не произошло, но опять же я пытаюсь преобразовать .ppt в .pdf Houseman 10 лет назад 0
@OWiz Можете ли вы предоставить более подробную информацию о том, что именно вы сделали? nixda 10 лет назад 0
Я не уверен, что это решение все еще жизнеспособно. PdfForge выпустил новую основную версию, и их документация изменилась nixda 7 лет назад 1