473,498 Members | 703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I am not able to convert multipage .doc file to .GIF

2 New Member
Hi

I have tried below code but its converting only one page of i.e starting page of .doc file to .gif file.

Is there is any solution to convert the multipage file to .GIF file...

Expand|Select|Wrap|Line Numbers
  1. And any thing wrong with below code....
  2. Dim objWord As New Microsoft.Office.Interop.Word.Application
  3.         Dim objDoc As Microsoft.Office.Interop.Word.Document
  4.  
  5.         Const CF_ENHMETAFILE As Integer = 14
  6.         objDoc = objWord.Documents.Open("D:\Guide.doc")
  7.  
  8.         objWord.ActiveDocument.Select()
  9.         objWord.Selection.CopyAsPicture()
  10.         'objDoc.SaveAs2("D:\Charge Back\test2.gif")
  11.  
  12.         Dim ip As IntPtr
  13.         Dim metaFile As System.Drawing.Imaging.Metafile
  14.         Dim bRet As Boolean
  15.         bRet = ClipboardAPI.OpenClipboard(Me.Handle)
  16.         If bRet = True Then
  17.             'Verify the clipboard contains data available
  18.             'as an enhanced metafile.
  19.             bRet = ClipboardAPI.IsClipboardFormatAvailable(CF_ENHMETAFILE) <> 0
  20.         End If
  21.  
  22.         If bRet = True Then
  23.             'Store the clipboard's contents in the IntPtr.
  24.             ip = ClipboardAPI.GetClipboardData(CF_ENHMETAFILE)
  25.         End If
  26.  
  27.         'Verify the IntPrt contains data before proceeding. Passing
  28.         'an empty IntPtr to System.Drawing.Imaging.Metafile results
  29.         'in an exception.
  30.         If Not IntPtr.Zero.Equals(ip) Then
  31.             metaFile = New System.Drawing.Imaging.Metafile(ip, True)
  32.             ClipboardAPI.CloseClipboard()
  33.             Dim image As System.Drawing.Image = metaFile
  34.             'Me.PictureBox1.Image = metaFile
  35.  
  36.             Dim objImageWriter As Image = New Bitmap(image.Width, image.Height)
  37.  
  38.             Dim objGraphics As Graphics = Graphics.FromImage(objImageWriter)
  39.  
  40.             objGraphics.Clear(Color.White)
  41.             'objGraphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  42.             objGraphics.DrawImage(image, 0, 0, image.Width, image.Height)
  43.  
  44.  
  45.             image.Dispose()
  46.             objGraphics.Dispose()
  47.  
  48.             Dim ep As Imaging.EncoderParameters = New Imaging.EncoderParameters
  49.             ep.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100)
  50.  
  51.             Dim codecs() As Imaging.ImageCodecInfo = Imaging.ImageCodecInfo.GetImageEncoders()
  52.             Dim iciInfo As Imaging.ImageCodecInfo
  53.             Dim item As Imaging.ImageCodecInfo
  54.             Dim frame As Integer
  55.             frame = 0
  56.             Dim page As Bitmap
  57.             page = Nothing
  58.             For Each item In codecs
  59.                 If (item.MimeType = "image/gif") Then iciInfo = item
  60.             Next
  61.             objImageWriter.Save("D:\doc.gif", iciInfo, ep)
  62.             'For i As Integer = 1 To objImageWriter.GetFrameCount(FrameDimension.Page) - 1
  63.             '    objImageWriter.SelectActiveFrame(FrameDimension.Page, i)
  64.             '    'mygif.Save("c:\test_" & i & ".gif")
  65.             '    objImageWriter.SaveAdd(objImageWriter, ep)
  66.             'Next
  67.             objImageWriter.Dispose()
Jun 27 '11 #1
0 1194

Sign in to post your reply or Sign up for a free account.

Similar topics

4
11541
by: abid | last post by:
I need to convert DBF file to a pipe delmited text file. Can somebody guide me with a sample C program that does this kind of conversion. Thanks, Abhi.
1
3814
by: Ashutosh | last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
1
4149
by: Mamatha | last post by:
Hi I am doing small application like video capturing,i had code to create avi file,but i want the same video file output in the form of wmv file format. How can we convert avi file to wmv file in...
1
5155
by: rama | last post by:
I need to convert excel file to txt file programatically which may contain 60000 records i want to convert it into txt file and upload it into unix server thanks in advance rama
3
1625
by: Kishore | last post by:
1) Is there a way to convert a file (MPP format) into an XML document in ASP. Is there any relation with XMLSerializer class with this. Can we use this class to convert a file into an XML Document....
1
1055
by: Ira | last post by:
Are there any ways to save any multipage file in the PDF format in VB.net?
3
25892
by: rojavenkat81 | last post by:
Hi All, Please help me regarding php program for convert video file to .flv file. I searched in many sites but i got only tool to convert video file to .flv file.But I want convert...
2
4771
kamill
by: kamill | last post by:
I need to convert excel file into PDF file using PHP, how can i do it. I am able to generate a pdf file. Is there any solution to export excel data into mysql database? I am waiting for help.
1
3675
by: sharmajavaforum | last post by:
Hai, I have a small task. I have an .HTML file. I wanted to convert .HTML file into a plain .txt file. Means after i convert the file, the .txt file should contain only the text rather ...
32
10892
by: poolboi | last post by:
hi guys, i've read a lot of thread of converting excel data into CSV files. however, i need a perl script to convert CSV file into excel file now, if required modules is needed, it would be...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.