Universal Document Converter
Información general
Descargas
Comprar
Tutoriales
Desarrolladores
Soporte técnico
Acerca de fCoder SIA


      Búsqueda en el sitio
   


      Conversiones populares
Adobe PDF a JPEG
Word Document a PDF
Hojas de cálculo Excel a PDF
PowerPoint a JPEG
Diseño Visio a PDF
Diseño AutoCAD a TIFF
Página web a JPEG
Convertir de cálculo Excel a PDF
Convertir DjVu a PDF
Convertir una página web a PDF

      Tutorial de vídeo
Ver el tutorial



Página principal>Developer Solutions>Examples>Visual Basic.NET>Word Documents to PDF

Converting Word Documents to PDF


'----------------------------------------------------------------------
' 1) Microsoft Word 97 or above should be installed and activated on your PC.
'
' 2) Universal Document Converter 5.2 or above should be installed, too.
'
' 3) Open your project in Microsoft Visual Basic.NET.
'
' 4) In Visual Basic main menu press "Project->Add Reference...".
'
' 5) In "Add Reference" window go to "COM" tab and double click into
'    "Universal Document Converter Type Library".
'----------------------------------------------------------------------

Private Sub PrintWordToPDF(ByVal strFilePath As String)

  Dim objUDC As UDC.IUDC
  Dim itfPrinter As UDC.IUDCPrinter
  Dim itfProfile As UDC.IProfile

  Dim WordApp As Object
  Dim WordDoc As Object

  objUDC = New UDC.APIWrapper
  itfPrinter = objUDC.Printers("Universal Document Converter")
  itfProfile = itfPrinter.Profile

' Use Universal Document Converter API to change settings of converterd document
  itfProfile.PageSetup.ResolutionX = 600
  itfProfile.PageSetup.ResolutionY = 600

  itfProfile.FileFormat.ActualFormat = UDC.FormatID.FMT_PDF

  itfProfile.FileFormat.PDF.ColorSpace = UDC.ColorSpaceID.CS_TRUECOLOR
  itfProfile.FileFormat.PDF.Multipage = UDC.MultipageModeID.MM_MULTI

  itfProfile.OutputLocation.Mode = UDC.LocationModeID.LM_PREDEFINED
  itfProfile.OutputLocation.FolderPath = "C:\Out"
  itfProfile.OutputLocation.FileName = "&[DocName(0)] -- &[Date(0)] -- &[Time(0)].&[ImageType]"
  itfProfile.OutputLocation.OverwriteExistingFile = False

' Run Microsoft Word as COM-server
  WordApp = CreateObject("Word.Application")

' Open document from file
  WordDoc = WordApp.Documents.Open(strFilePath, , 1)

' Print all pages of the document
  WordApp.ActivePrinter = "Universal Document Converter"
  Call WordApp.PrintOut(False)

' Close the document
  Call WordDoc.Close()
  WordDoc = Nothing

' Close Microsoft Word
  Call WordApp.Quit()
  WordApp = Nothing

End Sub



© 2001-2017 fCoder SIA Acerca de fCoder SIA | Mapa del sitio