how can I convert pdf file to word file using vb.net - vb.net

I'm trying to develop a program which allows the user to convert a pdf file to a word file using vb.net.
Is there any good API for this ?
And, is it as easy as it looks like?

try this,
' Path of input PDF document
Dim filePath As String = "d:\\Source.pdf"
' Instantiate the Document object
Dim document As Aspose.Pdf.Document = New Aspose.Pdf.Document(filePath)
' Create DocSaveOptions object
Dim saveOptions As DocSaveOptions = New DocSaveOptions()
' Set the recognition mode as Flow
saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow
' Set the Horizontal proximity as 2.5
saveOptions.RelativeHorizontalProximity = 2.5F
' Enable the value to recognize bullets during conversion process
saveOptions.RecognizeBullets = True
' save the resultnat DOC file
document.Save("d:\\Resultant.doc", saveOptions)

Related

How to display a word document in WebBrowser control in Windows Form Application using vb.net?

I created an application which can load a pdf document and then converted it into docx file using aspose.dll library. Lastly, it will display the docx file in WebBrowser control in the windows form application.
This is the code snippet for pdf to word docx conversion.
Dim filePath As String = txtPath.Text
' Dim pdfDocx As Aspose.Pdf.Document = New Aspose.Pdf.Document(filePath)
'open pdf document
Dim pdfDocument As Document = New Document(filePath)
' instantiate DocSaveOptions object
Dim saveOptions As DocSaveOptions = New DocSaveOptions()
' specify the output format as DOCX
Try
saveOptions.Format = DocSaveOptions.DocFormat.DocX
' save document in docx format
pdfDocument.Save("output.docx", saveOptions)
MsgBox("sUCCESS")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
The saveoptions succeed but now I want to display it in WebBrowser control. How can I do this? Thanks

Cannot find bookmarks from OpenXML appended document

using the following code snippet I open a document template (DOTX) and then append another document. Both have bookmarks.
Dim m_word As WordprocessingDocument = = WordprocessingDocument.Open("FrontPage.dotx", True)
Dim altChunkId As String = "ChunkId1"
Dim mainPart As MainDocumentPart = m_word.MainDocumentPart
Dim chunk As AlternativeFormatImportPart = mainPart.AddAlternativeFormatImportPart(
DocumentFormat.OpenXml.Packaging.AlternativeFormatImportPartType.WordprocessingML, altChunkId)
Using fileStream As IO.FileStream = IO.File.Open("Appendix.dotx", IO.FileMode.Open)
chunk.FeedData(fileStream)
End Using
Dim altChunk As AltChunk = New DocumentFormat.OpenXml.Wordprocessing.AltChunk()
altChunk.Id = altChunkId
mainPart.Document.Body.InsertAfter(altChunk, mainPart.Document.Body.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Paragraph).Last())
mainPart.Document.Save()
Now if I try to loop trough all bookmarks like this:
Dim docbody As Body = doc.GetFirstChild(Of Body)()
For Each bookmarkStart As BookmarkStart In docbody.Descendants(Of BookmarkStart)()
' Do something with the bookmarks
Next
I only get the bookmarks of the original frontpage.dotx, none of the bookmarks of the appendix.dotx is found.
If I save the document to a file, all the bookmarks are there when I open it using Word. I can also reopen the saved file i C# and then all bookmarks can be found using the above For Each loop. The question is, how can I get all the bookmarks after appending without saving and reloading the document?
When you use AltChunk to embed a document the entire file is embedded into the document - it's NOT integrated. That only happens when the combined document is opened by Word. If you need to work through all the bookmarks you need to either
Open each document, do the bookmarks, and THEN combine the two using AltChunk OR
Not use AltChunk to combine the documents, and transfer the second document part-by-part into the first document.

vb.net How to save File as Word & Open Office Document?

I have a small programm and i want to save the File so i can read them later into when i open it.
How can i now save the File cause i must save 5 Variables and read them back into the Tool and if its possible i want to use the File in Word or OpenOffice too.
My Variables
Title - Pieces- SinglePrice- Totalprice
Please give me Examples for the Point in the right way.
Thanks everyone!
If all you want to do is store four variables from your program in a file that can also be read by Word and OpenOffice, you can do that easily enough with a text file. The following code assumes that Title is a String, Pieces is an Integer, SinglePrice and TotalPrice are Decimal.
Dim folder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments
Dim saveFile As String = System.IO.Path.Combine(folder, "Save.txt")
Dim vars() As String = {Title, Pieces.ToString, SinglePrice.ToString, TotalPrice.ToString}
System.IO.File.WriteAllLines(saveFile, vars)
If you need to read the file to restore the values of the variables, you can do it like this. Note that this code assumes that the file was written by the first snippet of code, otherwise it would be necessary to validate the contaents of the file before using it.
Dim folder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments
Dim saveFile As String = System.IO.Path.Combine(folder, "Save.txt")
Dim vars() As String = System.IO.File.ReadAllLines(saveFile)
Title = vars(0)
Pieces = CInt(vars(1))
SinglePrice = CDec(vars(2))
TotalPrice = CDec(vars(3))

How can I add watermark from Textbox to taken picture?

How can I put the text from a TextBox on captured images ?
Is it possible to implement it to code from:
Vb app code
You can easily do it using Bytescout.Watermarking SDK for .NET
Here's an example of code `Imports System.Diagnostics
Imports Bytescout.Watermarking
Imports Bytescout.Watermarking.Presets
Module Module1
Sub Main()
' Create new watermarker
Dim waterMarker As New Watermarker()
' Create new preset
Dim preset As New TextFitsPage()
' Create new string
Dim inputFilePath As String
' Create new string
Dim outputFilePath As String
' Set input file path
inputFilePath = "my_sample_image.jpg" '<-- place your captured image here
' Set output file path
outputFilePath = "my_sample_output.jpg"
' Initialize library
waterMarker.InitLibrary("demo", "demo")
' Add image to apply watermarks to
waterMarker.AddInputFile(inputFilePath, outputFilePath)
' Set preset text
preset.Text = "Bytescout Watermarking" '<-- place your textbox.text here
' Add watermark to watermarker
waterMarker.AddWatermark(preset)
' Set output directory
waterMarker.OutputOptions.OutputDirectory = "."
' Apply watermarks
waterMarker.Execute()
' Open generated image file in default image viewer installed in Windows
Process.Start(outputFilePath)
End Sub
End Module`
Source: how to add a simple transparent watermark

Manipulate visio shapes with data passed from vb.net

I have the below code which is opening visio, opening a file in visio, printing the file and then closing; this all works fine.
However, now my task is to pass information over to the visio document page called 'Ticket Task', bind that information to some shapes and then print it.
I know this is possible with vb6 (that is what the outdated code is written in), however is there a way to do this in vb.net?
Thanks!
Code:
''Set up the file path
Dim docPath As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\" + splFileData(0) + "\" + splFileData(1) + ".vsd"
'Set up the attributes for the opening/printing of the document.
psi.UseShellExecute = True
psi.Verb = "print"
'psi.EnvironmentVariables.Add("Orders", "Hello")
psi.Arguments = printer
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = docPath
Console.WriteLine("Printing: " + docPath)
'Start the process (open visio document, print, close)
Process.Start(psi)
You'll have to change the way you're opening and printing Visio documents. This tutorial shows how to use VB.NET to work with documents. The Open function returns an object of type Microsoft.Office.Interop.Visio.Document. You can use this object to attach information to shapes as discussed in here. In fact, the VB.NET code is very similar to VB6. If you want Visio to be invisible, you can open the document as follows:
Microsoft.Office.Interop.Visio.InvisibleApp application = new Microsoft.Office.Interop.Visio.InvisibleApp();
application.Visible = false;
Microsoft.Office.Interop.Visio.Document doc = application.Documents.Open...