개정판 66be3f2d
update
DTI_PID/PDF_TO_IMAGE/App.config | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 | 2 |
<configuration> |
3 | 3 |
<configSections> |
4 |
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
|
5 |
<section name="PDF_TO_IMAGE.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
4 |
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
|
5 |
<section name="PDF_TO_IMAGE.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> |
|
6 | 6 |
</sectionGroup> |
7 | 7 |
</configSections> |
8 | 8 |
<startup> |
9 |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
|
9 |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
|
10 | 10 |
</startup> |
11 | 11 |
<userSettings> |
12 | 12 |
<PDF_TO_IMAGE.Properties.Settings> |
13 | 13 |
<setting name="_Dpi" serializeAs="String"> |
14 |
<value />
|
|
14 |
<value/> |
|
15 | 15 |
</setting> |
16 | 16 |
<setting name="_Height" serializeAs="String"> |
17 |
<value />
|
|
17 |
<value/> |
|
18 | 18 |
</setting> |
19 | 19 |
<setting name="_Width" serializeAs="String"> |
20 |
<value />
|
|
20 |
<value/> |
|
21 | 21 |
</setting> |
22 | 22 |
</PDF_TO_IMAGE.Properties.Settings> |
23 | 23 |
</userSettings> |
DTI_PID/PDF_TO_IMAGE/ConvertImage.cs | ||
---|---|---|
58 | 58 |
pdftron.PDFNet.Initialize("daelim.co.kr(Doftech Corp):CPU:2::W:AMC(20120315):EF6E886F25A414FFB5F8C1F2999CF2DA33DC6C5164315BAF7011B87AF0FA"); |
59 | 59 |
using (PDFDoc doc = new PDFDoc(FilePath)) |
60 | 60 |
{ |
61 |
Bitmap newBmp_; |
|
61 |
|
|
62 | 62 |
ImageCodecInfo DefaultImageCodecInfo = GetEncoderInfo("image/png"); |
63 | 63 |
EncoderParameters DefaultEncoderParameters = new EncoderParameters(2); |
64 | 64 |
System.Drawing.Imaging.Encoder QualityEncoder = System.Drawing.Imaging.Encoder.Quality; |
... | ... | |
75 | 75 |
{ |
76 | 76 |
float fDpix = 600; |
77 | 77 |
float fDpiy = 600; |
78 |
//int iWidth = 10000; |
|
79 |
//int iHeight = 10000; |
|
80 | 78 |
try |
81 | 79 |
{fDpix = float.Parse(Combo_DPI.Text); |
82 | 80 |
fDpiy = float.Parse(Combo_DPI.Text);} |
83 | 81 |
catch |
84 | 82 |
{} |
85 |
//try |
|
86 |
//{iWidth = int.Parse(Properties.Settings.Default._Width); |
|
87 |
//iHeight = int.Parse(Properties.Settings.Default._Height); |
|
88 |
//}catch{ } |
|
89 | 83 |
ElementBuilder bld = new ElementBuilder(); |
90 | 84 |
ElementWriter writer = new ElementWriter(); |
91 |
//var widthData = (int)doc.GetPage(i).GetPageWidth(); |
|
92 |
//int heightData = (int)doc.GetPage(i).GetPageHeight(); |
|
93 | 85 |
var rotation = doc.GetPage(i).GetRotation(); |
94 |
// draw.SetImageSize((int)(widthData * 2), (int)(heightData * 2), true); |
|
95 |
// draw.SetImageSize(iWidth, iHeight, true); |
|
96 |
draw.SetAntiAliasing(true); |
|
86 |
draw.SetAntiAliasing(false); |
|
97 | 87 |
draw.SetDPI(fDpix); |
98 |
newBmp_ = draw.GetBitmap(doc.GetPage(i)); |
|
99 |
|
|
88 |
Bitmap newBmp_ = draw.GetBitmap(doc.GetPage(i));
|
|
89 |
|
|
100 | 90 |
using (MemoryStream _savestream = new MemoryStream()) |
101 | 91 |
{ |
102 |
newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
103 |
newBmp_ = new Bitmap(_savestream); |
|
104 |
ObjSet objset = new ObjSet(); |
|
105 |
Obj jbig2_hint = objset.CreateName("png"); |
|
106 |
string pagePath = sPathNonExtension; |
|
107 |
if (i > 1) |
|
92 |
try |
|
108 | 93 |
{ |
109 |
pagePath = sPathNonExtension + "_" + i; |
|
94 |
newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
95 |
newBmp_ = new Bitmap(_savestream); |
|
96 |
ObjSet objset = new ObjSet(); |
|
97 |
Obj jbig2_hint = objset.CreateName("png"); |
|
98 |
string pagePath = sPathNonExtension; |
|
99 |
if (i > 1) |
|
100 |
{ |
|
101 |
pagePath = sPathNonExtension + "_" + i; |
|
102 |
} |
|
103 |
newBmp_.Save(pagePath + "_" + fDpix + ".png"); |
|
104 |
newBmp_.Dispose(); |
|
110 | 105 |
} |
111 |
newBmp_.Save(pagePath + "_" + fDpix +".png"); |
|
112 |
newBmp_.Dispose(); |
|
106 |
catch(Exception ex) |
|
107 |
{ |
|
108 | ||
109 |
} |
|
110 |
|
|
113 | 111 |
} |
114 | 112 |
GC.Collect(); |
115 | 113 |
GC.WaitForPendingFinalizers(); |
... | ... | |
117 | 115 |
} |
118 | 116 |
catch (Exception ex) |
119 | 117 |
{ |
120 |
return false; |
|
118 |
// return false;
|
|
121 | 119 |
} |
122 | 120 |
} |
123 | 121 |
if(doc.GetPageCount() > 0) |
124 | 122 |
{ |
125 | 123 |
MessageBox.Show("변환완료"); |
126 | 124 |
} |
127 | ||
128 | 125 |
#endregion |
129 | 126 |
return true; |
130 | 127 |
} |
... | ... | |
140 | 137 |
Properties.Settings.Default._Height = Txt_Height.Text; |
141 | 138 |
Properties.Settings.Default._Width = Txt_Width.Text; |
142 | 139 |
Properties.Settings.Default.Save(); |
143 |
ConvertPdfToImage(Txt_PDFPath.Text); |
|
140 |
/// ConvertPdfToImage(Txt_PDFPath.Text); |
|
141 |
/// |
|
142 |
string sPathNonExtension = Txt_PDFPath.Text.Replace(Path.GetExtension(Txt_PDFPath.Text), ""); |
|
143 | ||
144 | ||
145 |
pdftron.PDFNet.Initialize("daelim.co.kr(Doftech Corp):CPU:2::W:AMC(20120315):EF6E886F25A414FFB5F8C1F2999CF2DA33DC6C5164315BAF7011B87AF0FA"); |
|
146 |
using (PDFDoc doc = new PDFDoc(Txt_PDFPath.Text)) |
|
147 |
{ |
|
148 | ||
149 |
ImageCodecInfo DefaultImageCodecInfo = GetEncoderInfo("image/png"); |
|
150 |
EncoderParameters DefaultEncoderParameters = new EncoderParameters(2); |
|
151 |
System.Drawing.Imaging.Encoder QualityEncoder = System.Drawing.Imaging.Encoder.Quality; |
|
152 |
System.Drawing.Imaging.Encoder ColorDepthEncoder = System.Drawing.Imaging.Encoder.ColorDepth; |
|
153 |
DefaultEncoderParameters.Param[0] = new EncoderParameter(QualityEncoder, 100L); |
|
154 |
DefaultEncoderParameters.Param[1] = new EncoderParameter(ColorDepthEncoder, 8L); |
|
155 | ||
156 |
#region 이미지 만들기 |
|
157 |
for (int i = 1; i < doc.GetPageCount() + 1; i++) |
|
158 |
{ |
|
159 |
try |
|
160 |
{ |
|
161 |
using (pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw()) |
|
162 |
{ |
|
163 |
float fDpix = 600; |
|
164 |
float fDpiy = 600; |
|
165 |
try |
|
166 |
{ |
|
167 |
fDpix = float.Parse(Combo_DPI.Text); |
|
168 |
fDpiy = float.Parse(Combo_DPI.Text); |
|
169 |
} |
|
170 |
catch |
|
171 |
{ } |
|
172 |
ElementBuilder bld = new ElementBuilder(); |
|
173 |
ElementWriter writer = new ElementWriter(); |
|
174 |
var rotation = doc.GetPage(i).GetRotation(); |
|
175 |
draw.SetAntiAliasing(false); |
|
176 |
draw.SetDPI(fDpix); |
|
177 |
Bitmap newBmp_ = draw.GetBitmap(doc.GetPage(i)); |
|
178 | ||
179 |
using (MemoryStream _savestream = new MemoryStream()) |
|
180 |
{ |
|
181 |
try |
|
182 |
{ |
|
183 |
newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
184 |
newBmp_ = new Bitmap(_savestream); |
|
185 |
ObjSet objset = new ObjSet(); |
|
186 |
Obj jbig2_hint = objset.CreateName("png"); |
|
187 |
string pagePath = sPathNonExtension; |
|
188 |
if (i > 1) |
|
189 |
{ |
|
190 |
pagePath = sPathNonExtension + "_" + i; |
|
191 |
} |
|
192 |
newBmp_.Save(pagePath + "_" + fDpix + ".png"); |
|
193 |
newBmp_.Dispose(); |
|
194 |
} |
|
195 |
catch (Exception ex) |
|
196 |
{ |
|
197 | ||
198 |
} |
|
199 | ||
200 |
} |
|
201 |
GC.Collect(); |
|
202 |
GC.WaitForPendingFinalizers(); |
|
203 |
} |
|
204 |
} |
|
205 |
catch (Exception ex) |
|
206 |
{ |
|
207 |
// return false; |
|
208 |
} |
|
209 |
} |
|
210 |
if (doc.GetPageCount() > 0) |
|
211 |
{ |
|
212 |
MessageBox.Show("변환완료"); |
|
213 |
} |
|
214 |
#endregion |
|
215 |
} |
|
216 | ||
217 | ||
144 | 218 |
} |
145 | 219 |
else |
146 | 220 |
{ |
DTI_PID/PDF_TO_IMAGE/PDF_TO_IMAGE.csproj | ||
---|---|---|
8 | 8 |
<OutputType>WinExe</OutputType> |
9 | 9 |
<RootNamespace>PDF_TO_IMAGE</RootNamespace> |
10 | 10 |
<AssemblyName>PDF_TO_IMAGE</AssemblyName> |
11 |
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
|
11 |
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
|
12 | 12 |
<FileAlignment>512</FileAlignment> |
13 | 13 |
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
14 | 14 |
<TargetFrameworkProfile /> |
15 | 15 |
</PropertyGroup> |
16 | 16 |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
17 |
<PlatformTarget>x64</PlatformTarget>
|
|
17 |
<PlatformTarget>x86</PlatformTarget>
|
|
18 | 18 |
<DebugSymbols>true</DebugSymbols> |
19 | 19 |
<DebugType>full</DebugType> |
20 | 20 |
<Optimize>false</Optimize> |
... | ... | |
58 | 58 |
<Reference Include="DevExpress.Sparkline.v18.1.Core, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> |
59 | 59 |
<Reference Include="DevExpress.Utils.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> |
60 | 60 |
<Reference Include="DevExpress.XtraEditors.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> |
61 |
<Reference Include="PDFNet, Version=5.8.0.0, Culture=neutral, PublicKeyToken=36167be3f67ac39c, processorArchitecture=x86">
|
|
61 |
<Reference Include="PDFNet, Version=5.8.0.0, Culture=neutral, PublicKeyToken=36167be3f67ac39c, processorArchitecture=AMD64">
|
|
62 | 62 |
<SpecificVersion>False</SpecificVersion> |
63 | 63 |
<HintPath>.\PDFNet.dll</HintPath> |
64 | 64 |
</Reference> |
내보내기 Unified diff