Skip to content

Instantly share code, notes, and snippets.

@cpereira7
Last active November 4, 2017 19:44
Show Gist options
  • Select an option

  • Save cpereira7/ef019e72fc50934d9dffe3b9dab77594 to your computer and use it in GitHub Desktop.

Select an option

Save cpereira7/ef019e72fc50934d9dffe3b9dab77594 to your computer and use it in GitHub Desktop.
Guardar documentos docx em pdf
private void ExportPDF(string nome)
{
var wordApp = new Microsoft.Office.Interop.Word.Application();
var wordDocument = wordApp.Documents.Open(nome);
wordDocument.Save();
wordDocument.ExportAsFixedFormat(nome.Replace("docx", "pdf"), Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
wordDocument.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges,
Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat,
false);
wordApp.Quit();
Console.WriteLine(nome);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment