Skip to content

Commit

Permalink
Merge pull request #3 from rfog/master
Browse files Browse the repository at this point in the history
My new build modernizes the project and solves a bug when the ZIP/RAR files aren't zipped ordered by name
  • Loading branch information
dragouf authored Apr 18, 2021
2 parents cd6d14e + 4eea043 commit 21a385b
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 35 deletions.
36 changes: 19 additions & 17 deletions CbrConverter/CbrConverter.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CbrConverter</RootNamespace>
<AssemblyName>CbrConverter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -56,27 +56,28 @@
<ApplicationIcon>1335329130_comic-book.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip.Reduced">
<HintPath>Libraries\Ionic.Zip.Reduced.dll</HintPath>
<Reference Include="BouncyCastle.Crypto, Version=1.8.6.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.6.1\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="itextsharp, Version=4.1.6.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\itextsharp.dll</HintPath>
<Reference Include="DotNetZip, Version=1.14.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.14.0\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.8.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\SharpCompress.dll</HintPath>
<Reference Include="itextsharp, Version=5.5.13.2, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL">
<HintPath>..\packages\iTextSharp.5.5.13.2\lib\itextsharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.FileProviders.Abstractions, Version=3.1.9.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.FileProviders.Abstractions.3.1.9\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=3.1.9.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Primitives.3.1.9\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.26.0.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.26.0\lib\net46\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AboutorForm.cs">
Expand Down Expand Up @@ -121,6 +122,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
28 changes: 17 additions & 11 deletions CbrConverter/Converter/Extract.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using System.Drawing.Imaging;
using System.Drawing;
using Ionic.Zip;
using System.ComponentModel;
using SharpCompress.Archive;
using SharpCompress.Archives;
using SharpCompress.Common;

namespace CbrConverter
Expand Down Expand Up @@ -50,7 +48,7 @@ public void BeginExtraction(bool cbr2pdf, bool pdf2cbz, bool reduceSize, bool de
//it's a file so i start the single extraction thread
//check if cbr
string ext = Path.GetExtension(DataAccess.Instance.g_WorkingFile).ToLower();
if ((string.Compare(ext, ".cbr") == 0 || (string.Compare(ext, ".cbz") == 0)) && (_Cbr2Pdf))
if ((string.Compare(ext, ".zip") == 0 || string.Compare(ext, ".rar") == 0 || string.Compare(ext, ".cbr") == 0 || string.Compare(ext, ".cbz") == 0) && _Cbr2Pdf)
{

Thread extract = new Thread(ConvertCbrToPdf);
Expand Down Expand Up @@ -163,6 +161,13 @@ private void ConvertCbrToPdf()
divider = 50;
CurOneStep = divider / CurOneStep;

var options = new ExtractionOptions
{
Overwrite = true,
PreserveAttributes = false,
PreserveFileTime = true
};

//extract the file into the folder
foreach (var entry in archive.Entries)
{
Expand All @@ -171,9 +176,9 @@ private void ConvertCbrToPdf()
if (DataAccess.Instance.g_Processing) //this is to stop the thread if stop button is pressed
{

string path = Path.Combine(temporaryDir, Path.GetFileName(entry.FilePath));
string path = Path.Combine(temporaryDir, Path.GetFileName(entry.Key));
//entry.WriteToDirectory(@"C:\temp", ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
entry.WriteToFile(path, ExtractOptions.Overwrite);
entry.WriteToFile(path, options);

DataAccess.Instance.g_curProgress += CurOneStep;
evnt_UpdateCurBar();
Expand Down Expand Up @@ -331,12 +336,12 @@ private void ExtractMultipleFiles(string currentDir, double singval)
DataAccess.Instance.g_WorkingFile = file;
try
{
string ext = Path.GetExtension(DataAccess.Instance.g_WorkingFile);
if (((string.Compare(ext, ".cbr") == 0) || (string.Compare(ext, ".cbz") == 0) || (string.Compare(ext, ".CBZ") == 0) || (string.Compare(ext, ".CBR") == 0)) && (_Cbr2Pdf))
string ext = Path.GetExtension(DataAccess.Instance.g_WorkingFile).ToLower();
if (((string.Compare(ext, ".cbr") == 0) || (string.Compare(ext, ".rar") == 0) || (string.Compare(ext, ".cbz") == 0) || (string.Compare(ext, ".zip") == 0)) && (_Cbr2Pdf))
{
ConvertCbrToPdf();
}
else if (((string.Compare(ext, ".pdf") == 0) || (string.Compare(ext, ".PDF") == 0)) && (_Pdf2Cbz))
else if ((string.Compare(ext, ".pdf") == 0) && (_Pdf2Cbz))
{
ConvertPdfToCbr(file);
}
Expand Down Expand Up @@ -365,7 +370,8 @@ private void GeneratePdf()
var writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
document.Open();

string[] imageFiles = Directory.GetFiles(temporaryDir);
var imageFiles = Directory.GetFiles(temporaryDir).ToList();
imageFiles.Sort();

//count for progression bar
CurOneStep = imageFiles.Count();
Expand Down Expand Up @@ -396,7 +402,7 @@ private void GeneratePdf()

//checking file extension
string ext = Path.GetExtension(imageFile).ToLower();
if ((string.Compare(ext, ".jpg") == 0) || (string.Compare(ext, ".jpeg") == 0) || (string.Compare(ext, ".png") == 0) || (string.Compare(ext, ".bmp") == 0) || (string.Compare(ext, ".new") == 0))
if ((string.Compare(ext, ".tif") == 0) || (string.Compare(ext, ".jpg") == 0) || (string.Compare(ext, ".jpeg") == 0) || (string.Compare(ext, ".png") == 0) || (string.Compare(ext, ".bmp") == 0) || (string.Compare(ext, ".new") == 0))
{
//var size = iTextSharp.text.PageSize.A4;
var img = iTextSharp.text.Image.GetInstance(imageFile);
Expand Down
4 changes: 2 additions & 2 deletions CbrConverter/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions CbrConverter/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions CbrConverter/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.FileProviders.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="SharpCompress" publicKeyToken="afb0a02973931d96" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-0.26.0.0" newVersion="0.26.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
13 changes: 13 additions & 0 deletions CbrConverter/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.6.1" targetFramework="net461" />
<package id="DotNetZip" version="1.14.0" targetFramework="net461" />
<package id="iTextSharp" version="5.5.13.2" targetFramework="net461" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="3.1.9" targetFramework="net461" />
<package id="Microsoft.Extensions.Primitives" version="3.1.9" targetFramework="net461" />
<package id="SharpCompress" version="0.26.0" targetFramework="net461" />
<package id="System.Buffers" version="4.5.1" targetFramework="net461" />
<package id="System.Memory" version="4.5.4" targetFramework="net461" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
</packages>
Binary file added Compiled/v1.2/CbrConverter1.2.zip
Binary file not shown.
1 change: 1 addition & 0 deletions Compiled/v1.2/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ What's new in this fork :
- You can choose output folder
- Error won't pause processing

__Note :__ If you don't have visual studio you can download the executable file here: https://github.com/dragouf/CbrPdfConverter/releases/tag/1.1
__Note :__ If you don't have visual studio you can download the executable file here: https://github.com/rfog/CbrPdfConverter/blob/master/Compiled/v1.2/CbrConverter1.2.zip

<p align="center">
<img src="http://i.imgur.com/m34YK9n.png" alt="CbrConverter screenshot" />
Expand Down

0 comments on commit 21a385b

Please sign in to comment.