Commit abcf13ce authored by Michael Vernier's avatar Michael Vernier

Added optional pdf name parameter, fixed working directory issue with new 2015 build

parent 07ccb213
......@@ -23,20 +23,39 @@ namespace Word2PDF
catch( Exception e )
{
Console.WriteLine( "Missing file" );
Console.WriteLine( "Usage: " + args[ 0 ] + "[docx filename]" );
Console.WriteLine( "Usage: " + System.AppDomain.CurrentDomain.FriendlyName + " <docx filename> [pdf filename]" );
Environment.Exit( -1 );
}
if( docxname == "--help" || docxname == "-help" || docxname == "-h" )
{
Console.WriteLine( "Usage: " + System.AppDomain.CurrentDomain.FriendlyName + " <docx filename> [pdf filename]" );
Environment.Exit( 0 );
}
FileInfo file = new FileInfo( docxname );
object docxnameobj = ( object )file.FullName;
object docxnameobj = (object)file.FullName;
//Console.WriteLine( "File name full: " + file.FullName );
string pdfname = file.FullName.Substring( 0, file.FullName.LastIndexOf( '.' ) ) + ".pdf";
string pdfname = "";
try
{
pdfname = args[ 1 ];
if( !pdfname.Contains( ".pdf" ) )
{
pdfname += ".pdf";
}
}
catch( Exception e )
{
pdfname = file.FullName.Substring( 0, file.FullName.LastIndexOf( '.' ) ) + ".pdf";
}
//Console.WriteLine( "pdf name full: " + pdfname );
pdfname = Environment.CurrentDirectory + '\\' + pdfname;
object pdfnameobj = ( object )pdfname;
object format = ( object )( WdSaveFormat.wdFormatPDF );
object pdfnameobj = (object)pdfname;
object format = (object)( WdSaveFormat.wdFormatPDF );
Microsoft.Office.Interop.Word.Application word = null;
......@@ -50,9 +69,9 @@ namespace Word2PDF
doc.SaveAs2( ref pdfnameobj, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing );
( ( Microsoft.Office.Interop.Word._Document )doc ).Close( ref missing, ref missing, ref missing );
( (Microsoft.Office.Interop.Word._Document)doc ).Close( ref missing, ref missing, ref missing );
( ( Microsoft.Office.Interop.Word._Application )word ).Quit( ref notTrue, ref missing, ref missing );
( (Microsoft.Office.Interop.Word._Application)word ).Quit( ref notTrue, ref missing, ref missing );
}
catch( Exception e )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment