개정판 391aa70f
build issue #766: devexpress dll 사용
DTI_PID/PDF_TO_IMAGE/App.config | ||
---|---|---|
10 | 10 |
</startup> |
11 | 11 |
<userSettings> |
12 | 12 |
<PDF_TO_IMAGE.Properties.Settings> |
13 |
<setting name="_Dpi" serializeAs="String">
|
|
14 |
<value/>
|
|
13 |
<setting name="_Scale" serializeAs="String">
|
|
14 |
<value>0</value>
|
|
15 | 15 |
</setting> |
16 |
<setting name="_Height" serializeAs="String">
|
|
17 |
<value/>
|
|
16 |
<setting name="_LengthType" serializeAs="String">
|
|
17 |
<value>0</value>
|
|
18 | 18 |
</setting> |
19 |
<setting name="_Width" serializeAs="String"> |
|
20 |
<value/> |
|
19 |
<setting name="_Length" serializeAs="String"> |
|
20 |
<value>0</value> |
|
21 |
</setting> |
|
22 |
<setting name="_UseScale" serializeAs="String"> |
|
23 |
<value>True</value> |
|
21 | 24 |
</setting> |
22 | 25 |
</PDF_TO_IMAGE.Properties.Settings> |
23 | 26 |
</userSettings> |
DTI_PID/PDF_TO_IMAGE/ConvertImage.Designer.cs | ||
---|---|---|
33 | 33 |
this.Btn_LoadPDF = new System.Windows.Forms.Button(); |
34 | 34 |
this.Btn_Convert = new System.Windows.Forms.Button(); |
35 | 35 |
this.label2 = new System.Windows.Forms.Label(); |
36 |
this.Combo_DPI = new System.Windows.Forms.ComboBox();
|
|
36 |
this.Combo_Scale = new System.Windows.Forms.ComboBox();
|
|
37 | 37 |
this.label3 = new System.Windows.Forms.Label(); |
38 |
this.Txt_Length = new System.Windows.Forms.TextBox(); |
|
39 |
this.Chk_Scale = new System.Windows.Forms.CheckBox(); |
|
40 |
this.Combo_LengthType = new System.Windows.Forms.ComboBox(); |
|
38 | 41 |
this.label4 = new System.Windows.Forms.Label(); |
39 |
this.label5 = new System.Windows.Forms.Label(); |
|
40 |
this.Txt_Height = new System.Windows.Forms.TextBox(); |
|
41 |
this.Txt_Width = new System.Windows.Forms.TextBox(); |
|
42 |
this.Chk_DPI = new System.Windows.Forms.CheckBox(); |
|
43 | 42 |
this.SuspendLayout(); |
44 | 43 |
// |
45 | 44 |
// Txt_PDFPath |
... | ... | |
83 | 82 |
// label2 |
84 | 83 |
// |
85 | 84 |
this.label2.AutoSize = true; |
86 |
this.label2.Location = new System.Drawing.Point(12, 14);
|
|
85 |
this.label2.Location = new System.Drawing.Point(12, 11);
|
|
87 | 86 |
this.label2.Name = "label2"; |
88 |
this.label2.Size = new System.Drawing.Size(23, 12);
|
|
87 |
this.label2.Size = new System.Drawing.Size(37, 12);
|
|
89 | 88 |
this.label2.TabIndex = 4; |
90 |
this.label2.Text = "Dpi";
|
|
91 |
// |
|
92 |
// Combo_DPI
|
|
93 |
// |
|
94 |
this.Combo_DPI.FormattingEnabled = true;
|
|
95 |
this.Combo_DPI.Items.AddRange(new object[] {
|
|
96 |
"150",
|
|
97 |
"300",
|
|
98 |
"400",
|
|
99 |
"500",
|
|
100 |
"600",
|
|
101 |
"750",
|
|
102 |
"900",
|
|
103 |
"1200",
|
|
104 |
"1500",
|
|
105 |
"1800"});
|
|
106 |
this.Combo_DPI.Location = new System.Drawing.Point(75, 11);
|
|
107 |
this.Combo_DPI.MaxDropDownItems = 12;
|
|
108 |
this.Combo_DPI.Name = "Combo_DPI";
|
|
109 |
this.Combo_DPI.Size = new System.Drawing.Size(83, 20);
|
|
110 |
this.Combo_DPI.TabIndex = 5;
|
|
89 |
this.label2.Text = "Scale";
|
|
90 |
// |
|
91 |
// Combo_Scale
|
|
92 |
// |
|
93 |
this.Combo_Scale.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
94 |
this.Combo_Scale.FormattingEnabled = true;
|
|
95 |
this.Combo_Scale.Items.AddRange(new object[] {
|
|
96 |
"* 2",
|
|
97 |
"* 3",
|
|
98 |
"* 4",
|
|
99 |
"* 5",
|
|
100 |
"* 6",
|
|
101 |
"* 7",
|
|
102 |
"* 8",
|
|
103 |
"* 9",
|
|
104 |
"* 10"});
|
|
105 |
this.Combo_Scale.Location = new System.Drawing.Point(75, 8);
|
|
106 |
this.Combo_Scale.MaxDropDownItems = 12;
|
|
107 |
this.Combo_Scale.Name = "Combo_Scale";
|
|
108 |
this.Combo_Scale.Size = new System.Drawing.Size(48, 20);
|
|
109 |
this.Combo_Scale.TabIndex = 5;
|
|
111 | 110 |
// |
112 | 111 |
// label3 |
113 | 112 |
// |
... | ... | |
118 | 117 |
this.label3.TabIndex = 6; |
119 | 118 |
this.label3.Text = "PDF Path"; |
120 | 119 |
// |
120 |
// Txt_Length |
|
121 |
// |
|
122 |
this.Txt_Length.Location = new System.Drawing.Point(261, 8); |
|
123 |
this.Txt_Length.Name = "Txt_Length"; |
|
124 |
this.Txt_Length.Size = new System.Drawing.Size(78, 21); |
|
125 |
this.Txt_Length.TabIndex = 9; |
|
126 |
// |
|
127 |
// Chk_Scale |
|
128 |
// |
|
129 |
this.Chk_Scale.AutoSize = true; |
|
130 |
this.Chk_Scale.Checked = true; |
|
131 |
this.Chk_Scale.CheckState = System.Windows.Forms.CheckState.Checked; |
|
132 |
this.Chk_Scale.Location = new System.Drawing.Point(491, 10); |
|
133 |
this.Chk_Scale.Name = "Chk_Scale"; |
|
134 |
this.Chk_Scale.Size = new System.Drawing.Size(82, 16); |
|
135 |
this.Chk_Scale.TabIndex = 11; |
|
136 |
this.Chk_Scale.Text = "Use Scale"; |
|
137 |
this.Chk_Scale.UseVisualStyleBackColor = true; |
|
138 |
this.Chk_Scale.CheckedChanged += new System.EventHandler(this.Chk_Scale_CheckedChanged); |
|
139 |
// |
|
140 |
// Combo_LengthType |
|
141 |
// |
|
142 |
this.Combo_LengthType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; |
|
143 |
this.Combo_LengthType.FormattingEnabled = true; |
|
144 |
this.Combo_LengthType.Items.AddRange(new object[] { |
|
145 |
"Width", |
|
146 |
"Height"}); |
|
147 |
this.Combo_LengthType.Location = new System.Drawing.Point(175, 8); |
|
148 |
this.Combo_LengthType.MaxDropDownItems = 12; |
|
149 |
this.Combo_LengthType.Name = "Combo_LengthType"; |
|
150 |
this.Combo_LengthType.Size = new System.Drawing.Size(80, 20); |
|
151 |
this.Combo_LengthType.TabIndex = 12; |
|
152 |
// |
|
121 | 153 |
// label4 |
122 | 154 |
// |
123 | 155 |
this.label4.AutoSize = true; |
124 |
this.label4.Location = new System.Drawing.Point(183, 14);
|
|
156 |
this.label4.Location = new System.Drawing.Point(345, 11);
|
|
125 | 157 |
this.label4.Name = "label4"; |
126 | 158 |
this.label4.Size = new System.Drawing.Size(40, 12); |
127 |
this.label4.TabIndex = 7; |
|
128 |
this.label4.Text = "Height"; |
|
129 |
// |
|
130 |
// label5 |
|
131 |
// |
|
132 |
this.label5.AutoSize = true; |
|
133 |
this.label5.Location = new System.Drawing.Point(324, 14); |
|
134 |
this.label5.Name = "label5"; |
|
135 |
this.label5.Size = new System.Drawing.Size(35, 12); |
|
136 |
this.label5.TabIndex = 8; |
|
137 |
this.label5.Text = "Width"; |
|
138 |
// |
|
139 |
// Txt_Height |
|
140 |
// |
|
141 |
this.Txt_Height.Location = new System.Drawing.Point(229, 10); |
|
142 |
this.Txt_Height.Name = "Txt_Height"; |
|
143 |
this.Txt_Height.Size = new System.Drawing.Size(72, 21); |
|
144 |
this.Txt_Height.TabIndex = 9; |
|
145 |
// |
|
146 |
// Txt_Width |
|
147 |
// |
|
148 |
this.Txt_Width.Location = new System.Drawing.Point(365, 10); |
|
149 |
this.Txt_Width.Name = "Txt_Width"; |
|
150 |
this.Txt_Width.Size = new System.Drawing.Size(72, 21); |
|
151 |
this.Txt_Width.TabIndex = 10; |
|
152 |
// |
|
153 |
// Chk_DPI |
|
154 |
// |
|
155 |
this.Chk_DPI.AutoSize = true; |
|
156 |
this.Chk_DPI.Location = new System.Drawing.Point(459, 14); |
|
157 |
this.Chk_DPI.Name = "Chk_DPI"; |
|
158 |
this.Chk_DPI.Size = new System.Drawing.Size(69, 16); |
|
159 |
this.Chk_DPI.TabIndex = 11; |
|
160 |
this.Chk_DPI.Text = "Use DPI"; |
|
161 |
this.Chk_DPI.UseVisualStyleBackColor = true; |
|
159 |
this.label4.TabIndex = 13; |
|
160 |
this.label4.Text = "Pixels"; |
|
162 | 161 |
// |
163 | 162 |
// ConvertImage |
164 | 163 |
// |
... | ... | |
166 | 165 |
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
167 | 166 |
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; |
168 | 167 |
this.ClientSize = new System.Drawing.Size(695, 73); |
169 |
this.Controls.Add(this.Chk_DPI); |
|
170 |
this.Controls.Add(this.Txt_Width); |
|
171 |
this.Controls.Add(this.Txt_Height); |
|
172 |
this.Controls.Add(this.label5); |
|
173 | 168 |
this.Controls.Add(this.label4); |
169 |
this.Controls.Add(this.Combo_LengthType); |
|
170 |
this.Controls.Add(this.Chk_Scale); |
|
171 |
this.Controls.Add(this.Txt_Length); |
|
174 | 172 |
this.Controls.Add(this.label3); |
175 |
this.Controls.Add(this.Combo_DPI);
|
|
173 |
this.Controls.Add(this.Combo_Scale);
|
|
176 | 174 |
this.Controls.Add(this.label2); |
177 | 175 |
this.Controls.Add(this.Btn_Convert); |
178 | 176 |
this.Controls.Add(this.Btn_LoadPDF); |
... | ... | |
182 | 180 |
this.Name = "ConvertImage"; |
183 | 181 |
this.ShowIcon = false; |
184 | 182 |
this.Text = "ConvertImage"; |
183 |
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ConvertImage_FormClosing); |
|
185 | 184 |
this.ResumeLayout(false); |
186 | 185 |
this.PerformLayout(); |
187 | 186 | |
... | ... | |
194 | 193 |
private System.Windows.Forms.Button Btn_LoadPDF; |
195 | 194 |
private System.Windows.Forms.Button Btn_Convert; |
196 | 195 |
private System.Windows.Forms.Label label2; |
197 |
private System.Windows.Forms.ComboBox Combo_DPI;
|
|
196 |
private System.Windows.Forms.ComboBox Combo_Scale;
|
|
198 | 197 |
private System.Windows.Forms.Label label3; |
198 |
private System.Windows.Forms.TextBox Txt_Length; |
|
199 |
private System.Windows.Forms.CheckBox Chk_Scale; |
|
200 |
private System.Windows.Forms.ComboBox Combo_LengthType; |
|
199 | 201 |
private System.Windows.Forms.Label label4; |
200 |
private System.Windows.Forms.Label label5; |
|
201 |
private System.Windows.Forms.TextBox Txt_Height; |
|
202 |
private System.Windows.Forms.TextBox Txt_Width; |
|
203 |
private System.Windows.Forms.CheckBox Chk_DPI; |
|
204 | 202 |
} |
205 | 203 |
} |
206 | 204 |
DTI_PID/PDF_TO_IMAGE/ConvertImage.cs | ||
---|---|---|
1 |
using pdftron.PDF; |
|
2 |
using pdftron.SDF; |
|
3 |
using System; |
|
1 |
using System; |
|
4 | 2 |
using System.Collections.Generic; |
5 | 3 |
using System.ComponentModel; |
6 | 4 |
using System.Data; |
... | ... | |
11 | 9 |
using System.Text; |
12 | 10 |
using System.Threading.Tasks; |
13 | 11 |
using System.Windows.Forms; |
12 |
using DevExpress.Pdf; |
|
14 | 13 | |
15 | 14 |
namespace PDF_TO_IMAGE |
16 | 15 |
{ |
... | ... | |
19 | 18 |
public ConvertImage() |
20 | 19 |
{ |
21 | 20 |
InitializeComponent(); |
22 |
Combo_DPI.Text = Properties.Settings.Default._Dpi; |
|
23 |
Txt_Height.Text = Properties.Settings.Default._Height; |
|
24 |
Txt_Width.Text = Properties.Settings.Default._Width; |
|
21 | ||
22 |
Combo_Scale.SelectedIndex = Properties.Settings.Default._Scale; |
|
23 |
Combo_LengthType.SelectedIndex = Properties.Settings.Default._LengthType; |
|
24 |
Txt_Length.Text = Properties.Settings.Default._Length; |
|
25 |
Chk_Scale.Checked = Properties.Settings.Default._UseScale; |
|
26 |
SacleCheckedChange(); |
|
27 |
} |
|
28 | ||
29 |
private void ConvertImage_FormClosing(object sender, FormClosingEventArgs e) |
|
30 |
{ |
|
31 |
Properties.Settings.Default._Scale = Combo_Scale.SelectedIndex; |
|
32 |
Properties.Settings.Default._LengthType = Combo_LengthType.SelectedIndex; |
|
33 |
Properties.Settings.Default._Length = Txt_Length.Text; |
|
34 |
Properties.Settings.Default._UseScale = Chk_Scale.Checked; |
|
35 |
Properties.Settings.Default.Save(); |
|
25 | 36 |
} |
26 | 37 | |
27 | 38 |
private void Btn_LoadPDF_Click(object sender, EventArgs e) |
... | ... | |
32 | 43 |
string pdfpath = OFD.FileName; |
33 | 44 | |
34 | 45 |
Txt_PDFPath.Text = pdfpath; |
35 | ||
36 | 46 |
} |
37 | 47 |
} |
38 |
private static ImageCodecInfo GetEncoderInfo(String mimeType) |
|
48 | ||
49 |
private void Chk_Scale_CheckedChanged(object sender, EventArgs e) |
|
39 | 50 |
{ |
40 |
int j; |
|
41 |
ImageCodecInfo[] encoders; |
|
42 |
encoders = ImageCodecInfo.GetImageEncoders(); |
|
43 |
for (j = 0; j < encoders.Length; ++j) |
|
51 |
SacleCheckedChange(); |
|
52 |
} |
|
53 | ||
54 |
private void SacleCheckedChange() |
|
55 |
{ |
|
56 |
if (Chk_Scale.Checked) |
|
57 |
{ |
|
58 |
Txt_Length.Enabled = false; |
|
59 |
Combo_LengthType.Enabled = false; |
|
60 |
Combo_Scale.Enabled = true; |
|
61 |
} |
|
62 |
else |
|
44 | 63 |
{ |
45 |
if (encoders[j].MimeType == mimeType) |
|
46 |
return encoders[j]; |
|
64 |
Txt_Length.Enabled = true; |
|
65 |
Combo_LengthType.Enabled = true; |
|
66 |
Combo_Scale.Enabled = false; |
|
47 | 67 |
} |
48 |
return null; |
|
49 | 68 |
} |
50 | 69 | |
51 |
private bool ConvertPdfToImage(string FilePath) |
|
52 | 70 | |
71 |
private void Btn_Convert_Click(object sender, EventArgs e) |
|
53 | 72 |
{ |
54 |
string sPathNonExtension = FilePath.Replace(Path.GetExtension(FilePath), ""); |
|
55 | ||
73 |
int iScale = 0; |
|
74 |
double iLength = 0; |
|
75 |
bool bResult = true; |
|
76 |
string sFilePath = Txt_PDFPath.Text; |
|
56 | 77 | |
57 |
pdftron.PDFNet.Initialize("daelim.co.kr(Doftech Corp):CPU:2::W:AMC(20120315):EF6E886F25A414FFB5F8C1F2999CF2DA33DC6C5164315BAF7011B87AF0FA"); |
|
58 |
using (PDFDoc doc = new PDFDoc(FilePath)) |
|
78 |
if (Chk_Scale.Checked) |
|
79 |
iScale = Convert.ToInt32(Combo_Scale.SelectedItem.ToString().Split(new char[] { ' ' })[1]); |
|
80 |
else |
|
59 | 81 |
{ |
60 |
|
|
61 |
ImageCodecInfo DefaultImageCodecInfo = GetEncoderInfo("image/png"); |
|
62 |
EncoderParameters DefaultEncoderParameters = new EncoderParameters(2); |
|
63 |
System.Drawing.Imaging.Encoder QualityEncoder = System.Drawing.Imaging.Encoder.Quality; |
|
64 |
System.Drawing.Imaging.Encoder ColorDepthEncoder = System.Drawing.Imaging.Encoder.ColorDepth; |
|
65 |
DefaultEncoderParameters.Param[0] = new EncoderParameter(QualityEncoder, 100L); |
|
66 |
DefaultEncoderParameters.Param[1] = new EncoderParameter(ColorDepthEncoder, 8L); |
|
67 | ||
68 |
#region 이미지 만들기 |
|
69 |
for (int i = 1; i < doc.GetPageCount() + 1; i++) |
|
70 |
{ |
|
71 |
try |
|
72 |
{ |
|
73 |
using (pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw()) |
|
74 |
{ |
|
75 |
float fDpix = 600; |
|
76 |
float fDpiy = 600; |
|
77 |
try |
|
78 |
{fDpix = float.Parse(Combo_DPI.Text); |
|
79 |
fDpiy = float.Parse(Combo_DPI.Text);} |
|
80 |
catch |
|
81 |
{} |
|
82 |
ElementBuilder bld = new ElementBuilder(); |
|
83 |
ElementWriter writer = new ElementWriter(); |
|
84 |
var rotation = doc.GetPage(i).GetRotation(); |
|
85 |
draw.SetAntiAliasing(false); |
|
86 |
draw.SetDPI(fDpix); |
|
87 |
Bitmap newBmp_ = draw.GetBitmap(doc.GetPage(i)); |
|
88 |
|
|
89 |
using (MemoryStream _savestream = new MemoryStream()) |
|
90 |
{ |
|
91 |
try |
|
92 |
{ |
|
93 |
newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
94 |
newBmp_ = new Bitmap(_savestream); |
|
95 |
ObjSet objset = new ObjSet(); |
|
96 |
Obj jbig2_hint = objset.CreateName("png"); |
|
97 |
string pagePath = sPathNonExtension; |
|
98 |
if (i > 1) |
|
99 |
{ |
|
100 |
pagePath = sPathNonExtension + "_" + i; |
|
101 |
} |
|
102 |
newBmp_.Save(pagePath + "_" + fDpix + ".png"); |
|
103 |
newBmp_.Dispose(); |
|
104 |
} |
|
105 |
catch(Exception ex) |
|
106 |
{ |
|
107 | ||
108 |
} |
|
109 |
|
|
110 |
} |
|
111 |
GC.Collect(); |
|
112 |
GC.WaitForPendingFinalizers(); |
|
113 |
} |
|
114 |
} |
|
115 |
catch (Exception ex) |
|
116 |
{ |
|
117 |
// return false; |
|
118 |
} |
|
119 |
} |
|
120 |
if(doc.GetPageCount() > 0) |
|
121 |
{ |
|
122 |
MessageBox.Show("변환완료"); |
|
123 |
} |
|
124 |
#endregion |
|
125 |
return true; |
|
82 |
if (!double.TryParse(Txt_Length.Text, out iLength) || iLength < 300) |
|
83 |
bResult = false; |
|
84 |
|
|
126 | 85 |
} |
127 |
} |
|
128 | 86 | |
129 |
private void Btn_Convert_Click(object sender, EventArgs e) |
|
130 |
{ |
|
131 |
int iDpi = 0; |
|
132 |
if(Txt_PDFPath.Text != "" && int.TryParse(Combo_DPI.Text,out iDpi) == true) |
|
87 |
if (!File.Exists(sFilePath)) |
|
88 |
bResult = false; |
|
89 | ||
90 | ||
91 |
if (bResult) |
|
133 | 92 |
{ |
134 |
Properties.Settings.Default._Dpi = Combo_DPI.Text; |
|
135 |
Properties.Settings.Default._Height = Txt_Height.Text; |
|
136 |
Properties.Settings.Default._Width = Txt_Width.Text; |
|
137 |
Properties.Settings.Default.Save(); |
|
138 |
/// ConvertPdfToImage(Txt_PDFPath.Text); |
|
139 |
/// |
|
140 | 93 |
string sPathNonExtension = Txt_PDFPath.Text.Replace(Path.GetExtension(Txt_PDFPath.Text), ""); |
94 |
PdfDocumentProcessor pdp = new PdfDocumentProcessor(); |
|
95 |
pdp.LoadDocument(sFilePath); |
|
141 | 96 | |
142 | ||
143 |
pdftron.PDFNet.Initialize("daelim.co.kr(Doftech Corp):CPU:2::W:AMC(20120315):EF6E886F25A414FFB5F8C1F2999CF2DA33DC6C5164315BAF7011B87AF0FA"); |
|
144 |
using (PDFDoc doc = new PDFDoc(Txt_PDFPath.Text)) |
|
97 |
try |
|
145 | 98 |
{ |
146 |
ImageCodecInfo DefaultImageCodecInfo = GetEncoderInfo("image/png"); |
|
147 |
EncoderParameters DefaultEncoderParameters = new EncoderParameters(2); |
|
148 |
System.Drawing.Imaging.Encoder QualityEncoder = System.Drawing.Imaging.Encoder.Quality; |
|
149 |
System.Drawing.Imaging.Encoder ColorDepthEncoder = System.Drawing.Imaging.Encoder.ColorDepth; |
|
150 |
DefaultEncoderParameters.Param[0] = new EncoderParameter(QualityEncoder, 100L); |
|
151 |
DefaultEncoderParameters.Param[1] = new EncoderParameter(ColorDepthEncoder, 1L); |
|
152 | ||
153 |
#region 이미지 만들기 |
|
154 |
for (int i = 1; i < doc.GetPageCount() + 1; i++) |
|
99 |
for (int i = 0; i < pdp.Document.Pages.Count; i++) |
|
155 | 100 |
{ |
156 |
string sFileName = ""; |
|
157 |
string pagePath = sPathNonExtension; |
|
158 |
if (i > 1) |
|
101 |
PdfPage page = pdp.Document.Pages[i]; |
|
102 | ||
103 |
double dWidth = page.CropBox.Width; |
|
104 |
double dHeight = page.CropBox.Height; |
|
105 | ||
106 |
if (Chk_Scale.Checked) |
|
159 | 107 |
{ |
160 |
pagePath = sPathNonExtension + "_" + i; |
|
108 |
dWidth = dWidth * iScale; |
|
109 |
dHeight = dHeight * iScale; |
|
161 | 110 |
} |
162 |
try
|
|
111 |
else
|
|
163 | 112 |
{ |
164 |
using (pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw())
|
|
113 |
if (Combo_LengthType.SelectedItem.ToString() == "Width")
|
|
165 | 114 |
{ |
166 |
ElementBuilder bld = new ElementBuilder(); |
|
167 |
ElementWriter writer = new ElementWriter(); |
|
168 |
if (Chk_DPI.Checked) |
|
169 |
{ |
|
170 |
float fDpix = 600; |
|
171 |
float fDpiy = 600; |
|
172 |
try |
|
173 |
{ |
|
174 |
fDpix = float.Parse(Combo_DPI.Text); |
|
175 |
fDpiy = float.Parse(Combo_DPI.Text); |
|
176 |
} |
|
177 |
catch |
|
178 |
{ } |
|
179 |
|
|
180 |
var rotation = doc.GetPage(i).GetRotation(); |
|
181 |
|
|
182 |
draw.SetDPI(fDpix); |
|
183 |
sFileName = pagePath + "_" + fDpix + ".jpeg"; |
|
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
var widthData =int.Parse(Txt_Width.Text); |
|
188 |
int heightData = int.Parse(Txt_Height.Text); |
|
189 |
|
|
190 |
var rotation = doc.GetPage(i).GetRotation(); |
|
191 |
draw.SetImageSize(widthData, heightData, true); |
|
192 |
sFileName = pagePath + "_" + widthData + "_" + heightData + ".png"; |
|
193 |
} |
|
194 |
draw.SetAntiAliasing(false); |
|
195 |
draw.SetImageSmoothing(false); |
|
196 |
Bitmap newBmp_ = draw.GetBitmap(doc.GetPage(i)); |
|
197 | ||
198 |
using (MemoryStream _savestream = new MemoryStream()) |
|
199 |
{ |
|
200 |
try |
|
201 |
{ |
|
202 |
newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
203 |
using (Bitmap bmpImage = new Bitmap(_savestream)) |
|
204 |
{ |
|
205 |
ObjSet objset = new ObjSet(); |
|
206 |
Obj jbig2_hint = objset.CreateName("png"); |
|
207 |
bmpImage.Save(sFileName, ImageFormat.Png); |
|
208 |
bmpImage.Dispose(); |
|
209 |
// Do something with the Bitmap object |
|
210 |
} |
|
211 |
} |
|
212 |
catch (Exception ex) |
|
213 |
{ |
|
214 |
MessageBox.Show("err" + "\n" + ex.ToString() + "\n" + ex.Message); |
|
215 |
} |
|
216 | ||
217 |
} |
|
218 |
GC.Collect(); |
|
219 |
GC.WaitForPendingFinalizers(); |
|
115 |
double dScale = dWidth / iLength; |
|
116 |
dWidth = iLength; |
|
117 |
dHeight = dHeight / dScale; |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
double dScale = dHeight / iLength; |
|
122 |
dHeight = iLength; |
|
123 |
dWidth = dWidth / dScale; |
|
220 | 124 |
} |
221 | 125 |
} |
222 |
catch (Exception ex) |
|
126 | ||
127 |
double dMax = Math.Max(dWidth, dHeight); |
|
128 | ||
129 |
using (Bitmap bitmap = pdp.CreateBitmap(i + 1, (int)dMax)) |
|
223 | 130 |
{ |
224 |
MessageBox.Show("err2" + "\n" + ex.ToString() + "\n" + ex.Message); |
|
225 |
// return false; |
|
131 |
bitmap.Save(sPathNonExtension + "_Page" + (i + 1) + ".png"); |
|
226 | 132 |
} |
227 | 133 |
} |
228 |
if (doc.GetPageCount() > 0) |
|
229 |
{ |
|
230 |
MessageBox.Show("변환완료"); |
|
231 |
} |
|
232 |
#endregion |
|
134 | ||
135 |
MessageBox.Show("변환완료"); |
|
136 |
} |
|
137 |
catch (Exception ex) |
|
138 |
{ |
|
139 |
MessageBox.Show("변환 이미지의 사이즈를 줄여주십시오"); |
|
233 | 140 |
} |
234 | 141 |
} |
235 | 142 |
else |
236 | 143 |
{ |
237 |
MessageBox.Show("PDF 경로와 DPI를 확인해주세요");
|
|
144 |
MessageBox.Show("PDF 경로와 Scale 또는 Width or Height를 확인해주세요");
|
|
238 | 145 |
} |
239 | 146 | |
147 |
|
|
148 | ||
149 | ||
150 |
//Properties.Settings.Default._Dpi = Combo_Scale.Text; |
|
151 |
//Properties.Settings.Default._Height = Txt_Length.Text; |
|
152 |
//Properties.Settings.Default._Width = Txt_Width.Text; |
|
153 |
//Properties.Settings.Default.Save(); |
|
154 |
///// ConvertPdfToImage(Txt_PDFPath.Text); |
|
155 |
///// |
|
156 |
|
|
157 | ||
158 | ||
159 |
//pdftron.PDFNet.Initialize("daelim.co.kr(Doftech Corp):CPU:2::W:AMC(20120315):EF6E886F25A414FFB5F8C1F2999CF2DA33DC6C5164315BAF7011B87AF0FA"); |
|
160 |
//using (PDFDoc doc = new PDFDoc(Txt_PDFPath.Text)) |
|
161 |
//{ |
|
162 |
// ImageCodecInfo DefaultImageCodecInfo = GetEncoderInfo("image/png"); |
|
163 |
// EncoderParameters DefaultEncoderParameters = new EncoderParameters(2); |
|
164 |
// System.Drawing.Imaging.Encoder QualityEncoder = System.Drawing.Imaging.Encoder.Quality; |
|
165 |
// System.Drawing.Imaging.Encoder ColorDepthEncoder = System.Drawing.Imaging.Encoder.ColorDepth; |
|
166 |
// DefaultEncoderParameters.Param[0] = new EncoderParameter(QualityEncoder, 100L); |
|
167 |
// DefaultEncoderParameters.Param[1] = new EncoderParameter(ColorDepthEncoder, 1L); |
|
168 | ||
169 |
// #region 이미지 만들기 |
|
170 |
// for (int i = 1; i < doc.GetPageCount() + 1; i++) |
|
171 |
// { |
|
172 |
// string sFileName = ""; |
|
173 |
// string pagePath = sPathNonExtension; |
|
174 |
// if (i > 1) |
|
175 |
// { |
|
176 |
// pagePath = sPathNonExtension + "_" + i; |
|
177 |
// } |
|
178 |
// try |
|
179 |
// { |
|
180 |
// using (pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw()) |
|
181 |
// { |
|
182 |
// ElementBuilder bld = new ElementBuilder(); |
|
183 |
// ElementWriter writer = new ElementWriter(); |
|
184 |
// if (Chk_Scale.Checked) |
|
185 |
// { |
|
186 |
// float fDpix = 600; |
|
187 |
// float fDpiy = 600; |
|
188 |
// try |
|
189 |
// { |
|
190 |
// fDpix = float.Parse(Combo_Scale.Text); |
|
191 |
// fDpiy = float.Parse(Combo_Scale.Text); |
|
192 |
// } |
|
193 |
// catch |
|
194 |
// { } |
|
195 |
|
|
196 |
// var rotation = doc.GetPage(i).GetRotation(); |
|
197 |
|
|
198 |
// draw.SetDPI(fDpix); |
|
199 |
// sFileName = pagePath + "_" + fDpix + ".jpeg"; |
|
200 |
// } |
|
201 |
// else |
|
202 |
// { |
|
203 |
// var widthData =int.Parse(Txt_Width.Text); |
|
204 |
// int heightData = int.Parse(Txt_Length.Text); |
|
205 |
|
|
206 |
// var rotation = doc.GetPage(i).GetRotation(); |
|
207 |
// draw.SetImageSize(widthData, heightData, true); |
|
208 |
// sFileName = pagePath + "_" + widthData + "_" + heightData + ".png"; |
|
209 |
// } |
|
210 |
// draw.SetAntiAliasing(false); |
|
211 |
// draw.SetImageSmoothing(false); |
|
212 |
// Bitmap newBmp_ = draw.GetBitmap(doc.GetPage(i)); |
|
213 | ||
214 |
// using (MemoryStream _savestream = new MemoryStream()) |
|
215 |
// { |
|
216 |
// try |
|
217 |
// { |
|
218 |
// newBmp_.Save(_savestream, DefaultImageCodecInfo, DefaultEncoderParameters); |
|
219 |
// using (Bitmap bmpImage = new Bitmap(_savestream)) |
|
220 |
// { |
|
221 |
// ObjSet objset = new ObjSet(); |
|
222 |
// Obj jbig2_hint = objset.CreateName("png"); |
|
223 |
// bmpImage.Save(sFileName, ImageFormat.Png); |
|
224 |
// bmpImage.Dispose(); |
|
225 |
// // Do something with the Bitmap object |
|
226 |
// } |
|
227 |
// } |
|
228 |
// catch (Exception ex) |
|
229 |
// { |
|
230 |
// MessageBox.Show("err" + "\n" + ex.ToString() + "\n" + ex.Message); |
|
231 |
// } |
|
232 | ||
233 |
// } |
|
234 |
// GC.Collect(); |
|
235 |
// GC.WaitForPendingFinalizers(); |
|
236 |
// } |
|
237 |
// } |
|
238 |
// catch (Exception ex) |
|
239 |
// { |
|
240 |
// MessageBox.Show("err2" + "\n" + ex.ToString() + "\n" + ex.Message); |
|
241 |
// // return false; |
|
242 |
// } |
|
243 |
// } |
|
244 |
// if (doc.GetPageCount() > 0) |
|
245 |
// { |
|
246 |
// MessageBox.Show("변환완료"); |
|
247 |
// } |
|
248 |
// #endregion |
|
249 |
//} |
|
240 | 250 |
} |
251 | ||
252 |
|
|
241 | 253 |
} |
242 | 254 |
} |
DTI_PID/PDF_TO_IMAGE/PDF_TO_IMAGE.csproj | ||
---|---|---|
72 | 72 |
<Prefer32Bit>true</Prefer32Bit> |
73 | 73 |
</PropertyGroup> |
74 | 74 |
<ItemGroup> |
75 |
<Reference Include="PDFNet, Version=5.8.0.0, Culture=neutral, PublicKeyToken=36167be3f67ac39c, processorArchitecture=x86"> |
|
76 |
<SpecificVersion>False</SpecificVersion> |
|
77 |
<HintPath>.\PDFNet.dll</HintPath> |
|
78 |
</Reference> |
|
75 |
<Reference Include="DevExpress.Docs.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> |
|
76 |
<Reference Include="DevExpress.Pdf.v18.1.Core, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> |
|
79 | 77 |
<Reference Include="System" /> |
80 | 78 |
<Reference Include="System.ComponentModel.DataAnnotations" /> |
81 | 79 |
<Reference Include="System.Core" /> |
DTI_PID/PDF_TO_IMAGE/Properties/Settings.Designer.cs | ||
---|---|---|
12 | 12 |
|
13 | 13 |
|
14 | 14 |
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
15 |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
|
15 |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
|
16 | 16 |
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
17 | 17 |
|
18 | 18 |
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
... | ... | |
25 | 25 |
|
26 | 26 |
[global::System.Configuration.UserScopedSettingAttribute()] |
27 | 27 |
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
28 |
[global::System.Configuration.DefaultSettingValueAttribute("")] |
|
29 |
public string _Dpi {
|
|
28 |
[global::System.Configuration.DefaultSettingValueAttribute("0")]
|
|
29 |
public int _Scale {
|
|
30 | 30 |
get { |
31 |
return ((string)(this["_Dpi"]));
|
|
31 |
return ((int)(this["_Scale"]));
|
|
32 | 32 |
} |
33 | 33 |
set { |
34 |
this["_Dpi"] = value;
|
|
34 |
this["_Scale"] = value;
|
|
35 | 35 |
} |
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
[global::System.Configuration.UserScopedSettingAttribute()] |
39 | 39 |
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
40 |
[global::System.Configuration.DefaultSettingValueAttribute("")] |
|
41 |
public string _Height {
|
|
40 |
[global::System.Configuration.DefaultSettingValueAttribute("0")]
|
|
41 |
public int _LengthType {
|
|
42 | 42 |
get { |
43 |
return ((string)(this["_Height"]));
|
|
43 |
return ((int)(this["_LengthType"]));
|
|
44 | 44 |
} |
45 | 45 |
set { |
46 |
this["_Height"] = value;
|
|
46 |
this["_LengthType"] = value;
|
|
47 | 47 |
} |
48 | 48 |
} |
49 | 49 |
|
50 | 50 |
[global::System.Configuration.UserScopedSettingAttribute()] |
51 | 51 |
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
52 |
[global::System.Configuration.DefaultSettingValueAttribute("")] |
|
53 |
public string _Width {
|
|
52 |
[global::System.Configuration.DefaultSettingValueAttribute("0")]
|
|
53 |
public string _Length {
|
|
54 | 54 |
get { |
55 |
return ((string)(this["_Width"]));
|
|
55 |
return ((string)(this["_Length"]));
|
|
56 | 56 |
} |
57 | 57 |
set { |
58 |
this["_Width"] = value; |
|
58 |
this["_Length"] = value; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
[global::System.Configuration.UserScopedSettingAttribute()] |
|
63 |
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|
64 |
[global::System.Configuration.DefaultSettingValueAttribute("True")] |
|
65 |
public bool _UseScale { |
|
66 |
get { |
|
67 |
return ((bool)(this["_UseScale"])); |
|
68 |
} |
|
69 |
set { |
|
70 |
this["_UseScale"] = value; |
|
59 | 71 |
} |
60 | 72 |
} |
61 | 73 |
} |
DTI_PID/PDF_TO_IMAGE/Properties/Settings.settings | ||
---|---|---|
2 | 2 |
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PDF_TO_IMAGE.Properties" GeneratedClassName="Settings"> |
3 | 3 |
<Profiles /> |
4 | 4 |
<Settings> |
5 |
<Setting Name="_Dpi" Type="System.String" Scope="User">
|
|
6 |
<Value Profile="(Default)" />
|
|
5 |
<Setting Name="_Scale" Type="System.Int32" Scope="User">
|
|
6 |
<Value Profile="(Default)">0</Value>
|
|
7 | 7 |
</Setting> |
8 |
<Setting Name="_Height" Type="System.String" Scope="User">
|
|
9 |
<Value Profile="(Default)" />
|
|
8 |
<Setting Name="_LengthType" Type="System.Int32" Scope="User">
|
|
9 |
<Value Profile="(Default)">0</Value>
|
|
10 | 10 |
</Setting> |
11 |
<Setting Name="_Width" Type="System.String" Scope="User"> |
|
12 |
<Value Profile="(Default)" /> |
|
11 |
<Setting Name="_Length" Type="System.String" Scope="User"> |
|
12 |
<Value Profile="(Default)">0</Value> |
|
13 |
</Setting> |
|
14 |
<Setting Name="_UseScale" Type="System.Boolean" Scope="User"> |
|
15 |
<Value Profile="(Default)">True</Value> |
|
13 | 16 |
</Setting> |
14 | 17 |
</Settings> |
15 | 18 |
</SettingsFile> |
내보내기 Unified diff