Converting JPG to PDF

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
aroncox
Posts: 36
Joined: Fri May 15 2009

Converting JPG to PDF

Post by aroncox »

I'm using the code below (which is in PowerBuilder sorry, but you ought to be able to work out what it is doing). I'm trying to convert a JPG file to a PDF and all that happens right now is when it gets to the BatchConvert call the file opens in Windows Picture and Fax Viewer and then never exits from BatchConvert (i.e. it hangs). I do not have JPG files associated with Windows Picture and Fax Viewer and have tried associating them with Irfan View, Paint, and a few other apps. Doublie-clciking the JPG open the associated app, but Windows Picture and Fax Viewer always opens when BatchConvert is called!

Any ideas appreciated. Thanks.

Code: Select all

// Connect the pdfobj ole object to the cdintf interface of CDIntf.dll
// To be able to use this dll CDIntf should be registered in Windows.
pdfobj.ConnectToNewObject("cdintfEx.cdintfEx.4")

// Attach to PDFprinter
pdfobj.DriverInit ("Trace PDF Converter")  
// PrinterName is declared as the name of the existing printer

pdfobj.EnablePrinter("xxx","xxx")

pdfobj.SetDefaultPrinter()
    
// Set output PDF file name
pdfobj.DefaultFileName = "C:\Temp\AmynuiJPG.pdf"
    
// Set file options to no prompt and use file name
pdfobj.FileNameOptions = NoPrompt + UseFileName
	 
// Enable the printer before each printout.  This is for the Developer version 2.1
pdfobj.EnablePrinter("xxx","xxx")
    
pdfobj.BatchConvert("C:\test.jpg")

pdfobj.DriverEnd()
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Converting JPG to PDF

Post by Devteam »

In order for BatchConvert to work, you need to be able to right-click on the document, select the Print option from the menu and have your document printed directly to the printer. This works well with IrfanView which you mention below but you need to properly configure the registry first. By default, the "print" command does not get associated with IrfanView. You can change the association by adding the following key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\IrfanView.jpg\shell\print\command]
@="\"C:\\Program Files\\IrfanView\\i_view32.exe\" \"%1\" /print"

Before trying to call BatchConvert, add the above key, set your default printer to the PDF printer, right-click on any .jpg and select "Print." The output should go directly to the printer without any window popping up.

Let us know if this helps.
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Post Reply