本文整理汇总了C#中Microsoft.Office.Interop.Word.Document.ExportAsFixedFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ExportAsFixedFormat方法的具体用法?C# Document.ExportAsFixedFormat怎么用?C# Document.ExportAsFixedFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Word.Document
的用法示例。
在下文中一共展示了Document.ExportAsFixedFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public override void Convert(String inputFile, String outputFile)
{
Object nothing = System.Reflection.Missing.Value;
try
{
if (!File.Exists(inputFile))
{
throw new ConvertException("File not Exists");
}
if (IsPasswordProtected(inputFile))
{
throw new ConvertException("Password Exist");
}
app = new Word.Application();
docs = app.Documents;
doc = docs.Open(inputFile, false, true, false, nothing, nothing, true, nothing, nothing, nothing, nothing, false, false, nothing, true, nothing);
doc.ExportAsFixedFormat(outputFile, Word.WdExportFormat.wdExportFormatPDF, false, Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument, 1, 1, Word.WdExportItem.wdExportDocumentContent, false, false, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, false, false, nothing);
}
catch (Exception e)
{
release();
throw new ConvertException(e.Message);
}
release();
}
示例2: datosaword2
//.........这里部分代码省略.........
string caadenadireccion = "", cadenaanterior = "";
if (c1.datocampo == null)
{
s.TextFrame.TextRange.Text = "";
}
else
{
if (c1.datocampo.Contains("|"))
{
separadordireccion = c1.datocampo.Split(new string[] { "|" }, StringSplitOptions.None);
foreach (string str in separadordireccion)
{
if (caadenadireccion == "")
{
cadenaanterior = str.Remove(0, 4);
caadenadireccion = cadenaanterior;
}
else
caadenadireccion = caadenadireccion + "\n" + str.Remove(0, 1);
}
}
else
{
if (c1.datocampo == "")
caadenadireccion = "";
else
caadenadireccion = c1.datocampo.Remove(0, 4);
}
s.TextFrame.TextRange.Text = caadenadireccion;
}
bandera = true;
break;
}
else
{
s.TextFrame.TextRange.Text = c1.datocampo;
bandera = true;
break;
}
}
else
{
s.TextFrame.TextRange.Text = c1.datocampo;
bandera = true;
break;
}
}
}
if (bandera)
continue;
if (s.TextFrame.TextRange.Text.Contains("PALLET"))
{
if (cbx_PAQUETE.Checked)
{
if (etq.IdiomaETQ == 2)
s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PACKAGE");
if (etq.IdiomaETQ == 1)
s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PAQUETE");
}
continue;
}
}
}
foreach (CamposCodigos cmp in ListaCodigosBaseDeDatos)
{
string nombrecampo = cmp.nombrecodigo.Replace("bcd", "txt");
foreach (Campos camps in ListaFinal)
{
if (camps.nombrecampo == nombrecampo)
{
CampoCodigo.nombrecodigo = cmp.nombrecodigo;
CampoCodigo.datocodigo = camps.datocampo;
CampoCodigo.tipocodigo = cmp.tipocodigo;
ListaCodigos.Add(CampoCodigo);
continue;
}
}
}
insertarCodigosDeBarraAWord(doc);
if (File.Exists(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"))
File.Delete((@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"));
doc.ExportAsFixedFormat(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf", Word.WdExportFormat.wdExportFormatPDF,
OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForPrint,
BitmapMissingFonts: true, DocStructureTags: false);
doc.SaveAs2(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
doc.Saved = true;
((Microsoft.Office.Interop.Word._Document)doc).Close();
((Microsoft.Office.Interop.Word._Application)appWord).Quit();
File.Delete(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
File.Delete(@rutasEnModAdmin.RutaDeTemp + "/Etq_" + TipyVarEtqs.Key.ToString() + "_" + TipyVarEtqs.Value.ToString() + ".docx");
ContadorEtiquetas++;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.matarProcesosWordExcel();
}
}
示例3: _Search
private void _Search(List<string> pathToFile, string stringToSearch, string pathToSave = null)
{
logger.Info("Clean the return List of coincidences");
FileInfo.Clear();
logger.Info("initializing paramenter objects");
object oMissing = System.Reflection.Missing.Value;
object oTrue = true;
object oFalse = false;
try
{
logger.Info("instantiating word app");
word = new Word.Application();
logger.Info("instantiating document of word app");
doc = new Word.Document();
logger.Info("reading each files on path ={0}", pathToFile);
foreach (string item in pathToFile)
{
object fileName = item;
logger.Info("opening the file");
doc = word.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
doc.Activate();
logger.Info("file opened and activates");
FileInfo fiIn = new FileInfo();
fiIn.FileName = item;
fiIn.FileNameOut = string.Format(@"{0}\{1}.pdf", pathToSave, Guid.NewGuid().ToString());
logger.Info("searching the text on each paragraphs");
foreach (Word.Paragraph Paragraph in doc.Paragraphs)
{
Word.Range rng = Paragraph.Range;
rng.Find.Text = stringToSearch.Trim();
rng.Find.ClearFormatting();
rng.Find.Forward = true;
rng.Find.Replacement.ClearFormatting();
rng.Find.Wrap = Word.WdFindWrap.wdFindStop;
rng.Find.Execute(
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
while (rng.Find.Found)
{
rng.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkYellow;
rng.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdWhite;
MatchesInfo maIn = new MatchesInfo();
maIn.Page = (int)rng.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndAdjustedPageNumber);
maIn.Line = (int)rng.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterLineNumber);
fiIn.MatchesList.Add(maIn);
logger.Info("text matching and highlight");
rng.Find.Execute(
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
}
FileInfo.Add(fiIn);
if (!string.IsNullOrEmpty(pathToSave))
{
logger.Info("exporting the file");
doc.ExportAsFixedFormat(
fiIn.FileNameOut,
Word.WdExportFormat.wdExportFormatPDF,
OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
BitmapMissingFonts: true, DocStructureTags: false);
logger.Info("file exported");
}
object saveOption = Word.WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
((Word._Document)doc).Close(ref saveOption, ref originalFormat, ref routeDocument);
}
}
catch (Exception ex)
{
//TODO: Manipular errores;
logger.Info("An exception has detected");
logger.Error(ex);
throw new Exception("");
throw;
}
finally
{
((Word._Application)word).Quit(ref oFalse, ref oMissing, ref oMissing);
}
}
示例4: datosaword
//.........这里部分代码省略.........
if (caadenadireccion == "")
{
cadenaanterior = str.Remove(0,4);
caadenadireccion = cadenaanterior;
}
else
caadenadireccion = caadenadireccion + "\n" + str.Remove(0,1);
}
}
else
{
if (c1.datocampo == "")
caadenadireccion = "";
else
caadenadireccion = c1.datocampo.Remove(0,4);
}
s.TextFrame.TextRange.Text = caadenadireccion;
}
bandera = true;
break;
}
else
{
if (s.Name == "txtPRODUCTCODE" || s.Name == "txtORDERNO")
{
if (c1.datocampo.Length > 29)
s.TextFrame.TextRange.Font.Size = s.TextFrame.TextRange.Font.Size - 10;
if (c1.datocampo.Length > 34)
s.TextFrame.TextRange.Font.Size = s.TextFrame.TextRange.Font.Size - 10;
if (c1.datocampo.Length > 41)
s.TextFrame.TextRange.Font.Size = s.TextFrame.TextRange.Font.Size - 5;
if (c1.datocampo.Length > 70)
s.TextFrame.TextRange.Font.Size = s.TextFrame.TextRange.Font.Size - 5;
}
s.TextFrame.TextRange.Text = c1.datocampo;
bandera = true;
break;
}
}
else
{
s.TextFrame.TextRange.Text = c1.datocampo;
bandera = true;
break;
}
}
}
if (bandera)
continue;
if (s.TextFrame.TextRange.Text.Contains("PALLET"))
{
if (cbx_PAQUETE.Checked)
{
if (etq.IdiomaETQ == 2)
s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PACKAGE");
if (etq.IdiomaETQ == 1)
s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PAQUETE");
}
continue;
}
}
}
foreach (CamposCodigos cmp in ListaCodigosBaseDeDatos)
{
string nombrecampo = cmp.nombrecodigo.Replace("bcd", "txt");
foreach (Campos camps in ListaFinal)
{
if (camps.nombrecampo == nombrecampo)
{
CampoCodigo.nombrecodigo = cmp.nombrecodigo;
CampoCodigo.datocodigo = camps.datocampo;
CampoCodigo.tipocodigo = cmp.tipocodigo;
ListaCodigos.Add(CampoCodigo);
continue;
}
}
}
insertarCodigosDeBarraAWord(doc);
if (File.Exists(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"))
File.Delete((@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"));
doc.ExportAsFixedFormat(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf", Word.WdExportFormat.wdExportFormatPDF,
OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForPrint,
BitmapMissingFonts: true, DocStructureTags: false);
doc.SaveAs2(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
doc.Saved = true;
((Microsoft.Office.Interop.Word._Document)doc).Close();
((Microsoft.Office.Interop.Word._Application)appWord).Quit();
File.Delete(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
File.Delete(@rutasEnModAdmin.RutaDeTemp + "/Etq_" + TipyVarEtqs.Key.ToString() + "_" + TipyVarEtqs.Value.ToString() + ".docx");
ContadorEtiquetas++;
//}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.matarProcesosWordExcel();
}
}