load an image (JPG, PNG) and print to microsoft print to pdf

Started by mpapke, May 11, 2020, 06:32:02 AM

Previous topic - Next topic

mpapke

I want to do this:
1. load an image in JPG or PNG format
2. convert it to PDF by printing it directly to the 'Microsoft Print to PDF' virtual printer under Win10.

The virtual printer needs the filename of the target pdf given.

Can anybody help me?

Michael

td

Assuming that you want to use WinBatch for the task, you might consider the PdfSharp dotNet assembly.  It can be found at http://www.pdfsharp.net. Using WinBatch's CLR hosting (dotNet assemblies) has a bit of a learning curve but it is well within the capabilities of most WinBatch users.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

I would use ImageMagicks's "convert" utility for this.

convert *.jpg AllCombined.pdf

works for 1 (or more) JPG files.

Note: Easiest, of course, would just be to "shell out" to "convert", but ISTR that there is a COM interface for it (on the Windows platform version of IM).  I think it was discussed here and I used it once or twice.

td

Good suggestion but the newer versions of ImageMagic do not have robust COM support anymore.  In fact, they have more or less undocumented the COM interfaces.  There is a .Net assembly that interfaces with ImageMagic but I have not tried it with WinBatch to verify how well works.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade