Discussion about the Way to Convert Word to PDF with VB.NET
We can find that
most splendid papers are showed online with PDF format. In order to avoid papers
to editing by others and protect the copyright, authors may require that the
papers are displayed as PDF format before sending it to internet. If the author
uses Microsoft Word to write papers originally, he or she needs to convert Word to
PDF. So, I want to
discuss something about the conversion between Word and PDF.
For common
users, they can use converters to convert Word to PDF. At present, more and more
converters provided online. Even, some are free to download. Because of these
converters, it becomes more convenient to convert Word to PDF. However, we need
to wait a little long time for convert a large amount of documents.
For
developers, they often use C# or VB.Net to realize conversion. Also, we can find
many materials about the methods. But we need to choose the most appropriate
method according to the different requirements.
Because we should convert
Word to PDF, so it seems that Word is the essential tool when converting.
However, if we can’t install Microsoft Word on the system, is it possible to
convert Word to PDF with
VB.NET? Of course yes.
The following code will show you the method to convert Word to PDF without Word
being installed.
'Create word document
Dim document As New
Document()
Dim section As Section =
document.AddSection()
section.PageSetup.PageSize =
PageSize.A4
section.PageSetup.Margins.Top =
72.0F
section.PageSetup.Margins.Bottom =
72.0F
section.PageSetup.Margins.Left =
89.85F
section.PageSetup.Margins.Right = 89.85F
Dim paragraph As
Paragraph = section.AddParagraph()
paragraph.Format.HorizontalAlignment
Spire.Doc.Documents.HorizontalAlignment.Left
paragraph.AppendPicture(Image.FromFile("Word.png"))
Dim
p1 As String _
= "Microsoft Word is a word processor designed by
Microsoft."_
+ "It was first released in 1983 under the name Multi-Tool Word
for Xenix systems.
+ "Subsequent versions were later written for several
other platforms including"_
+ "IBM PCs running DOS (1983), the Apple
Macintosh (1984), the AT&T Unix PC (1985),"_
+ "Atari ST (1986), SCO
UNIX, OS/2, and Microsoft Windows (1989)."
Dim p2 As String _
=
"Microsoft Office Word instead of merely Microsoft Word."_
+ "The 2010
version appears to be branded as Microsoft Word,"_
+ "once again. The current
versions are Microsoft Word 2010 for Windows and 2008 for
Mac."
section.AddParagraph().AppendText(p1).CharacterFormat.FontSize =
14
section.AddParagraph().AppendText(p2).CharacterFormat.FontSize =
14
'Save doc file to pdf.
document.SaveToFile("Sample.pdf",
FileFormat.PDF)