Calling NConvert from ASP.Net

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Posts: 3
Joined: Mon Feb 22, 2016 2:44 pm

Calling NConvert from ASP.Net

Postby KenJRay » Mon Apr 04, 2016 7:02 pm

Not sure if this has already been answered, but I have a situation in a web site where it pulls a document in TIFF format from a repository, and displays that document as a web page. This has caused problems for people with Apple Macs, because they uses "quicktime" to display the TIFF file, and it can't handle multipage TIFF documents. To me, the solution would be to convert the TIFF document on the fly to PDF - and nConvert seems the ideal solution for this. What I've tried to do is used the ASP.Net "Process Start" - the sample code is:

Code: Select all

Dim nStartIndex = strImagePath.LastIndexOf("\") + 1
Dim strSourceFile = strImagePath.Remove(0, nStartIndex)
Dim strNconvertProgram As String = "C:\Program Files\XnView\nconvert.exe"
Dim StrNConvertArguments As String = String.Format("-c fax -multi -out pdf -o %.pdf - overwrite -quiet {0}", strImagePath)
Dim myProcess As Process = Process.Start(strNconvertProgram, StrNConvertArguments)
Dim strOutputFile As String = strSourceFile.Replace("tif", "pdf")
Response.Redirect(String.Format("{0}", strOutputFile, False))

However, it doesn't do the Response.Redirect.

Any thoughts on the correct way to do this?


Ken Ray
IT Solutions Architect
Clay County Clerk of the Circuit Court

Posts: 1364
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Calling nCovert from ASP.Net

Postby cday » Mon Apr 04, 2016 7:47 pm

Some problems with your NConvert code, I think:

Code: Select all

"-c fax -multi -out pdf -o %.pdf - overwrite -quiet {0}"

For a PDF file Fax compression is 1 :

Code: Select all

-c value          : Compression number
              default : 0 (uncompressed)
              PDF    : 1 (Fax), 2 (Rle), 3 (LZW), 4(ZIP), 5 (JPEG)


Code: Select all

"-out pdf -multi -quiet -overwrite -c 1 -o %.pdf {0}"

And the order of some terms looks wrong, so try this ordrer:

Code: Select all

"-out pdf -multi -quiet -overwrite -c 1 -o %.pdf {0}"

There's not much documentation on the permitted order of terms but about that order worked earlier today in another thread...

I can't comment on your ASP code, and the command line is so unforgiving in some respects that the above changes may only be steps on the way to final working code... :wink:

Return to “NConvert”

Who is online

Users browsing this forum: No registered users and 1 guest