Problem converting multipage DCX to PDF

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

Moderators: helmut, XnTriq, xnview

Post Reply
erict43
Posts: 4
Joined: Thu Apr 14, 2011 7:25 pm

Problem converting multipage DCX to PDF

Post by erict43 »

I am trying to convert multipage DCX files to multipage PDF. However, I cannot get it to work properly. The command I am using is:

Code: Select all

nconvert -v -xall -out pdf -c 1 -keepfiledate inputfile.dcx
The result of this is a seperate PDF file for each page of the DCX file, but I would like a single multipage PDF.

If I try to convert without the -xall switch, my PDF file only contains the first page. If I try to include the -multi switch, I get a file called output.tif containing the words "Invalid Image".

Any help would be appreciated.
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Problem converting multipage DCX to PDF

Post by marsh »

This example worked for me:
nconvert -v -in -1 -xall -multi -out pdf -o output.pdf input.dcx
erict43
Posts: 4
Joined: Thu Apr 14, 2011 7:25 pm

Re: Problem converting multipage DCX to PDF

Post by erict43 »

marsh wrote:This example worked for me:
nconvert -v -in -1 -xall -multi -out pdf -o output.pdf input.dcx
Yes, this worked for me too. It seems it will not make it multi-page unless you specifically identify a single output file.

Now that it works for a single file, how can I make this work with a file list? If I use a file list, even if I use a wildcard like "-o %.pdf", it creates a file with the name of the first one on the list and puts all subsequent files into that one.
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Problem converting multipage DCX to PDF

Post by marsh »

erict43 wrote:
marsh wrote:This example worked for me:
nconvert -v -in -1 -xall -multi -out pdf -o output.pdf input.dcx
Yes, this worked for me too. It seems it will not make it multi-page unless you specifically identify a single output file.

Now that it works for a single file, how can I make this work with a file list? If I use a file list, even if I use a wildcard like "-o %.pdf", it creates a file with the name of the first one on the list and puts all subsequent files into that one.
I think a script would be required for that.
erict43
Posts: 4
Joined: Thu Apr 14, 2011 7:25 pm

Re: Problem converting multipage DCX to PDF

Post by erict43 »

I wrote a Visual Basic program to run through the list one at a time. I am not a programmer, so don't judge me on this code. It's probably more complicated than it needs to be, but I have a lot of files to convert, so I set it up to create a log file as well as show a little status update for each one. Feel free to use it if you like. Just a note, this is not VBScript, it's Visual Basic. If you want to run it as a VBS you will probably need to make some modifications.

Code: Select all

Option Strict On
Imports System.IO

Module Module1

    Sub Main()
        Dim fileListPath As String = "c:\DCX_files\filelist.txt"    ' List of files to be converted
        Dim fileList() As String = IO.File.ReadAllLines(fileListPath)                   ' Read in file list
        Dim fileCount As Integer = fileList.Length                              ' Count # of files for progress reporting
        Dim filesProcessed As Integer = 1                                       ' File counter
        Dim file As String                                                      ' Current file selected from the list
        Dim fileInfo As System.IO.FileInfo                                      ' To extract filename and pathname
        Dim fileName, filePath, outputName, shellCommand As String
        Dim procID As Integer                                                   ' Just used to capture output of Shell command
        Dim logFile As String = "c:\DCX_files\DCX_log.txt"  ' Log file pathname

        ' Write header for log file
        My.Computer.FileSystem.WriteAllText(logFile, "Rundate: " & vbDate & vbCrLf, False)
        My.Computer.FileSystem.WriteAllText(logFile, "Files to process:  " & CStr(fileCount) & vbCrLf, False)
        My.Computer.FileSystem.WriteAllText(logFile, "--------------------------------------------" & vbCrLf, False)

        ' Convert files
        For Each file In fileList
            ' Show current progress
            Console.Clear()
            Console.Write("Processing file " & CStr(filesProcessed) & "/" & CStr(fileCount) & vbCrLf & vbCrLf)

            ' Get name and path of current file
            fileInfo = My.Computer.FileSystem.GetFileInfo(file)
            fileName = fileInfo.Name
            filePath = fileInfo.DirectoryName
            outputName = filePath & "\" & Left$(fileName, Len(fileName) - 4) & ".pdf"
            Console.Write("Converting:  " & file & vbCrLf)
            Console.Write("Output file: " & outputName)
            Console.WriteLine()

            ' Run NConvert in command shell, wait to finish before processing next file
            shellCommand = "c:\nconvert -quiet -xall -multi -out pdf -c 1 -keepfiledate -o """ _
                & outputName & """ """ & file & """"

            procID = Shell(shellCommand, AppWinStyle.Hide, True, -1)

            ' Write to log file
            My.Computer.FileSystem.WriteAllText(logFile, "Processed:  " & file & vbCrLf, True)

            filesProcessed += 1

        Next

        ' Write final log entry
        My.Computer.FileSystem.WriteAllText(logFile, "--------------------------------------------" & vbCrLf, False)
        My.Computer.FileSystem.WriteAllText(logFile, "Processed " & CStr(filesProcessed - 1) & "/" & CStr(fileCount) & " files." & vbCrLf, True)

        Console.WriteLine()
        Console.Write("Processing complete.  Press any key to end.")
        Console.ReadKey()

    End Sub

End Module
User avatar
Peter2
XnThusiast
Posts: 1365
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Re: Problem converting multipage DCX to PDF

Post by Peter2 »

Maybe you can create the single-PDFs first and then merge them together in a second step? There are some freeware tools ...

http://www.ujihara.jp/ConcatPDF/en/
http://www.chip.de/downloads/PDF-Split- ... 95960.html
http://noliturbare.com/more/links

Peter
XnViewMP <Current version> German, XnConvert <Current version>, Win 10
erict43
Posts: 4
Joined: Thu Apr 14, 2011 7:25 pm

Re: Problem converting multipage DCX to PDF

Post by erict43 »

I thought of doing that initially, but I have quite a lot of files to convert, it would be quite time consuming. The VB app works, so I am going to use that.
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Problem converting multipage DCX to PDF

Post by marsh »

Thank you for sharing script
Post Reply