Page 1 of 1
Problem converting multipage DCX to PDF
Posted: Thu Apr 14, 2011 7:33 pm
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.
Re: Problem converting multipage DCX to PDF
Posted: Fri Apr 15, 2011 3:06 am
by marsh
This example worked for me:
nconvert -v -in -1 -xall -multi -out pdf -o output.pdf input.dcx
Re: Problem converting multipage DCX to PDF
Posted: Fri Apr 15, 2011 3:56 pm
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.
Re: Problem converting multipage DCX to PDF
Posted: Fri Apr 15, 2011 5:42 pm
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.
Re: Problem converting multipage DCX to PDF
Posted: Tue Apr 19, 2011 6:28 pm
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
Re: Problem converting multipage DCX to PDF
Posted: Tue Apr 19, 2011 7:12 pm
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
Re: Problem converting multipage DCX to PDF
Posted: Tue Apr 19, 2011 9:12 pm
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.
Re: Problem converting multipage DCX to PDF
Posted: Fri Apr 22, 2011 9:53 pm
by marsh
Thank you for sharing script