Как использовать AIC для загрузки файла PDF и вывода Postscript на компьютере с Windows 2008?

Как написать код с помощью AIC (Acrobat Interapplication Communication) для загрузки файла PDF и вывода эквивалентного файла Postscript? Используя Acrobat X в интерактивном режиме, я открывал файл, затем использовал меню «Файл» > «Сохранить как...» > «Дополнительные параметры…» > «PostScript».

В идеале я хотел бы сделать это из программы службы Windows, не отображая какое-либо окно на консоли компьютера.

Я установил Acrobat X Pro и загрузил Acrobat SDK.

Я бы предпочел примеры кода на C#, но при необходимости могу конвертировать из VB или C++.


person randomfactor    schedule 12.05.2011    source источник


Ответы (3)


Для последней версии Ghostscript (v9.02) подходящей командной строкой будет:

gswin32c.exe ^
  -o output.ps ^
  -sDEVICE=ps2write ^
   input.pdf
person Kurt Pfeifle    schedule 15.05.2011
comment
Ghostscript не подходит для моих нужд. Adobe Acrobat является обязательным требованием. - person randomfactor; 16.05.2011
comment
Я сейчас реверсирую. Мне известен хитрый фрагмент кода, который позволяет Enfocus PowerSWITCH делать именно то, на что я надеялся. Тем не менее, их метод включает в себя тонкую магию, чтобы обойти механизмы безопасности песочницы javascript, которые я не смог удовлетворительно разработать. - person randomfactor; 23.09.2011
comment
Кажется, что Adobe — злейший враг Acrobat. Зачем им встраивать в пользовательский интерфейс что-то, что недоступно через их программный API? - person randomfactor; 23.09.2011

Другой альтернативой для вас может быть вызов Acrobat Reader (или Professional?) с переключателями командной строки, чтобы он конвертировал ваш PDF в PostScript. В Linux (Ubuntu Natty) по крайней мере это то, что предлагает версия 9.4.2 Acrobat Reader (не уверен, что версия для Windows предлагает точно такие же переключатели CLI):

kp@s42:~$  acroread -help
Usage: acroread [options] [list of files] 
Run 'acroread -help' to see a full list of available command line options.
------------------------

Options:
    --display=<DISPLAY>                                          This option specifies the host and display to use.
    --screen=<SCREEN>                                            X screen to use. Use this options to override the screen part of the DISPLAY environment variable.
    --sync                                                       Make X calls synchronous. This slows down the program considerably.
    -geometry [<width>x<height>][{+|-}<x offset>{+|-}<y offset>] Set the size and/or location of the document windows.
    -help                                                        Prints the common command-line options.
    -iconic                                                      Launches in an iconic state on the desktop.
    -info                                                        Lists out acroread Installation Root, Version number, Language.
    -tempFile                                                    Indicates files listed on the command line are temporary files and should not be put in the recent file list.  
    -tempFileTitle <title>                                       Same as -tempFile, except the title is specified.
    -toPostScript                                                Converts the given pdf_files to PostScript.
    -openInNewInstance                                           It launches a new instance of acroread process. 
    -openInNewWindow                                             Same as OpenInNewInstance. But it is recommended to use OpenInNewInstance. openInNewWindow will be deprecated.
    -installCertificate <server-ip> <server-port>                Fetches and installs client-side certificates for authentication to access the server while creating secured connections.
    -installCertificate [-PEM|-DER] <PathName>                   Installs the certificate in the specified format from the given path to the Adobe Reader Certificate repository.
    -v, -version                                                 Print version information and quit.
    /a                                                           Switch used to pass the file open parameters.


Forms of using -toPostScript
    -toPostScript [options] pdf_file ... [ps_dir]
    -toPostScript [options] -pairs pdf_file_1 ps_file_1 ...
    -toPostScript [options]
    Note: When using -toPostScript it must be the first argument passed in on the command line.

Valid options for the conversion of PDF to PostScript:

    -binary                                                      emit binary PostScript where possible.
    -start <int>                                                 identify the first page in the document to be converted (default is the first page of the document).
    -end <int>                                                   identify the last page in the document to be converted (default is the last page of the document).
    -optimizeForSpeed                                            emit PostScript such that all fonts are emitted once at the beginning of the document. 
    -landscape                                                   rotate the pages to print landscape.
    -reverse                                                     reverse the page order of the output.
    -odd                                                         emit only odd-numbered pages.
    -even                                                        emit only even-numbered pages.
    -commentsOff                                                 don't print comments.
    -annotsOff                                                   don't print annots.
    -stampsOff                                                   don't print stamps.
    -markupsOn                                                   print document and markups.
    -level2                                                      emit Level 2 PostScript.
    -level3                                                      emit Level 3 PostScript.
    -printerhalftones                                            use the printer default halftones.
    -saveVM                                                      download fonts as needed to preserve printer memory.
    -shrink                                                      shrink the pages to fit the page size.
    -expand                                                      expand the pages to fit the page size.
    -size <pagesize>                                             set the page size.
    -transQuality level                                          set the transparency flattening level. Value from 1-5.
    -printerName <name>                                          this is to print device-dependent PS.
    -rotateAndCenter                                             auto-rotate and center the pages.
    -choosePaperByPDFPageSize                                    use the pdf page size to determine the output tray.
    -nUp <hpage> <vpage> <pageorder> border rotate               print multiple pages on the same sheet of paper.
    -booklet <subset> <binding> rotate <from> <to>               prints multiple pages on the same sheet of paper in the order required to read correctly when folded.


For detailed description on the options please visit the manpage.
person Kurt Pfeifle    schedule 16.05.2011
comment
Ни acrobat, ни acrord32 не предлагают никаких параметров командной строки в Windows. - person randomfactor; 17.05.2011
comment
@randomfactor: Это неправда! Я точно знаю, что acrord32.exe действительно предлагает некоторые параметры командной строки для печати... Я просто не знаю, в чем разница с версией для Linux, и я Мне сейчас лень это исследовать. -- Значит, для этой задачи линукс использовать нельзя? - person Kurt Pfeifle; 17.05.2011
comment
Хорошо, вы правы. Я пробовал /h /help --help /? и обычные подозреваемые. Но это неподдерживаемые параметры командной строки, и встроенного справочного сообщения нет. Эту информацию можно найти в разделе Adobe Acrobat SDK для разработчиков Часто задаваемые вопросы на стр. 27: - person randomfactor; 17.05.2011

Возможно, было бы лучше использовать Ghostscript. В самом простом случае простой вызов его как внешнего процесса с параметрами командной строки сделает преобразование за вас — но есть несколько способов улучшить интеграцию — вплоть до создания виртуального принтера Postscript.

person jsbueno    schedule 13.05.2011
comment
Ghostscript не подходит для моей цели. Мой коллега настаивает на том, что в прошлом Ghostscript был источником многих проблем с печатью. Это может подойти для файлов, предназначенных только для просмотра на мониторе, но не для коммерческой печати. Поэтому я не могу принять этот ответ. - person randomfactor; 16.05.2011
comment
@randomfactor: Ghostscript намного улучшился в последних 4-5 выпусках. Однако ваш коллега был прав: старый переключатель командной строки -sDEVICE=pswrite действительно выдавал PostScript Level 1, и это было не слишком хорошо для дальнейшей обработки. Вы должны хотя бы попробовать ps2write-выход самой последней версии (9.02), прежде чем сочтете его неподходящим. - person Kurt Pfeifle; 16.05.2011