Skip to content

Commit

Permalink
#22 - Adds the /powerpoint_output switch
Browse files Browse the repository at this point in the history
  • Loading branch information
vittala committed Apr 3, 2018
1 parent 9e1d4c2 commit 2eba29b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
56 changes: 53 additions & 3 deletions OfficeToPDF/PowerpointConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class PowerpointConverter : Converter
return (int)ExitCode.ApplicationError;
}
}
Boolean includeProps = !(Boolean)options["excludeprops"];
Boolean includeTags = !(Boolean)options["excludetags"];
PpPrintOutputType printType = PpPrintOutputType.ppPrintOutputSlides;
MSCore.MsoTriState nowrite = (Boolean)options["readonly"] ? MSCore.MsoTriState.msoTrue : MSCore.MsoTriState.msoFalse;
bool pdfa = (Boolean)options["pdfa"] ? true : false;
if ((Boolean)options["hidden"])
Expand All @@ -107,8 +110,12 @@ class PowerpointConverter : Converter
{
quality = PpFixedFormatIntent.ppFixedFormatIntentScreen;
}
Boolean includeProps = !(Boolean)options["excludeprops"];
Boolean includeTags = !(Boolean)options["excludetags"];
if (!String.IsNullOrWhiteSpace((String)options["powerpoint_output"]))
{
bool printIsValid = false;
printType = PowerpointConverter.getOutputType((String)options["powerpoint_output"], ref printIsValid);
}

app.FeatureInstall = MSCore.MsoFeatureInstall.msoFeatureInstallNone;
app.DisplayDocumentInformationPanel = false;
app.DisplayAlerts = PpAlertLevel.ppAlertsNone;
Expand Down Expand Up @@ -140,7 +147,7 @@ class PowerpointConverter : Converter
activePresentation.Slides.InsertFromFile(inputFile, 0);
}
Converter.releaseCOMObject(fonts);
activePresentation.ExportAsFixedFormat(outputFile, PpFixedFormatType.ppFixedFormatTypePDF, quality, MSCore.MsoTriState.msoFalse, PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PpPrintOutputType.ppPrintOutputSlides, MSCore.MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, "", includeProps, true, includeTags, true, pdfa, Type.Missing);
activePresentation.ExportAsFixedFormat(outputFile, PpFixedFormatType.ppFixedFormatTypePDF, quality, MSCore.MsoTriState.msoFalse, PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, printType, MSCore.MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, "", includeProps, true, includeTags, true, pdfa, Type.Missing);

// Determine if we need to make bookmarks
if ((bool)options["bookmarks"])
Expand Down Expand Up @@ -279,5 +286,48 @@ private static void loadBookmarks(Presentation activePresentation, ref List<PDFB
}
Converter.releaseCOMObject(slides);
}


// Return the PpPrintOutputType for a given option string
public static PpPrintOutputType getOutputType(string printType, ref bool valid)
{
valid = true;
switch (printType)
{
case "handout":
case "handouts":
case "handout1":
return PpPrintOutputType.ppPrintOutputOneSlideHandouts;
case "handout2":
case "handouts2":
return PpPrintOutputType.ppPrintOutputTwoSlideHandouts;
case "handout3":
case "handouts3":
return PpPrintOutputType.ppPrintOutputThreeSlideHandouts;
case "handout4":
case "handouts4":
return PpPrintOutputType.ppPrintOutputFourSlideHandouts;
case "handout6":
case "handouts6":
return PpPrintOutputType.ppPrintOutputSixSlideHandouts;
case "handout9":
case "handouts9":
return PpPrintOutputType.ppPrintOutputNineSlideHandouts;
case "notes":
return PpPrintOutputType.ppPrintOutputNotesPages;
case "slides":
return PpPrintOutputType.ppPrintOutputSlides;
case "outline":
return PpPrintOutputType.ppPrintOutputOutline;
case "build_slides":
case "buildslides":
case "build-slides":
return PpPrintOutputType.ppPrintOutputBuildSlides;
default:
valid = false;
break;
}
return PpPrintOutputType.ppPrintOutputSlides;
}
}
}
21 changes: 20 additions & 1 deletion OfficeToPDF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static void Main(string[] args)
options["word_no_repair"] = false;
options["original_filename"] = "";
options["original_basename"] = "";
options["powerpoint_output"] = "";
options["pdf_page_mode"] = null;
options["pdf_layout"] = null;
options["pdf_merge"] = (int) MergeMode.None;
Expand All @@ -143,7 +144,7 @@ static void Main(string[] args)
{ "excel_delay", "Excel delay milliseconds" }
};

Regex switches = new Regex(@"^/(version|hidden|markup|readonly|bookmarks|merge|noquit|print|screen|pdfa|template|writepassword|password|help|verbose|exclude(props|tags)|excel_(delay|max_rows|show_formulas|show_headings|auto_macros|template_macros|active_sheet|worksheet|no_recalculate|no_link_update)|word_(header_dist|footer_dist|ref_fonts|no_field_update|field_quick_update(_safe)?|max_pages|keep_history|no_repair)|pdf_(page_mode|append|prepend|layout|clean_meta|owner_pass|user_pass|restrict_(annotation|extraction|assembly|forms|modify|print|accessibility_extraction|full_quality))|working_dir|\?)$", RegexOptions.IgnoreCase);
Regex switches = new Regex(@"^/(version|hidden|markup|readonly|bookmarks|merge|noquit|print|screen|pdfa|template|writepassword|password|help|verbose|exclude(props|tags)|excel_(delay|max_rows|show_formulas|show_headings|auto_macros|template_macros|active_sheet|worksheet|no_recalculate|no_link_update)|powerpoint_(output)|word_(header_dist|footer_dist|ref_fonts|no_field_update|field_quick_update(_safe)?|max_pages|keep_history|no_repair)|pdf_(page_mode|append|prepend|layout|clean_meta|owner_pass|user_pass|restrict_(annotation|extraction|assembly|forms|modify|print|accessibility_extraction|full_quality))|working_dir|\?)$", RegexOptions.IgnoreCase);
for (int argIdx = 0; argIdx < args.Length; argIdx++)
{
string item = args[argIdx];
Expand Down Expand Up @@ -274,6 +275,21 @@ static void Main(string[] args)
argIdx++;
}
break;
case "powerpoint_output":
// Only accept the next option if there are enough options
if (argIdx + 2 < args.Length)
{
bool validOutputType = false;
PowerpointConverter.getOutputType(args[argIdx + 1], ref validOutputType);
if (!validOutputType)
{
Console.WriteLine("Invalid PowerPoint output type");
Environment.Exit((int)(ExitCode.Failed | ExitCode.InvalidArguments));
}
options["powerpoint_output"] = args[argIdx + 1];
argIdx++;
}
break;
case "working_dir":
// Allow for a local working directory where files are manipulated
if (argIdx + 2 < args.Length)
Expand Down Expand Up @@ -1011,6 +1027,9 @@ the file. Applies when converting with Excel.
/excel_no_recalculate - Skip automatic re-calculation of formulas in the workbook.
/excel_template_macros - Run Auto_Open macros in the /template document before conversion by Excel
/excel_worksheet <num> - Only convert worksheet <num> in the workbook. First sheet is 1
/powerpoint_output <type> - Controls what is generated by output. Possible values are slides, notes,
outline, build_slides, handouts and multi-page handouts using handout2,
handout3, handout4, handout6 and handout9. The default is slides.
/word_header_dist <pts> - The distance (in points) from the header to the top of
the page.
/word_footer_dist <pts> - The distance (in points) from the footer to the bottom
Expand Down
4 changes: 2 additions & 2 deletions OfficeToPDF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.13.0")]
[assembly: AssemblyFileVersion("1.8.13.0")]
[assembly: AssemblyVersion("1.8.14.0")]
[assembly: AssemblyFileVersion("1.8.14.0")]
3 changes: 3 additions & 0 deletions OfficeToPDF/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ The following optional switches can be used:
/excel_no_recalculate - skip automatic re-calculation of formulas in the workbook
/excel_template_macros - run Auto_Open macros in the /template document before conversion by Excel
/excel_worksheet <num> - only convert worksheet <num> in the workbook. First sheet is 1
/powerpoint_output <type> - controls what is generated by output. Possible values are slides, notes,
outline, build_slides, handouts and multi-page handouts using handout2,
handout3, handout4, handout6 and handout9. The default is slides
/word_header_dist <pts> - the distance (in points) from the header to the top of
the page
/word_footer_dist <pts> - the distance (in points) from the footer to the bottom
Expand Down

0 comments on commit 2eba29b

Please sign in to comment.