我如何将picture_Box中的图像保存为.pdf文件 [英] How I save an image from picture_Box as .pdf file
问题描述
我使用此代码扫描扫描仪中的图像:
***************************** ************************
尝试
RasterCodecs.Startup()
Me.TwainSession = New TwainSession
Me.TwainSession.Startup(Me,Scan Technologies,Inc。, Abdulla Scanner .NET,版本16,Abdulla Twain测试样本,TwainStartupFlags.None)
Me.TwainSession.ShowProgressIndicator(True)
Me.Text = TwainSession.SelectedSourceName
Catch ex As Exception
MsgBox(ex.Message,MsgBoxStyle.Exclamation, 错误)
结束尝试
*********
Private Sub TwainSession_AcquirePage (ByVal sender As Object,ByVal e As Leadtools.Twain.TwainAcquirePageEventArgs)处理TwainSession.AcquirePage
尝试
如果Not IsNothing(e.Image)然后
PictureBox1.Image = Image.FromHbitmap(e.Image.ToHBitmap)
结束如果
Catch ex As Exception
MessageBox.Show(ex.Message,خطأ,MessageBoxButtons.OK,MessageBoxIcon.Error)
结束尝试
结束子
*************
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理Button1.Click
尝试
Me.TwainSession.Acquire(TwainUserInterfaceFlags.Show)
'------------ ----------------------------
Catch ex As Exception
MsgBox( ex.Message.ToString,MsgBoxStyle.Critical或MsgBoxStyle.MsgBoxRight + MsgBoxStyle.MsgBoxRtlReading,scan)
结束尝试
End Sub
*************** __________________________________________________
I尝试使用此代码,但它不起作用???
PictureBox1.Image.Save(C:&\ Img100.pdf,Imaging.ImageFormat.pdf)
你能帮我吗?
I use this code to scan image from scanner :
*****************************************************
Try
RasterCodecs.Startup()
Me.TwainSession = New TwainSession
Me.TwainSession.Startup(Me, "Scan Technologies, Inc.", "Abdulla Scanner .NET", "Version 16", "Abdulla Twain test sample", TwainStartupFlags.None)
Me.TwainSession.ShowProgressIndicator(True)
Me.Text = TwainSession.SelectedSourceName
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "error")
End Try
*********
Private Sub TwainSession_AcquirePage(ByVal sender As Object, ByVal e As Leadtools.Twain.TwainAcquirePageEventArgs) Handles TwainSession.AcquirePage
Try
If Not IsNothing(e.Image) Then
PictureBox1.Image = Image.FromHbitmap(e.Image.ToHBitmap)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
*************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Me.TwainSession.Acquire(TwainUserInterfaceFlags.Show)
'----------------------------------------
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.Critical Or MsgBoxStyle.MsgBoxRight + MsgBoxStyle.MsgBoxRtlReading, "scan")
End Try
End Sub
***************__________________________________________________
I try to use this code but it is not working???
PictureBox1.Image.Save("C:" & "\Img100.pdf", Imaging.ImageFormat.pdf)
can you help me?
推荐答案
这是一套不完整的PDF库参考资料你可以使用: http://csharp-source.net/open-source/pdf-libraries 。
-SA
This is an incomplete set of references to PDF libraries you can use: http://csharp-source.net/open-source/pdf-libraries.
—SA
嗯... ImageFormat.pdf不是ImageFormat类的成员,所以你在哪里获得从哪?该代码甚至不会编译,更不用说工作了。你不能只是键入你想要作为类成员的任何旧扩展并期望它工作。
图像和位图类不知道如何以PDF格式保存图像格式。您必须使用第三方库(如PdfSharp)创建PDF文档并将图像插入到文档中。
Ummm... ImageFormat.pdf is not a member of the ImageFormat class so where did you get that from? That code won't even compile let alone work. You cannot just type any old extension you want as a class member and expect it to work.
The Image and Bitmap classes have no idea how to save an image in PDF format. You have to create a PDF document and insert your image into the document using a 3rd party library, like PdfSharp.
这篇关于我如何将picture_Box中的图像保存为.pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!