VB.NET PDF: How to HTML5 PDF Viewer & Editor PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Create PDF from Text
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Create PDF from Text

VB.NET PDF - Create PDF from Text in C#.NET


Empower VB.NET Users to Create PDF File from Text Using Visual Basic .NET Demo Code




Best VB.NET adobe text to PDF converter library for Visual Studio .NET project


Batch convert editable & searchable PDF document from TXT formats in VB.NET class


Able to copy and paste all text content from .txt file to PDF file by keeping original layout


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Create PDF document from text file in .NET WinForms application and ASP.NET webpage


Able to convert plain text to various fonts, colors and sizes of text content in PDF


Free SDK component built in .NET framework


Online evaluation source code for VB.NET class




VB.NET Project: Necessary DLLs for Conversion from Text to PDF



Integrate following RasterEdge text to PDF converter SDK dlls into your VB.NET project assemblies;



  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.DICOM.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.JBIG2.dll


  RasterEdge.Imaging.JPEG2000.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Converter.dll


  RasterEdge.XDoc.Excel.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.XDoc.PDF.dll


  RasterEdge.XDoc.PowerPoint.dll


  RasterEdge.XDoc.TIFF.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.AdvancedCleanup.Core.dll


  RasterEdge.XImage.OCR.dll


  RasterEdge.XImage.OCR.Tesseract.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


    using RasterEdge.Imaging.Basic;


    using RasterEdge.XDoc.Converter;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




How to VB.NET: Use Text to PDF Converter Library DLLs



VB.NET demo code for creating PDF document from .txt format



'.txt convert to pdf(file to file)
Dim inputFilePath As String = "C:\dmeo.txt"
Dim outputFilePath As String = "C:\output.pdf"
DocumentConverter.ToDocument(inputFilePath, outputFilePath, FileType.DOC_PDF)



'.txt convert to pdf(stream to stream)
Dim inputFilePath As String = "C:\dmeo.txt"
Dim stream As Stream = File.Open(inputFilePath, FileMode.Open)
Dim outputStream As MemoryStream = New MemoryStream()
DocumentConverter.ToDocument(stream, outputStream, FileType.DOC_PDF)





How to VB.NET: Convert two or multiple text files to PDF(batch convert)



Following demo codes will show how to convert text files to pdf documents.



Dim inputDirectory As String = "C:\input\"
Dim outputDirectory As String = "C:\Output\"
Dim files() As String = Directory.GetFiles(inputDirectory, "*.txt")

'convert .txt document to pdf one by one.
For Each filePath As String In  files
       Dim startIdx As Integer = filePath.LastIndexOf("\")
       Dim endIdx As Integer = filePath.LastIndexOf(".")
       Dim docName As String = filePath.SubString(startIdx + 1, endIdx - startIdx - 1)
       ' Convert it to PDF document.
       DocumentConverter.ToDocument(filePath, outputDirectory + docName + ".pdf", FileType.DOC_PDF)
Next





How to VB.NET: Combine multiple Text files, and convert to PDF



Following is VB.NET demo code for text files to PDF conversion.



Dim files() As String = { "C:\demo1.txt, C:\demo2.txt, C:\demo3.txt" }
Dim outputFilePath As String = "C:\output.pdf"
Dim streams As List(Of MemoryStream) = New List(Of MemoryStream)()
For Each filePath As String In  files
       Dim inputStream As FileStream = File.Open(filePath, FileMode.Open)
       Dim outputStream As MemoryStream = New MemoryStream()
       ' Convert it to PDF document.
       DocumentConverter.ConvertToDocument(inputStream, outputStream, FileType.DOC_PDF)
       streams.Add(outputStream)
       inputStream.Close()
Next
PDFDocument.CombineDocument(streams, outputFilePath)





How to VB.NET: Insert Text file into pdf document, and create a new PDF file



Following is VB.NET demo code to Insert .txt file to PDF at specific location.



Dim filePath As String = "C:\demo.txt"
Dim inputStream As Stream = File.Open(filePath, FileMode.Open)
Dim stream As MemoryStream = New MemoryStream()
DocumentConverter.ToDocument(inputStream, stream, FileType.DOC_PDF)
Dim pdf As PDFDocument = New PDFDocument(stream)
Dim pageCount As Integer = pdf.GetPageCount()
Dim pages List(Of BasePage) = New List(Of BasePage)() 
For i As Integer = 0 To pageCount - 1
       pages.Add(pdf.GetPage(i))
Next
Dim outputPdf As String = "C:\output.pdf"
Dim desDoc As PDFDocument = New PDFDocument(outputPdf)
Dim insertLocation As Integer = 2
desDoc.InsertPages(pages.ToArray(), insertLocation)
desDoc.Save("C:\desDocument.pdf")