We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DocIO to PDF?

Can a DocIO document be saved as a PDF? or Syncfusion.PDF import a DocIO and save as a PDF?


1 Reply

BP Bhuvaneswari P Syncfusion Team September 9, 2008 08:44 AM UTC

Hi Dima,

Thank you for your interest in Syncfusion products.

Doc to PDF

We don't have direct option to convert from Doc to PDF. But we have implemented new conversion from doc to HTML in our Volume 3

release (Beta will be available by tomorrow). Through this we can workaround for Doc to PDF. Already we have support for HTML to

PDF. So doc to PDF can be achieved by convert the specific doc to HTML and then convert HTML to PDF.

Code snippet for doc to HTML

'Open the document to convert from word to HTML
Dim doc1 As WordDocument = New WordDocument(textBox1.Text)
Dim htmlExport As HTMLExport = New HTMLExport()
'Export the doc to HTML and save as .html file
strHtml = Application.StartupPath & "doctohtml_res.html"
doc1.SaveOptions.HtmlExportImagesFolder = Application.StartupPath
htmlExport.SaveAsXhtml(doc1, strHtml)

Code snippet for HTML to PDF

Using html As HtmlConverter = New HtmlConverter()
Using img As Image = html.ConvertToImage(strHtml, ImageType.Metafile, CInt(Fix(width)), -1, dimension)
Dim metafile As PdfMetafile = CType(PdfImage.FromImage(img), PdfMetafile)
Dim format As PdfMetafileLayoutFormat = New PdfMetafileLayoutFormat()
format.Break = PdfLayoutBreakType.FitPage
format.Layout = PdfLayoutType.Paginate
pdf.PageSettings.Height = img.Height
format.SplitTextLines = False
metafile.Draw(page, New RectangleF(0, 0, pageSize.Width, -1), format)
End Using
End Using

Here is the sample for your reference:

http://websamples.syncfusion.com/samples/DocIO.Windows/P47690/main.htm


Here is the dll to test this issue:

http://www.syncfusion.com/development/uploads/Doc_Pdf_Dlls_28f2c87e.zip


Please add the below assemblies before run the sample:
1. AxSHDocVw.dll
2. SHDocVw.dll
3. Syncfusion.DocIO.Base.dll
4. Syncfusion.Core.dll
5. Syncfusion.Compression.Base.dll
6. syncfusion.htmlconverter.base.dll
7. syncfusion.pdf.base.dll

Note: we do have only limited support for doc to HTML. Not all the elements are converted to HTML page.

Please try this and let us know if this helps you.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon