diff --git a/App.config b/App.config
index 407086c..3cde61f 100644
--- a/App.config
+++ b/App.config
@@ -1,6 +1,14 @@
-
+
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
diff --git a/Form1.Designer.vb b/Form1.Designer.vb
index 7130494..200ac81 100644
--- a/Form1.Designer.vb
+++ b/Form1.Designer.vb
@@ -44,41 +44,46 @@ Partial Class Form1
'
'TextBox1
'
- Me.TextBox1.Location = New System.Drawing.Point(93, 12)
+ Me.TextBox1.Location = New System.Drawing.Point(186, 24)
+ Me.TextBox1.Margin = New System.Windows.Forms.Padding(6)
Me.TextBox1.Name = "TextBox1"
- Me.TextBox1.Size = New System.Drawing.Size(232, 21)
+ Me.TextBox1.Size = New System.Drawing.Size(460, 35)
Me.TextBox1.TabIndex = 0
'
'TextBox2
'
- Me.TextBox2.Location = New System.Drawing.Point(93, 39)
+ Me.TextBox2.Location = New System.Drawing.Point(186, 78)
+ Me.TextBox2.Margin = New System.Windows.Forms.Padding(6)
Me.TextBox2.Name = "TextBox2"
- Me.TextBox2.Size = New System.Drawing.Size(232, 21)
+ Me.TextBox2.Size = New System.Drawing.Size(460, 35)
Me.TextBox2.TabIndex = 1
'
'Button1
'
- Me.Button1.Location = New System.Drawing.Point(4, 11)
+ Me.Button1.Location = New System.Drawing.Point(8, 22)
+ Me.Button1.Margin = New System.Windows.Forms.Padding(6)
Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(73, 20)
+ Me.Button1.Size = New System.Drawing.Size(146, 40)
Me.Button1.TabIndex = 2
Me.Button1.Text = "图片文件夹"
Me.Button1.UseVisualStyleBackColor = True
'
'Button2
'
- Me.Button2.Location = New System.Drawing.Point(4, 39)
+ Me.Button2.Location = New System.Drawing.Point(8, 78)
+ Me.Button2.Margin = New System.Windows.Forms.Padding(6)
Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(73, 21)
+ Me.Button2.Size = New System.Drawing.Size(146, 42)
Me.Button2.TabIndex = 3
Me.Button2.Text = "输出文件"
Me.Button2.UseVisualStyleBackColor = True
'
'Conver
'
- Me.Conver.Location = New System.Drawing.Point(4, 66)
+ Me.Conver.Location = New System.Drawing.Point(8, 132)
+ Me.Conver.Margin = New System.Windows.Forms.Padding(6)
Me.Conver.Name = "Conver"
- Me.Conver.Size = New System.Drawing.Size(73, 32)
+ Me.Conver.Size = New System.Drawing.Size(146, 64)
Me.Conver.TabIndex = 4
Me.Conver.Text = "转换"
Me.Conver.UseVisualStyleBackColor = True
@@ -86,34 +91,39 @@ Partial Class Form1
'TrackBar1
'
Me.TrackBar1.Enabled = False
- Me.TrackBar1.Location = New System.Drawing.Point(4, 146)
+ Me.TrackBar1.Location = New System.Drawing.Point(8, 292)
+ Me.TrackBar1.Margin = New System.Windows.Forms.Padding(6)
Me.TrackBar1.Name = "TrackBar1"
- Me.TrackBar1.Size = New System.Drawing.Size(334, 45)
+ Me.TrackBar1.Size = New System.Drawing.Size(668, 90)
Me.TrackBar1.TabIndex = 5
'
'Label1
'
Me.Label1.AutoSize = True
- Me.Label1.Location = New System.Drawing.Point(91, 75)
+ Me.Label1.Location = New System.Drawing.Point(182, 150)
+ Me.Label1.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(47, 12)
+ Me.Label1.Size = New System.Drawing.Size(118, 24)
Me.Label1.TabIndex = 6
- Me.Label1.Text = "默认DPI"
+ Me.Label1.Text = "PDF压缩率"
'
'TextBox3
'
- Me.TextBox3.Location = New System.Drawing.Point(144, 72)
+ Me.TextBox3.Location = New System.Drawing.Point(312, 150)
+ Me.TextBox3.Margin = New System.Windows.Forms.Padding(6)
Me.TextBox3.Name = "TextBox3"
- Me.TextBox3.Size = New System.Drawing.Size(31, 21)
+ Me.TextBox3.Size = New System.Drawing.Size(58, 35)
Me.TextBox3.TabIndex = 7
- Me.TextBox3.Text = "72"
+ Me.TextBox3.Text = "0"
+ Me.ToolTip1.SetToolTip(Me.TextBox3, "0不用压缩(一般用这个,除非生成pdf特别大),大于等于100使用png压缩,数字无影响;小于100使用jpg压缩,压缩质量与数字挂钩")
'
'CheckBox1
'
Me.CheckBox1.AutoSize = True
- Me.CheckBox1.Location = New System.Drawing.Point(193, 75)
+ Me.CheckBox1.Location = New System.Drawing.Point(386, 150)
+ Me.CheckBox1.Margin = New System.Windows.Forms.Padding(6)
Me.CheckBox1.Name = "CheckBox1"
- Me.CheckBox1.Size = New System.Drawing.Size(132, 16)
+ Me.CheckBox1.Size = New System.Drawing.Size(258, 28)
Me.CheckBox1.TabIndex = 8
Me.CheckBox1.Text = "包括下一级子文件夹"
Me.CheckBox1.UseVisualStyleBackColor = True
@@ -122,9 +132,11 @@ Partial Class Form1
'
Me.GroupBox1.Controls.Add(Me.RadioButton2)
Me.GroupBox1.Controls.Add(Me.RadioButton1)
- Me.GroupBox1.Location = New System.Drawing.Point(12, 104)
+ Me.GroupBox1.Location = New System.Drawing.Point(24, 208)
+ Me.GroupBox1.Margin = New System.Windows.Forms.Padding(6)
Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(313, 48)
+ Me.GroupBox1.Padding = New System.Windows.Forms.Padding(6)
+ Me.GroupBox1.Size = New System.Drawing.Size(626, 96)
Me.GroupBox1.TabIndex = 9
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "子文件夹选项"
@@ -133,9 +145,10 @@ Partial Class Form1
'RadioButton2
'
Me.RadioButton2.AutoSize = True
- Me.RadioButton2.Location = New System.Drawing.Point(155, 20)
+ Me.RadioButton2.Location = New System.Drawing.Point(310, 40)
+ Me.RadioButton2.Margin = New System.Windows.Forms.Padding(6)
Me.RadioButton2.Name = "RadioButton2"
- Me.RadioButton2.Size = New System.Drawing.Size(143, 16)
+ Me.RadioButton2.Size = New System.Drawing.Size(281, 28)
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.TabStop = True
Me.RadioButton2.Text = "每个文件夹到单独文件"
@@ -145,9 +158,10 @@ Partial Class Form1
'
Me.RadioButton1.AutoSize = True
Me.RadioButton1.Checked = True
- Me.RadioButton1.Location = New System.Drawing.Point(6, 20)
+ Me.RadioButton1.Location = New System.Drawing.Point(12, 40)
+ Me.RadioButton1.Margin = New System.Windows.Forms.Padding(6)
Me.RadioButton1.Name = "RadioButton1"
- Me.RadioButton1.Size = New System.Drawing.Size(143, 16)
+ Me.RadioButton1.Size = New System.Drawing.Size(281, 28)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "所有文件夹到一个文件"
@@ -155,13 +169,17 @@ Partial Class Form1
'
'ToolTip1
'
- Me.ToolTip1.AutomaticDelay = 200
+ Me.ToolTip1.AutomaticDelay = 50
+ Me.ToolTip1.AutoPopDelay = 5000
+ Me.ToolTip1.InitialDelay = 50
+ Me.ToolTip1.IsBalloon = True
+ Me.ToolTip1.ReshowDelay = 10
'
'Form1
'
- Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(12.0!, 24.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
- Me.ClientSize = New System.Drawing.Size(337, 183)
+ Me.ClientSize = New System.Drawing.Size(674, 366)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.CheckBox1)
Me.Controls.Add(Me.TrackBar1)
@@ -172,6 +190,7 @@ Partial Class Form1
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
+ Me.Margin = New System.Windows.Forms.Padding(6)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Text = "Muti IMG2PDF"
diff --git a/Form1.resx b/Form1.resx
index 5e0f0b7..ee03f00 100644
--- a/Form1.resx
+++ b/Form1.resx
@@ -121,9 +121,9 @@
167, 17
- 312, 17
+ 518, 16
- 494, 17
+ 846, 16
\ No newline at end of file
diff --git a/Form1.vb b/Form1.vb
index bff2ab9..a624204 100644
--- a/Form1.vb
+++ b/Form1.vb
@@ -1,8 +1,7 @@
Imports System.IO '虽然写在这里,但是pdfsharp和sytem里都有Drawing等字类同名,请下面详写
-Imports PdfSharp
-Imports PdfSharp.Pdf
-Imports PdfSharp.Drawing
Imports System.Linq.Expressions
+Imports Ghostscript
+Imports ImageMagick
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
@@ -89,7 +88,7 @@ Public Class Form1
Try
Merg2pdf(w8t2con, TextBox2.Text)
Catch ex As Exception
- MsgBox(ex)
+ MsgBox(ex.ToString)
End Try
End Sub
@@ -102,53 +101,56 @@ Public Class Form1
Private Sub Merg2pdf(ByVal w8t2con As Collection, ByVal fileloca As String)
TrackBar1.Maximum = w8t2con.Count
- Dim document As PdfDocument = New PdfDocument '创建pdf文件
+ If TextBox3.Text = 0 Then '免压缩,通常情况
+ Using images As MagickImageCollection = New MagickImageCollection
+ For Each picfile In w8t2con
+ images.Add(picfile)
+ TrackBar1.Value += 1
+ Application.DoEvents()
+ Next
+ images.Write(fileloca)
+ End Using
+ Else
+ TrackBar1.Maximum = TrackBar1.Maximum * 2 + 1
+ Directory.CreateDirectory(TextBox1.Text & "\temp\")
+ '先转格式
+ Using tmpimages As MagickImageCollection = New MagickImageCollection()
+ For Each img In w8t2con
+ tmpimages.Add(img)
- ' 创建一个临时文件夹来保存文件流
- Dim tempFolderPath As String = Path.Combine(Path.GetTempPath(), "PdfSharpTemp")
- If Not Directory.Exists(tempFolderPath) Then
- Directory.CreateDirectory(tempFolderPath)
- End If
+ Next
+ For i = 0 To tmpimages.Count - 1
+ If TextBox3.Text >= 100 Then
+ tmpimages(i).Format = MagickFormat.Png24
+ tmpimages(i).Quality = 1
+ tmpimages(i).Write(TextBox1.Text & "\temp\" & i & ".png")
+ Else
+ tmpimages(i).Format = MagickFormat.Jpg
+ tmpimages(i).Quality = TextBox3.Text
+ tmpimages(i).Write(TextBox1.Text & "\temp\" & i & ".jpg")
+ End If
- For Each img In w8t2con
- Dim tempImgFile As String = Path.Combine(tempFolderPath, Path.GetFileName(img))
- Using fs As New FileStream(tempImgFile, FileMode.Create, FileAccess.ReadWrite)
- ' 写入图片数据到文件流中
- Dim imgBytes As Byte() = File.ReadAllBytes(img)
- fs.Write(imgBytes, 0, imgBytes.Length)
- fs.Flush()
- ' 将文件流的位置重置到开始
- fs.Position = 0
+ TrackBar1.Value += 1
+ Application.DoEvents()
+ Next
+ End Using
- Dim page As PdfPage = document.AddPage() '创建新页
- Dim gfx As XGraphics = XGraphics.FromPdfPage(page) '创建画布在page上
- Using ximg As XImage = XImage.FromStream(fs) '创建gfx可用的image
- 'Dim g As Graphics
- 'g = Graphics.FromImage(Image.FromFile(img))
- 'Debug.WriteLine(ximg.HorizontalResolution) 'pdf打印页面大小与DPI有关
- page.Width = ximg.PixelWidth '设置页面为图片分辨率,piexel是分辨率,width是通过dpi转换后的大小
- page.Height = ximg.PixelHeight
- 'Debug.WriteLine("{0} x:{1} y:{2}", img, page.Width, page.Height)
- 'Debug.WriteLine("x:{0} y:{1}", g.DpiX / TextBox3.Text, g.DpiY / TextBox3.Text)
- gfx.ScaleTransform(ximg.HorizontalResolution / TextBox3.Text)
- gfx.DrawImage(ximg, 0, 0)
- page.Close()
- End Using
+ '再写入
+ Using images As MagickImageCollection = New MagickImageCollection
+ Dim files As New DirectoryInfo(TextBox1.Text & "\temp\")
+ Dim fileslist = files.GetFiles()
+ For Each picfile In fileslist
+ images.Add(picfile.FullName)
+ TrackBar1.Value += 1
+ Application.DoEvents()
+ Next
+ images.Write(fileloca)
End Using
- TrackBar1.Value += 1
- Next
- document.Save(fileloca)
+ Directory.Delete(TextBox1.Text & "\temp\", True)
+ End If
Beep()
- document.Close()
- ' 删除临时文件夹
- Directory.Delete(tempFolderPath, True)
TrackBar1.Value = 0
Conver.Enabled = True
- Try
- GC.Collect()
- Catch ex As Exception
- MsgBox(ex)
- End Try
End Sub
@@ -173,5 +175,4 @@ Public Class Form1
TextBox2.Text = temp
End If
End Sub
-
End Class
diff --git a/Image2Pdf.vbproj b/Image2Pdf.vbproj
index f2e9083..21c9c23 100644
--- a/Image2Pdf.vbproj
+++ b/Image2Pdf.vbproj
@@ -11,9 +11,12 @@
Image2Pdf
512
WindowsForms
- v4.5.1
+ v4.8.1
true
true
+
+
+
AnyCPU
@@ -69,11 +72,14 @@
true
-
- packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll
+
+ packages\Ghostscript.NET.1.2.3.1\lib\net40\Ghostscript.NET.dll
-
- packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll
+
+ packages\Magick.NET-Q8-AnyCPU.13.4.0\lib\netstandard20\Magick.NET-Q8-AnyCPU.dll
+
+
+ packages\Magick.NET.Core.13.4.0\lib\netstandard20\Magick.NET.Core.dll
@@ -111,6 +117,7 @@
True
Application.myapp
+ True
True
@@ -148,4 +155,11 @@
+
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
\ No newline at end of file
diff --git a/My Project/Application.Designer.vb b/My Project/Application.Designer.vb
index 8970b0a..4a6ce1f 100644
--- a/My Project/Application.Designer.vb
+++ b/My Project/Application.Designer.vb
@@ -1,10 +1,10 @@
'------------------------------------------------------------------------------
'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
+' 此代码由工具生成。
+' 运行时版本:4.0.30319.42000
'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
+' 对此文件的更改可能会导致不正确的行为,并且如果
+' 重新生成代码,这些更改将会丢失。
'
'------------------------------------------------------------------------------
@@ -13,15 +13,15 @@ Option Explicit On
Namespace My
-
- 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
- ' or if you encounter build errors in this file, go to the Project Designer
- ' (go to Project Properties or double-click the My Project node in
- ' Solution Explorer), and make changes on the Application tab.
+
+ '注意:此文件是自动生成的;请勿直接进行修改。若要更改,
+ ' 或者如果您在此文件中遇到生成错误,请转至项目设计器
+ ' (转至“项目属性”或在解决方案资源管理器中双击“我的项目”节点),
+ ' 然后在“应用程序”选项卡中进行更改。
'
Partial Friend Class MyApplication
-
- _
+
+ _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
@@ -29,10 +29,16 @@ Namespace My
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
-
- _
+
+ _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.Image2Pdf.Form1
End Sub
+
+ _
+ Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
+ Me.MinimumSplashScreenDisplayTime = 0
+ Return MyBase.OnInitialize(commandLineArgs)
+ End Function
End Class
End Namespace
diff --git a/My Project/Application.myapp b/My Project/Application.myapp
index 1243847..b3f38bb 100644
--- a/My Project/Application.myapp
+++ b/My Project/Application.myapp
@@ -1,11 +1,12 @@
-
+
true
Form1
false
0
true
0
- 0
+ 0
true
-
+ false
+
\ No newline at end of file
diff --git a/My Project/Resources.Designer.vb b/My Project/Resources.Designer.vb
index 5f12736..ecd873c 100644
--- a/My Project/Resources.Designer.vb
+++ b/My Project/Resources.Designer.vb
@@ -1,40 +1,41 @@
'------------------------------------------------------------------------------
'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
+' 此代码由工具生成。
+' 运行时版本:4.0.30319.42000
'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
+' 对此文件的更改可能会导致不正确的行为,并且如果
+' 重新生成代码,这些更改将会丢失。
'
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
+Imports System
Namespace My.Resources
-
- 'This class was auto-generated by the StronglyTypedResourceBuilder
- 'class via a tool like ResGen or Visual Studio.
- 'To add or remove a member, edit your .ResX file then rerun ResGen
- 'with the /str option, or rebuild your VS project.
+
+ '此类是由 StronglyTypedResourceBuilder
+ '类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ '若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ '(以 /str 作为命令选项),或重新生成 VS 项目。
'''
- ''' A strongly-typed resource class, for looking up localized strings, etc.
+ ''' 一个强类型的资源类,用于查找本地化的字符串等。
'''
- _
+ _
Friend Module Resources
-
+
Private resourceMan As Global.System.Resources.ResourceManager
-
+
Private resourceCulture As Global.System.Globalization.CultureInfo
-
+
'''
- ''' Returns the cached ResourceManager instance used by this class.
+ ''' 返回此类使用的缓存的 ResourceManager 实例。
'''
- _
+ _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
@@ -44,17 +45,17 @@ Namespace My.Resources
Return resourceMan
End Get
End Property
-
+
'''
- ''' Overrides the current thread's CurrentUICulture property for all
- ''' resource lookups using this strongly typed resource class.
+ ''' 重写当前线程的 CurrentUICulture 属性,对
+ ''' 使用此强类型资源类的所有资源查找执行重写。
'''
- _
+ _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
- Set(ByVal value As Global.System.Globalization.CultureInfo)
+ Set
resourceCulture = value
End Set
End Property
diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb
index 20fdd39..a3a2aad 100644
--- a/My Project/Settings.Designer.vb
+++ b/My Project/Settings.Designer.vb
@@ -1,10 +1,10 @@
'------------------------------------------------------------------------------
'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
+' 此代码由工具生成。
+' 运行时版本:4.0.30319.42000
'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
+' 对此文件的更改可能会导致不正确的行为,并且如果
+' 重新生成代码,这些更改将会丢失。
'
'------------------------------------------------------------------------------
@@ -13,42 +13,42 @@ Option Explicit On
Namespace My
-
- _
+
+ _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
-
- Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
-
-#Region "My.Settings Auto-Save Functionality"
+
+ Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
+
+#Region "My.Settings 自动保存功能"
#If _MyType = "WindowsForms" Then
- Private Shared addedHandler As Boolean
+ Private Shared addedHandler As Boolean
- Private Shared addedHandlerLockObject As New Object
+ Private Shared addedHandlerLockObject As New Object
- _
- Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
- If My.Application.SaveMySettingsOnExit Then
- My.Settings.Save()
- End If
- End Sub
+ _
+ Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
+ If My.Application.SaveMySettingsOnExit Then
+ My.Settings.Save()
+ End If
+ End Sub
#End If
#End Region
-
+
Public Shared ReadOnly Property [Default]() As MySettings
Get
-
+
#If _MyType = "WindowsForms" Then
- If Not addedHandler Then
- SyncLock addedHandlerLockObject
- If Not addedHandler Then
- AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
- addedHandler = True
- End If
- End SyncLock
- End If
+ If Not addedHandler Then
+ SyncLock addedHandlerLockObject
+ If Not addedHandler Then
+ AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
+ addedHandler = True
+ End If
+ End SyncLock
+ End If
#End If
Return defaultInstance
End Get
@@ -57,13 +57,13 @@ Namespace My
End Namespace
Namespace My
-
- _
+
+ _
Friend Module MySettingsProperty
-
- _
+
+ _
Friend ReadOnly Property Settings() As Global.Image2Pdf.My.MySettings
Get
Return Global.Image2Pdf.My.MySettings.Default
diff --git a/packages.config b/packages.config
index 26da24d..cdee2fc 100644
--- a/packages.config
+++ b/packages.config
@@ -1,4 +1,6 @@
-
+
+
+
\ No newline at end of file