I have a console application in VB. Today I'm using PDFsharp (http://www.pdfsharp.net/) to merge PDF files like this:
Private Sub mergePdfFiles(pdfFiles As String(), output As String)
Dim out As PdfDocument = New PdfDocument
Try
For Each file As String In pdfFiles
Dim inputDoc As PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(file,IO.PdfDocumentOpenMode.Import)
Dim count As Integer = inputDoc.PageCount
For idx As Integer = 0 To count - 1
Dim page As PdfPage = inputDoc.Pages(idx)
out.AddPage(page)
Next
Next
out.Save(output)
Catch ex As Exception
End Try
End Sub
This works fine. Now I want to convert DOCX files to PDF, but it seems that PDFsharp can't do it. I understand that MigraDoc can do it
MigraDoc Foundation the Open Source .NET library that easily creates documents based on an object model with paragraphs, tables, styles, etc. and renders them into PDF or RTF.
But I didn't manage to do it. The samples are not very clear and is for C#. http://www.pdfsharp.net/wiki/DocumentViewer-sample.ashx
For example:
//create RTF file From document
private void miRtf_Click(object sender, System.EventArgs e)
{
RtfDocumentRenderer rtf = new RtfDocumentRenderer();
rtf.Render(this.pagePreview.Document, "test.rtf", null);
Process.Start("test.rtf");
}
In VB I try with Me
instead of this
but I don't have pagePreview.
How can I convert DOCX files to PDF files in VB using MigraDoc or PDFsharp?