{"text_format":"2","workbook":"xlsx","n_sheets":3,"sheets":["CSRender","pdfiumビルド手順","pdfiumviewer.cpp"],"not_rendered":{"charts":0,"images":2,"macros":0,"external_links":0,"defined_names":0,"comments":0,"pivot_tables":0},"unopened":[],"bounds":{"document_bytes":16777216,"sheet_cells":100000,"run_cost":"one","rows_first":2000,"rows_last":500,"rows_between":2000,"halvings":0,"cell_chars":16384,"cell_head_chars":4096},"cells_cut":0,"cells_raw":0,"read":"whole","date_system":"1900"}

{"sheet":"CSRender","index":0,"n_rows":76,"n_cols":10,"rows_kept":76,"cut":false,"hidden":false,"merged":[]}
[]
["1．フォルダー構成"]
[null,"\\pfsverify\\Tools\\RenderPDF"]
[null,null,"📂bin",{"$nulls":6},"// CSRenderバイナリー"]
[null,null,null,"📂Release"]
[{"$nulls":4},"📂x64"]
[{"$nulls":5},"pdfium.dll"]
[{"$nulls":5},"pdfium.dll.lib"]
[{"$nulls":5},"pdfium.dll.pdb"]
[{"$nulls":4},"CSRender.exe "]
[{"$nulls":4},"PdfiumViewer.dll "]
[{"$nulls":4},"　　・"]
[{"$nulls":4},"　　・"]
[null,null,"📂CSRender",{"$nulls":6},"// CSRenderソース"]
[null,null,null,"CSRender.cs"]
[null,null,null,"　　・"]
[null,null,null,"　　・"]
[null,null,"📂packages"]
[null,null,null,"📂PdfiumViewer.2.13.0.0",{"$nulls":5},"// オリジナルPdfiumViewer.dll (nupkg)"]
[null,null,null,"📂PdfiumViewer.Native.x86_64.v8-xfa.2018.4.8.256",{"$nulls":5},"// オリジナルpdfium.dll (nupkg)"]
[null,null,"📂pdfium",{"$nulls":6},"// 手順書、pdfiumバイナリー"]
[null,null,null,"PdfiumViewer用Pdfiumビルド手順.xlsx"]
[null,null,null,"📂Contrib"]
[{"$nulls":4},"pdfiumviewer.cpp",{"$nulls":4},"// pdfiumviewer対応のソース（修正済）"]
[{"$nulls":4},"org_pdfiumviewer.cpp",{"$nulls":4},"// オリジナル"]
[null,null,null,"📂Release"]
[{"$nulls":4},"PdfiumViewer.dll"]
[{"$nulls":4},"PdfiumViewer.pdb"]
[{"$nulls":4},"📂x64"]
[{"$nulls":5},"pdfium.dll"]
[{"$nulls":5},"pdfium.dll.pdb"]
[{"$nulls":5},"pdfium.dll.lib"]
[null,null,null,"📂debug"]
[{"$nulls":4},"PdfiumViewer.dll"]
[{"$nulls":4},"PdfiumViewer.pdb"]
[{"$nulls":4},"📂x64"]
[{"$nulls":5},"pdfium.dll"]
[{"$nulls":5},"pdfium.dll.pdb"]
[{"$nulls":5},"pdfium.dll.lib"]
[null,null,"📂PdfiumViewer-master",{"$nulls":6},"// PdfiumViewerソース"]
[null,null,"📂TestSample"]
[null,null,"CSRender2019.sln",{"$nulls":6},"// 新CSRenderビルドプロジェクト"]
[]
[null,"※ PdfiumViewer(2.13)ソースの取得先"]
[null,null,"https://github.com/pvginkel/PdfiumViewer.git"]
[]
["２．CSRenderのビルド"]
[null,"１）CSRender2019.slnをVS2019で開く"]
[null,"２）ソリューション構成を[Release]、プラットフォームを[Any CPU]に"]
[null,"３）ビルド・ソリューションのビルドメニュー押下"]
[null,"４）バイナリーは"]
[null,null,"\\pfsverify\\Tools\\RenderPDF\\bin\\\\Release"]
[null,null,null,"CSRender.exe"]
[null,"      ",null,"PdfiumViewer.dll"]
[null,"       に作成される"]
[]
["３．CSRenderのデバッグ時の注意"]
[null,"１）CSRender2019.slnをVS2019で開く"]
[null,"２）ソリューション構成を[Debug]、プラットフォームを[Any CPU]に"]
[null,"３）ビルド・ソリューションのクリーンメニュー押下"]
[null,null,"これが無いとコンパイルされない"]
[null,null,"クリーンでは削除されないので"]
[null,null,"\\pfsverify\\Tools\\RenderPDF\\bin\\Debugの"]
[null,null,null,"CSRender.exe"]
[null,null,null,"CSRender.pdb"]
[null,null,null,"PdfiumViewer.dll"]
[null,null,null,"PdfiumViewer.pdb"]
[null,null,"を削除"]
[null,"４）ビルド・ソリューションのビルドメニュー押下"]
[null,"５）バイナリーは"]
[null,null,"\\pfsverify\\Tools\\RenderPDF\\bin\\Debug"]
[null,null,null,"CSRender.exe"]
[null,"      ",null,"PdfiumViewer.dll"]
[null,"       に作成される"]
[null,"６．デバッグ・デバッグの開始"]
[null,null,"PdfiumViewer.dll、x64/pdfium.dllの関数までデバッグできる"]

{"sheet":"pdfiumビルド手順","index":1,"n_rows":163,"n_cols":8,"rows_kept":163,"cut":false,"hidden":false,"merged":[]}
["０．Pdfiumについて"]
[null,"PDFium は chrome で利用されている PDF レンダリングエンジン"]
[null,"Apache License Version 2.0なので改変、商用利用（無償かつ無制限に使用可）も可能だと思います（自身なし）"]
[null,"ちなみに、PdfiumViewerもApache License Version 2.0です"]
[]
["１．depot_tools をダウンロードして、解凍"]
["        ","depot_toolsは、ChromiumやChromium OSのソースコードのダウンロードやレビューの管理などを行うためのスクリプト集"]
["　　　","   https://storage.googleapis.com/chrome-infra/depot_tools.zip"]
["　","　または"]
["　　　","   git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git"]
[null,"から取得"]
[]
["２．Path 環境変数に depot_tools のパスを追加　"]
[null,"Path変数の先頭にdepot_tools のパスを追加"]
[null,"※Cドライブ直下に展開した場合"]
[null,"　C:\\depot_tools"]
{"$rows_empty":25}
["3．PDFium ビルドフォルダの作成"]
[null,"コマンドプロンプトを開き、新規フォルダを作成して、そこに移動します。"]
[null,"例：E:\\Build\\\\pdfium"]
[]
["４．gclient の実行"]
[null,"gclient はChromiumプロジェクトが利用しているメタチェックアウトツール"]
[null,"ビルドフォルダへ移動し、コマンドプロンプトで"]
[null,"まずは引数無しで"]
[null,null,"gclient"]
[null,"次の引数で"]
[null,null,"gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git"]
[null,"同期するために"]
[null,null,"gclient sync -vv"]
[null,"作成された pdfium フォルダに移動"]
[]
["５．BUILD.gn の変更"]
[null,"以下を参考にBUILD.gnを変更"]
[null,"https://github.com/pvginkel/PdfiumViewer/wiki/Building-PDFium"]
[]
[null,null,"config(\"pdfium_common_config\") {"]
[null,null,"  cflags = []"]
[null,null,"  cflags_cc = []"]
[null,null,"  ldflags = []"]
[null,null,"  include_dirs = [ \".\" ,\"v8/include\"]",null,null,null,"追加"]
[null,null,"  defines = [\"FPDFSDK_EXPORTS\"]",null,null,null,"追加"]
[]
[null,null,"//Change component(\"pdfium\") to shared_library(\"pdfium\") to build a shared library;"]
[null,null,"shared_library(\"pdfium\") {",{"$nulls":4},"変更・追加"]
[null,null,"  output_name = \"pdfium\""]
[null,null,"  libs = []"]
[null,null,"  configs += [ \":pdfium_strict_config\" ]"]
[null,null,"  public_configs = [ \":pdfium_public_config\" ]"]
[null,null,"  sources = [ \"fpdfsdk/pdfiumviewer.cpp\" ]",{"$nulls":4},"追加"]
[]
["６．public\\fpdfview.h\" の変更"]
[null,"関数をExportするために変数を追加する"]
[null,"本来はargs.gnと上記のBUILD.gnで定義した変数が反映されるはずだが私に環境では反映されないので直接定義する"]
[]
[null,null,"#include <stddef.h>"]
[]
[null,null,"#if defined(_WIN32) && !defined(__WINDOWS__)"]
[null,null,"#include <windows.h>"]
[null,null,"#endif"]
[]
[null,null,"#define FPDF_IMPLEMENTATION 1",{"$nulls":4},"追加"]
[null,null,"#define COMPONENT_BUILD 1",{"$nulls":4},"追加"]
[]
["７．環境変数の追加"]
[null,"コマンドプロンプトで以下の環境変数を追加する"]
[null,null,"set DEPOT_TOOLS_WIN_TOOLCHAIN=0"]
[]
[null,"※私の環境ではgclientコマンドを実行する前に変数を定義するとエラーになるので実行してからコマンドプロンプトで行う"]
[]
[]
["８．pdfiumviewer.cppの修正および配置"]
[null,"pdfiumviewer.cppのオリジナルは以下のGitから取得"]
[null,"　https://github.com/pvginkel/PdfiumBuild/tree/master/Scripts"]
[]
[null,"V8対応は最新のpdfiumではエラーになるので"]
[null,"　Scripts/PdfiumViewer-x64-no_v8-no_xfa/contrib/fpdfsdk/pdfiumviewer.cpp"]
[null,"から取得する"]
[]
[null,"オリジナルソースではclangでClassのStatic宣言でエラーがでるのでsingletonに変更する"]
[null," 変更後のソース"]
[null,null,"\\pfsverify\\Tools\\RenderPDF\\pdfium\\Contrib\\pdfiumviewer.cpp"]
[null,"pdfiumviewer.cppをBUILD.gnで定義した場所にコピーする"]
[null,"　　　　　E:\\Build\\pdfium\\pdfium\\fpdfsdk"]
[]
["９．ビルド設定ファイルの編集とNinja スクリプトの更新"]
[null,"同期をとる"]
[null,null,"gclient sync"]
[null,"下記のフォルダーが作成されていることを確認する"]
[null,null,"E:Build\\pdfium\\pdfium\\third_party\\llvm-build"]
[null,"※syncがよくエラーになるため、何度か実行する"]
[]
[null,"コマンドプロンプトで"]
[null,null,"gn args ."]
[null,"Textエディターで args.gnファイルが開くので以下のように変更する"]
[null,"xfa(XFA サポートを削除）とv8は使用しない（最新のソースではv8の構成が変更されているためコンパイルでエラーとなる)"]
[]
[null,null,"# Build arguments go here."]
[null,null,"# See \"gn args <out_dir> --list\" for available build arguments."]
[null,null,"pdf_is_standalone = true"]
[null,null,"is_component_build = false"]
[null,null,"is_debug = false"]
[null,null,"pdf_enable_xfa = false"]
[null,null,"pdf_enable_v8 = false"]
[null,null,"target_cpu = \"x64\""]
[null,null,"is_official_build = false"]
[null,null,"chrome_pgo_phase=0 "]
[]
[null,"ファイルを閉じるとNinja スクリプトが更新され、数千のエラー メッセージが生成されるが以下のファイルが作成されていれば一応問題なし"]
[null,null,"build.ninja"]
[null,"が作成されていることを確認する"]
[]
[]
["１０．Ninja.exeのダウンロード"]
[null,"従来まではdepot_toolsに含まれていが現在は削除されているようである"]
[null,"無い場合は以下から取得する"]
[null,"　https://github.com/ninja-build/ninja/releases/ninja-win.zip"]
[null,"ninja-win.zipを展開しNinja.exeを"]
[null,"　E:\\Build\\pdfium\\pdfium\\third_party\\ninja"]
[null,"へコピーする"]
[]
["１１．ビルド"]
[null,"コマンドプロンプトで"]
[null,null,"ninja pdfium"]
[]
[null,"正常に終了した場合は"]
[null,"　[1330/1330] LINK(DLL) pdfium.dll pdfium.dll.lib pdfium.dll.pdb"]
[null,"がコンソールに出力され"]
[null,"　E:\\Build\\pdfium\\pdfium"]
[null,"に"]
[null,"　pdfium.dll"]
[null,"　pdfium.dll.lib"]
[null,"　pdfium.dll.pdb"]
[null,"が作成される"]
[]
["１２．参考URL"]
[null,"https://qiita.com/qt6hy/items/d65cd43a73312b64a404"]
[null,"https://github.com/pvginkel/PdfiumViewer"]
[null,"https://qiita.com/hotpepsi/items/066aba74fef1672ef11a"]

{"sheet":"pdfiumviewer.cpp","index":2,"n_rows":123,"n_cols":8,"rows_kept":123,"cut":false,"hidden":false,"merged":[]}
["赤文字が変更箇所"]
[]
["// Copyright (c) 2015 Pieter van Ginkel. All rights reserved."]
["// Use of this source code is governed by a BSD-style license that can be"]
["// found in the LICENSE file."]
[]
["#include \"public/fpdfview.h\""]
["#if PDF_ENABLE_V8"]
["#include \"v8/include/v8.h\""]
["#include \"v8/include/libplatform/libplatform.h\""]
["#endif // PDF_ENABLE_V8"]
[]
["extern \"C\""]
["{"]
["    FPDF_EXPORT void FPDF_CALLCONV FPDF_AddRef();"]
["    FPDF_EXPORT void FPDF_CALLCONV FPDF_Release();"]
["}"]
[]
["class RefCounter"]
["{"]
["private:"]
["    CRITICAL_SECTION cs;"]
["    int refCount;"]
["#if PDF_ENABLE_V8"]
["    v8::Platform* platform;"]
["#endif // PDF_ENABLE_V8"]
["    static RefCounter* _instance;",{"$nulls":4},"//追加"]
["    "]
["public:"]
["    RefCounter()"]
["    {"]
["        ::InitializeCriticalSection(&cs);"]
["        refCount = 0;"]
["#if PDF_ENABLE_V8"]
["        platform = NULL;"]
["#endif // PDF_ENABLE_V8"]
["    }"]
[]
["    ~RefCounter()"]
["    {"]
["        ::DeleteCriticalSection(&cs);"]
["    }"]
[]
["    // Singletonオブジェクトの取得",{"$nulls":4},"//追加"]
["    static RefCounter* sGetInstance( void )"]
["    {"]
["        if(!_instance) {"]
["            _instance = new RefCounter;"]
["        }"]
["        return _instance ;"]
["    }"]
[]
["    void Enter()"]
["    {"]
["        ::EnterCriticalSection(&cs);"]
["    }"]
[]
["    void Leave()"]
["    {"]
["        ::LeaveCriticalSection(&cs);"]
["    }"]
[]
["    void AddRef()"]
["    {"]
["        ::EnterCriticalSection(&cs);"]
[]
["        if (refCount == 0)"]
["        {"]
["#if PDF_ENABLE_V8"]
["#if V8_INTL_SUPPORT"]
["#error V8_INTL_SUPPORT cannot be enabled"]
["#endif"]
["            platform = v8::platform::CreateDefaultPlatform();"]
["            v8::V8::InitializePlatform(platform);"]
["            v8::V8::Initialize();"]
["#endif // PDF_ENABLE_V8"]
[]
["            FPDF_InitLibrary();"]
["        }"]
[]
["        refCount++;"]
[]
["        ::LeaveCriticalSection(&cs);"]
["    }"]
[]
["    void Release()"]
["    {"]
["        ::EnterCriticalSection(&cs);"]
[]
["        refCount--;"]
[]
["        if (refCount == 0)"]
["        {"]
["            FPDF_DestroyLibrary();"]
["#if PDF_ENABLE_V8"]
["            v8::V8::ShutdownPlatform();"]
["            delete platform;"]
["#endif // PDF_ENABLE_V8"]
["        }"]
[]
["        ::LeaveCriticalSection(&cs);"]
["    }"]
["};"]
[]
[]
["//static RefCounter refCounter;",{"$nulls":4},"エラーがでるのでコメント"]
["// Singletonの実装"]
["RefCounter* RefCounter::_instance = 0;",{"$nulls":4},"追加"]
[]
[]
["FPDF_EXPORT void FPDF_CALLCONV FPDF_AddRef()",{"$nulls":6},"// singletonの変更"]
["{"]
["    RefCounter *ref = RefCounter::sGetInstance() ;"]
["    ref->AddRef();"]
["    //refCounter.AddRef();"]
["}"]
[]
["FPDF_EXPORT void FPDF_CALLCONV FPDF_Release()"]
["{"]
["    RefCounter *ref = RefCounter::sGetInstance() ;"]
["    ref->Release();"]
["    //refCounter.Release();"]
["}"]