Skip to content

Commit 103d323

Browse files
committed
优化相关引用,修改打包方式,减少文件体积
1 parent 30a5c71 commit 103d323

File tree

10 files changed

+155
-56
lines changed

10 files changed

+155
-56
lines changed

PDFQFZ/FodyWeavers.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<Costura />
3+
</Weavers>

PDFQFZ/FodyWeavers.xsd

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4+
<xs:element name="Weavers">
5+
<xs:complexType>
6+
<xs:all>
7+
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
8+
<xs:complexType>
9+
<xs:all>
10+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11+
<xs:annotation>
12+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13+
</xs:annotation>
14+
</xs:element>
15+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16+
<xs:annotation>
17+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18+
</xs:annotation>
19+
</xs:element>
20+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
21+
<xs:annotation>
22+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
23+
</xs:annotation>
24+
</xs:element>
25+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
26+
<xs:annotation>
27+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
28+
</xs:annotation>
29+
</xs:element>
30+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
31+
<xs:annotation>
32+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
33+
</xs:annotation>
34+
</xs:element>
35+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
36+
<xs:annotation>
37+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
38+
</xs:annotation>
39+
</xs:element>
40+
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
41+
<xs:annotation>
42+
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
43+
</xs:annotation>
44+
</xs:element>
45+
</xs:all>
46+
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
47+
<xs:annotation>
48+
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
49+
</xs:annotation>
50+
</xs:attribute>
51+
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
52+
<xs:annotation>
53+
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
54+
</xs:annotation>
55+
</xs:attribute>
56+
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
57+
<xs:annotation>
58+
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
59+
</xs:annotation>
60+
</xs:attribute>
61+
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
62+
<xs:annotation>
63+
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
64+
</xs:annotation>
65+
</xs:attribute>
66+
<xs:attribute name="DisableCompression" type="xs:boolean">
67+
<xs:annotation>
68+
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
69+
</xs:annotation>
70+
</xs:attribute>
71+
<xs:attribute name="DisableCleanup" type="xs:boolean">
72+
<xs:annotation>
73+
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
74+
</xs:annotation>
75+
</xs:attribute>
76+
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
77+
<xs:annotation>
78+
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
79+
</xs:annotation>
80+
</xs:attribute>
81+
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
82+
<xs:annotation>
83+
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
84+
</xs:annotation>
85+
</xs:attribute>
86+
<xs:attribute name="ExcludeAssemblies" type="xs:string">
87+
<xs:annotation>
88+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
89+
</xs:annotation>
90+
</xs:attribute>
91+
<xs:attribute name="IncludeAssemblies" type="xs:string">
92+
<xs:annotation>
93+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
94+
</xs:annotation>
95+
</xs:attribute>
96+
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
97+
<xs:annotation>
98+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
99+
</xs:annotation>
100+
</xs:attribute>
101+
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
102+
<xs:annotation>
103+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
104+
</xs:annotation>
105+
</xs:attribute>
106+
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
107+
<xs:annotation>
108+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
109+
</xs:annotation>
110+
</xs:attribute>
111+
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
112+
<xs:annotation>
113+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
114+
</xs:annotation>
115+
</xs:attribute>
116+
<xs:attribute name="PreloadOrder" type="xs:string">
117+
<xs:annotation>
118+
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
119+
</xs:annotation>
120+
</xs:attribute>
121+
</xs:complexType>
122+
</xs:element>
123+
</xs:all>
124+
<xs:attribute name="VerifyAssembly" type="xs:boolean">
125+
<xs:annotation>
126+
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
127+
</xs:annotation>
128+
</xs:attribute>
129+
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
130+
<xs:annotation>
131+
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
132+
</xs:annotation>
133+
</xs:attribute>
134+
<xs:attribute name="GenerateXsd" type="xs:boolean">
135+
<xs:annotation>
136+
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
137+
</xs:annotation>
138+
</xs:attribute>
139+
</xs:complexType>
140+
</xs:element>
141+
</xs:schema>

PDFQFZ/Form1.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PDFQFZ/Form1.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
using System.Collections.Generic;
1212
using iTextSharp.text;
1313
using iTextSharp.text.exceptions;
14-
using Org.BouncyCastle.Crypto.Generators;
1514
using PDFQFZ.Library;
16-
using System.Text;
1715
using System.Threading.Tasks;
1816

1917
namespace PDFQFZ
@@ -36,21 +34,8 @@ public partial class Form1 : Form
3634
private string strIniFilePath = $@"{Application.StartupPath}\config.ini";//获取INI文件路径
3735

3836

39-
System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)//把DLL打包到EXE需要用到
40-
{
41-
// 执行解析逻辑,加载所需的程序集
42-
string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", "");
43-
dllName = dllName.Replace(".", "_");
44-
if (dllName.EndsWith("_resources")) return null;
45-
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
46-
byte[] bytes = (byte[])rm.GetObject(dllName);
47-
return System.Reflection.Assembly.Load(bytes);
48-
}
4937
public Form1(string[] args)
5038
{
51-
//在InitializeComponent()之前调用
52-
53-
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
5439
InitializeComponent();
5540
// 在这里处理命令行参数
5641
if (args.Length > 0)
@@ -1197,7 +1182,7 @@ public void PDFToiPDF(string pdfPath)
11971182
//原版方法2
11981183
PDFFile pdfFile = PDFFile.Open(pdfPath);
11991184
Bitmap[] bitmaps = new Bitmap[pdfFile.PageCount];
1200-
int dpi = 300; //原版方法最好默认300
1185+
int dpi = 200; //原版方法最好默认300
12011186
for (int i = 0; i < pdfFile.PageCount; i++)
12021187
{
12031188
Bitmap pageImage = pdfFile.GetPageImage(i, dpi); //这个地方转换导致原有水印和背景透明度丢失,下面的方法解决

PDFQFZ/PDFQFZ.csproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,13 @@
7474
<StartupObject>PDFQFZ.Program</StartupObject>
7575
</PropertyGroup>
7676
<ItemGroup>
77-
<Reference Include="O2S.Components.PDFRender4NET">
78-
<HintPath>D:\Downloads\O2S.Components.PDFRender4NET.dll</HintPath>
77+
<Reference Include="O2S.Components.PDFRender4NET, Version=4.5.1.2, Culture=neutral, processorArchitecture=MSIL">
78+
<SpecificVersion>False</SpecificVersion>
79+
<HintPath>D:\Downloads\428a8-main\O2S.Components.PDFRender4NET.dll</HintPath>
7980
</Reference>
80-
<Reference Include="System" />
81-
<Reference Include="System.Core" />
82-
<Reference Include="System.Security" />
83-
<Reference Include="System.Xml.Linq" />
84-
<Reference Include="System.Data.DataSetExtensions" />
85-
<Reference Include="Microsoft.CSharp" />
8681
<Reference Include="System.Data" />
87-
<Reference Include="System.Deployment" />
8882
<Reference Include="System.Drawing" />
8983
<Reference Include="System.Windows.Forms" />
90-
<Reference Include="System.Xml" />
9184
</ItemGroup>
9285
<ItemGroup>
9386
<Compile Include="Form1.cs">
@@ -100,8 +93,6 @@
10093
<Compile Include="Library\IniFileHelper.cs" />
10194
<Compile Include="Program.cs" />
10295
<Compile Include="Properties\AssemblyInfo.cs" />
103-
<None Include="Resources\O2S.Components.PDFRender4NET.dll" />
104-
<None Include="Resources\itextsharp.dll" />
10596
<EmbeddedResource Include="Form1.resx">
10697
<DependentUpon>Form1.cs</DependentUpon>
10798
<SubType>Designer</SubType>
@@ -145,6 +136,11 @@
145136
</BootstrapperPackage>
146137
</ItemGroup>
147138
<ItemGroup>
139+
<PackageReference Include="Costura.Fody">
140+
<Version>5.7.0</Version>
141+
<IncludeAssets>runtime;compile;build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
142+
<PrivateAssets>all</PrivateAssets>
143+
</PackageReference>
148144
<PackageReference Include="iTextSharp">
149145
<Version>5.5.13.1</Version>
150146
</PackageReference>

PDFQFZ/Properties/Resources.Designer.cs

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PDFQFZ/Properties/Resources.resx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,4 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121-
<data name="itextsharp" type="System.Resources.ResXFileRef, System.Windows.Forms">
122-
<value>..\Resources\itextsharp.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
123-
</data>
124-
<data name="O2S_Components_PDFRender4NET" type="System.Resources.ResXFileRef, System.Windows.Forms">
125-
<value>..\Resources\O2S.Components.PDFRender4NET.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
126-
</data>
127121
</root>
-944 KB
Binary file not shown.

PDFQFZ/Resources/itextsharp.dll

-3.89 MB
Binary file not shown.

pdfqfz.jpg

32.5 KB
Loading

0 commit comments

Comments
 (0)