Author Topic: load an image (JPG, PNG) and print to microsoft print to pdf  (Read 174 times)

mpapke

  • Newbie
  • *
  • Posts: 1
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

  • Tech Support
  • *****
  • Posts: 3453
    • WinBatch
Re: load an image (JPG, PNG) and print to microsoft print to pdf
« Reply #1 on: May 11, 2020, 07:14:10 am »
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

  • Sr. Member
  • ****
  • Posts: 313
Re: load an image (JPG, PNG) and print to microsoft print to pdf
« Reply #2 on: May 11, 2020, 09:56:21 am »
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

  • Tech Support
  • *****
  • Posts: 3453
    • WinBatch
Re: load an image (JPG, PNG) and print to microsoft print to pdf
« Reply #3 on: May 11, 2020, 10:38:36 am »
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