WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mpapke on May 11, 2020, 06:32:02 AM

Title: load an image (JPG, PNG) and print to microsoft print to pdf
Post by: mpapke on May 11, 2020, 06:32:02 AM
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
Title: Re: load an image (JPG, PNG) and print to microsoft print to pdf
Post by: td 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 (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.
Title: Re: load an image (JPG, PNG) and print to microsoft print to pdf
Post by: snowsnowsnow 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.
Title: Re: load an image (JPG, PNG) and print to microsoft print to pdf
Post by: td 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.