Skip to content

Commit

Permalink
[workitem#43] - allow for quick field update
Browse files Browse the repository at this point in the history
  • Loading branch information
vittala committed Aug 30, 2016
1 parent 3350e15 commit 7cbb674
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion OfficeToPDF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static void Main(string[] args)
options["excel_active_sheet"] = false;
options["excel_max_rows"] = (int) 0;
options["excel_worksheet"] = (int) 0;
options["word_field_quick_update"] = false;
options["word_no_field_update"] = false;
options["word_header_dist"] = (float) -1;
options["word_footer_dist"] = (float) -1;
Expand All @@ -118,7 +119,7 @@ static void Main(string[] args)
options["pdf_restrict_accessibility_extraction"] = false;
options["pdf_restrict_full_quality"] = false;

Regex switches = new Regex(@"^/(version|hidden|markup|readonly|bookmarks|merge|noquit|print|screen|pdfa|template|writepassword|password|help|verbose|exclude(props|tags)|excel_(max_rows|show_formulas|show_headings|auto_macros|active_sheet|worksheet)|word_(header_dist|footer_dist|ref_fonts|no_field_update)|pdf_(page_mode|append|prepend|layout|clean_meta|owner_pass|user_pass|restrict_(annotation|extraction|assembly|forms|modify|print|accessibility_extraction|full_quality))|\?)$", 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_(max_rows|show_formulas|show_headings|auto_macros|active_sheet|worksheet)|word_(header_dist|footer_dist|ref_fonts|no_field_update|field_quick_update)|pdf_(page_mode|append|prepend|layout|clean_meta|owner_pass|user_pass|restrict_(annotation|extraction|assembly|forms|modify|print|accessibility_extraction|full_quality))|\?)$", RegexOptions.IgnoreCase);
for (int argIdx = 0; argIdx < args.Length; argIdx++)
{
string item = args[argIdx];
Expand Down Expand Up @@ -795,6 +796,7 @@ the file. Applies when converting with Excel.
the page.
/word_footer_dist <pts> - The distance (in points) from the footer to the bottom
of the page.
/word_field_quick_update - Perform a fast update of fields in Word before conversion.
/word_no_field_update - Do not update fields when creating the PDF.
/word_ref_fonts - When fonts are not available, a reference to the font is used in
the generated PDF rather than a bitmapped version. The default is
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.7.6.0")]
[assembly: AssemblyFileVersion("1.7.6.0")]
[assembly: AssemblyVersion("1.7.7.0")]
[assembly: AssemblyFileVersion("1.7.7.0")]
1 change: 1 addition & 0 deletions OfficeToPDF/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The following optional switches can be used:
the page
/word_footer_dist <pts> - the distance (in points) from the footer to the bottom
of the page
/word_field_quick_update - perform a fast update of fields in Word before conversion
/word_no_field_update - do not update fields when creating the PDF
/word_ref_fonts - when fonts are not available, a reference to the font is used in
the generated PDF rather than a bitmapped version. The default is
Expand Down
11 changes: 9 additions & 2 deletions OfficeToPDF/WordConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class WordConverter: Converter
// See if we have to update fields
if (!(Boolean)options["word_no_field_update"])
{
updateDocumentFields(doc, word, inputFile);
updateDocumentFields(doc, word, inputFile, options);
}

var pageSetup = doc.PageSetup;
Expand Down Expand Up @@ -318,8 +318,15 @@ class WordConverter: Converter
}
}

private static void updateDocumentFields(Document doc, Microsoft.Office.Interop.Word.Application word, String inputFile)
private static void updateDocumentFields(Document doc, Microsoft.Office.Interop.Word.Application word, String inputFile, Hashtable options)
{
if ((Boolean)options["word_field_quick_update"])
{
var fields = doc.Fields;
fields.Update();
Converter.releaseCOMObject(fields);
return;
}
// Update some of the field types in the document so the printed
// PDF looks correct. Skips some field types (such as ASK) that would
// create dialogs
Expand Down

0 comments on commit 7cbb674

Please sign in to comment.