Commit 858d7d86 authored by AP matsuo koji's avatar AP matsuo koji 😲

Add CSRenderProj

parents
/.PDFData

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.960
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSRender", "CSRender\CSRender.csproj", "{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B1418EB-CA5D-4F34-9026-020B0B30AE79}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
{
"Head": {
"HashBaseName": "72.0_Crop_JPG_91",
"HashFilePath": "C:\\Users\\cozy\\Documents\\GitDoc\\Scripts\\WinRT\\CSRender\\CSRender\\BasehashPDF\\RenderHash_72.0_Crop_JPG_91.json",
"Dpi": "72.0",
"Box": "Crop",
"ImType": "JPG",
"JQ": "91"
},
"Files": [
{
"Key": "BaseHash.pdf",
"Value": {
"UpdateTime": "\/Date(1585355435085)\/",
"UpdateTimeStr": "2020\/03\/28 9:30:35",
"PageHashCode": [
"B7D69FA446C6C64F985AA3446C6D5C6FD0A70C4C2F1E9AB55AB10993A5A67313"
]
}
}
]
}
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\PdfiumViewer.Native.x86_64.v8-xfa.2018.4.8.256\build\PdfiumViewer.Native.x86_64.v8-xfa.props" Condition="Exists('..\packages\PdfiumViewer.Native.x86_64.v8-xfa.2018.4.8.256\build\PdfiumViewer.Native.x86_64.v8-xfa.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FD99EFAA-2479-4E3B-BD1A-5B785288E3B3}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CSRender</RootNamespace>
<AssemblyName>CSRender</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="PdfiumViewer, Version=2.13.0.0, Culture=neutral, PublicKeyToken=91e4789cfb0609e0, processorArchitecture=MSIL">
<HintPath>..\packages\PdfiumViewer.2.13.0.0\lib\net20\PdfiumViewer.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Windows, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Annotated\Windows.winmd</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSRender.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<EmbeddedResource Include="RES\BaseHash.pdf" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="CSRender_ReadMe.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>このプロジェクトは、このコンピューター上にない NuGet パッケージを参照しています。それらのパッケージをダウンロードするには、[NuGet パッケージの復元] を使用します。詳細については、http://go.microsoft.com/fwlink/?LinkID=322105 を参照してください。見つからないファイルは {0} です。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\PdfiumViewer.Native.x86_64.v8-xfa.2018.4.8.256\build\PdfiumViewer.Native.x86_64.v8-xfa.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PdfiumViewer.Native.x86_64.v8-xfa.2018.4.8.256\build\PdfiumViewer.Native.x86_64.v8-xfa.props'))" />
</Target>
</Project>
\ No newline at end of file
V1.3.0.4:2021/04/29 :Helpの記述抜け "/Result"の対応
V1.3.0.3:2020/11/22 :/Result <比較結果> を実装。diff画像を出力
V1.3.0.2:2020/07/11 :不具合修正
比較時に差異があるとクラッシュしていた。streamのフラッシュミス
V1.3.0.1:2020/06/20 :不具合修正
2つのファイルの比較が常にOKになっていた可能性があるので修正
V1.3.0.0:2020/06/10 :基本的なPDFの画像化(PNG,JPG)とPDFの比較を行えるもの
以下、CSRender /? のヘルプ内容です]
TestSampleフォルダに使用例がありますので合わせて参照のこと
CSRender.exe [/<Opts>] <PDFPath or PDFDir>
* Render of PDF file. available 3 command mode:[Basic Rendering] [Make Hash command] [Compare command], and [Render Options]
PDFの画像化は[Basic Rendering]。
比較は/MkHash([Make Hash command])後に、/FC([Compare command])で高速実行できます。
[Basic Rendering] 基本的なレンダリング
CSRender.exe [/<Render Options>] <PDFPath|PDFDir>
/F <pdfPath|pdfDir> : pdfPath(pdfファイル名|ディレクトリ) /Fは省略可能
/O <output directory> : 出力ディレクトリ。省略時は"IMG"フォルダ
[Render Options] レンダリングオプション
/D <解像度> : 解像度指定 9 - 300dpi(default=72dpi)
/JPG,/JPEG,/PNG,/TIF,/TIFF,/GIF,/BMP: Select one output format.(default=/JPG)
/JPEGQ <quality>: Jpegの品質指定1-100(default=91)
/P <PageRange> : ページの範囲を指定する(省略時は全ページ)
連続した範囲を指定する場合は、ハイフン('-')を用いる。終了側を省略すると最終pageまで。
複数のページを指定する場合は、カンマ(',')を用いる
Ex. /P "1,2,30-100" //1,2pages and 30-100pages.
[Unsupport] 未対応↓
/L <input List text> : 入力PDFファイルリスト(*unsupport)
/T <tempPath> : テンポラリフォルダを指定(省略時は出力先フォルダと同じ(*unsupport no need)
/OP <0|1> : オーバープリントのOn/Off (省略時は1)(*unsupport allways on[1])
/U <0|1> : 同名上書き設定 0:上書きしない 1:上書き(*unsupport allways overwrite[1])
/OFFSET <X> <Y> : ミリ単位でオフセットを指定する(省略時は共に0mm)(*unsupport)
/PDFium <0or1>: GoogoleのPDFiumViewerエンジンを使用する(default=1>
【未】/BM,/BT,/BA,/BA,/BC: Select one box.(default=/BC:CrobBox): Boxies:MediaBox/BleedBox/TrimBox/ArtBox/CropBox
[Make Hash command] 比較用ハッシュ値作成コマンド
CSRender.exe /MkHash ...<Render Options>... <PDF|PDF dir>
/MKHash : ハッシュ値を出力する。前記の[Render Options]を指定すること
[HASHファイル作成]
[Compare command] 比較コマンド
CSRender.exe /FC ...<Render Options>... <Target PDF|PDF dir> <Reference PDF|PDF dir>
/FC : 2つのPDFを比較する。前記の[Render Options]を指定すること。無名引数が2つ必要です
事前に/MkHashを実行しておくことで高速に処理できる
【未】/RESULT <result file> : 比較結果を格納するファイルパス
/FCコマンドを指定すると一致したら0,不一致なら1を返却するようになる
<result file>は、<pageNum(1始まり)>,<OK or NG>の行で構成される
[ELSE ] その他のオプション
/PDFium <0|1>:PDFiumライブラリを使う,デフォルト=1
/NoExeSepa :実行分離しない(遅い)
内部コマンド:/SubExe <WCF_PipeAddress> :実行分離,PDF単位で別Processで処理
/H or /? : This help
This diff is collapsed.
== 引数のクラス化
RenderDoc() :メインの呼び出し
RenderPage() :ページ毎の処理。画像やHashも作成(選択)
RenderDocCompare(): メインの比較モード
RenderPageStream() : Compare時に呼び出す。Streamのみで、画像作成、Hash値は上位で実装するようにした。
→ RenderPage()もRenderPageStreamにして、RenderDoc()側で画像生成もあり
→ 複数PDFの処理は更にプログラムメインでPallarelで処理
→ asyncのスレッド処理はRenderDoc/RenderDocCompareでページの並行処理で使う
== 引数クラス
* スレッドを考えると書き換える情報はクラスに含めてはいけない
pegeN,Hashを除くべき
. まとめたクラスパラメータ
→ 結論:Render条件パラメータのみクラス化すべき→Hashでできているのかな?
class RenderParams {
// 基本操作パラメータ
string inPdfPath;//="" 対象PDF,ディレクトリはProgram側で対処
string inRefPdfPath; 比較モードのみ。そのPDFパス
string inOutputDir; //= "", 画像やハッシュの出力先が必要な場合
// Doc処理の操作パラメータ
string inPageRange;// = "1-*",
bool bSaveImage;// = true, //画像出力を伴う場合のみ
bool bHash;// = false, //ハッシュ値が必要な場合のみ
UtHash.HashDataxk inHashData=null //出力ハッシュコンテナ
string inMode;// = "pageBitMap", // デバッグ用
// Render条件パラメータ(すべてにほぼ必要)
{
double inDpi; //= 9.0,
string inImageType; //= "JPG",
int inJpegQ; = //0,
string inBoxType;// = "Crop",
}
}
class RenderParams {
string inPdfPath;//=""
string inOutputDir; //= "",
double inDpi; //= 9.0,
string inImageType; //= "JPG",
int inJpegQ; = //0,
string inBoxType;// = "Crop",
string inPageRange;// = "1-*",
string inMode;// = "pageBitMap",
bool bSaveImage;// = true,
bool bHash;// = false,
UtHash.HashDataxk inHashData=null
}
// RenderPdfDocCompare
string inPdfPath, // pdfもしくはディレクトリの場合あり→無い!pdfのみで、program側のループでディレクトリ展開
string inRefPdfPath,
string inDir = "", // 結果の出力先 未使用。diff画像が生成が未達成なのでその時の出力先とすべき
double inDpi = 9.0,
string inImageType = "JPG",
int inJpegQ = 0,
string inBoxType = "Crop",
string inPageRange = "1-*",
string inMode = "pageBitMap",
bool bHash = false,
UtHash.HashDatax inHashDataTgt=null,
UtHash.HashDatax inHashDataRef=null
// RenderPage
// Need:
PdfDocument inPdfDoc, // Need GetPage() only. (Total page number);
// 総ページ数のためだけに必要。あってもいいでしょう
PdfPage inPdfPage, // Target Page Data(page.index:0-x)
string inOutputPath,// Imageのパス
string inOutputDir = "",// これ必要?→不要が確定
ref string inOutputHashCode, // ページハッシュコード出力の受け取り
// Optional:
double inDpi = 72.0,
string inEncName = "JPG", //画像フォーマット、Saveのときのみ
int inJpegQ = 91,
string inBoxType = "Crop",
bool bSaveImage = true,// ファイル保存有無。ハッシュ値計算のみのときにfalseにする
bool bHash = false
// RenderPageStream
// Need:
PdfDocument inPdfDoc, // Need GetPage() only. (Total page number);
PdfPage inPdfPage, // Target Page Data(page.index:0-x)
string otPath, // 不要確定
// Optional:
double inDpi = 72.0,
string inBoxType = "Crop"
// 出力画像であるJpeg,EncNameが不要
//
== 排他制御関係
#if COMMNET
http://espresso3389.hatenablog.com/entry/20080827/1219787248
安全なMutex
ということで、次のようなラッパークラスを作った。
class SessionLock : IDisposable
{
public SessionLock(string mutexName)
{
m_mutex = new Mutex(false, mutexName);
m_mutex.WaitOne();
}
public void Dispose()
{
try
{
m_mutex.ReleaseMutex();
m_mutex.Close();
}
catch { }
}
Mutex m_mutex;
}
これならば、
using System;
using System.Threading;
namespace MutexTest
{
...
public class MutexTest
{
public static void Main()
{
using (new SessionLock("Hello, world"))
{
Console.WriteLine("Hey, I'm in the protected world!");
Thread.Sleep(10000);
Console.WriteLine("...");
}
}
}
}
#endif
== 2020/5/31
WCF+SortedDictionaryで一旦動作した。
残件::
* Compare
* help
* 共通化
* 強制終了
* BaseHashの調整
* 標準出力
* WCFのデータ整理
* WCFのジェネリック化
* namespace
* vim
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("CSRender")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CSRender")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]
// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
[assembly: Guid("fd99efaa-2479-4e3b-bd1a-5b785288e3b3")]
// アセンブリのバージョン情報は次の 4 つの値で構成されています:
//
// メジャー バージョン
// マイナー バージョン
// ビルド番号
// Revision
//
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.4")]
[assembly: AssemblyFileVersion("1.3.0.4")]
// rev:1.3.0.4:2021/04/29 :Helpの記述抜け "/Result"の対応
// rev:1.3.0.3:2020/11/22 :/Result <比較結果> を実装。diff画像を出力
// rev:1.3.0.2: streamのフラッシュミス 比較時に差異があるとクラッシュしていた。
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
// ランタイム バージョン:4.0.30319.42000
//
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
// コードが再生成されるときに損失したりします。
// </auto-generated>
//------------------------------------------------------------------------------
namespace CSRender.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="PdfiumViewer" version="2.13.0.0" targetFramework="net461" />
<package id="PdfiumViewer.Native.x86_64.v8-xfa" version="2018.4.8.256" targetFramework="net461" />
</packages>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment