summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2014-05-22 16:14:52 -0700
committerJohn Abd-El-Malek <jam@chromium.org>2014-05-23 16:55:40 -0700
commit70e2270a8ac049bbcef0f13ae0848e3a2d01966b (patch)
tree5926bf475df15d3607033eb8f9416d5ae56c3c83
parent3ce25e68aa8f6d4b880ce4e0e9f123d117fcbd0c (diff)
downloadpdfium-70e2270a8ac049bbcef0f13ae0848e3a2d01966b.tar.xz
Create a standalone pdfium build.
I moved pdfium_test from chromium's repo to pdfium's. It's now buildable as a sample following the instructions on the wiki.
-rw-r--r--.gitignore18
-rw-r--r--README.txt1
-rw-r--r--build/all.gyp15
-rw-r--r--build/gyp_pdfium46
-rw-r--r--build/gyp_pdfium.py8
-rw-r--r--build/standalone.gypi259
-rw-r--r--samples/pdfium_test.cc309
-rw-r--r--samples/samples.gyp21
8 files changed, 677 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..06184bd2c4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+/build/Debug
+/build/Release
+/build/gyp
+/out
+/v8
+/xcodebuild
+Makefile
+.DS_Store
+*.filters
+*.mk
+*.opensdf
+*.pyc
+*.sdf
+*.sln
+*.suo
+*.user
+*.vcxproj
+*.xcodeproj \ No newline at end of file
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000000..3a2cbde22f
--- /dev/null
+++ b/README.txt
@@ -0,0 +1 @@
+For build instructions visit https://code.google.com/p/pdfium/wiki/Build \ No newline at end of file
diff --git a/build/all.gyp b/build/all.gyp
new file mode 100644
index 0000000000..e9229dd7c6
--- /dev/null
+++ b/build/all.gyp
@@ -0,0 +1,15 @@
+# Copyright 2014 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'All',
+ 'type': 'none',
+ 'dependencies': [
+ '../samples/samples.gyp:*',
+ ],
+ }
+ ]
+} \ No newline at end of file
diff --git a/build/gyp_pdfium b/build/gyp_pdfium
new file mode 100644
index 0000000000..0458b96d13
--- /dev/null
+++ b/build/gyp_pdfium
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script is wrapper for PDFium that adds some support for how GYP
+# is invoked by PDFium beyond what can be done in the gclient hooks.
+
+import os
+import platform
+import sys
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir))
+
+sys.path.insert(0, os.path.join(pdfium_root, 'build', 'gyp', 'pylib'))
+import gyp
+
+
+def run_gyp(args):
+ rc = gyp.main(args)
+ if rc != 0:
+ print 'Error running GYP'
+ sys.exit(rc)
+
+
+def main():
+ args = sys.argv[1:]
+ args.append(os.path.join(script_dir, 'all.gyp'))
+
+ args.append('-I')
+ args.append(os.path.join(pdfium_root, 'build', 'standalone.gypi'))
+
+ args.extend(['-D', 'gyp_output_dir=out'])
+
+ # Set the GYP DEPTH variable to the root of the PDFium project.
+ args.append('--depth=' + os.path.relpath(pdfium_root))
+
+ print 'Updating projects from gyp files...'
+ sys.stdout.flush()
+
+ run_gyp(args)
+
+if __name__ == '__main__':
+ sys.exit(main()) \ No newline at end of file
diff --git a/build/gyp_pdfium.py b/build/gyp_pdfium.py
new file mode 100644
index 0000000000..9776c302d4
--- /dev/null
+++ b/build/gyp_pdfium.py
@@ -0,0 +1,8 @@
+# Copyright 2014 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+path = os.path.abspath(os.path.split(__file__)[0])
+execfile(os.path.join(path, 'gyp_pdfium'))
diff --git a/build/standalone.gypi b/build/standalone.gypi
new file mode 100644
index 0000000000..970c0590c7
--- /dev/null
+++ b/build/standalone.gypi
@@ -0,0 +1,259 @@
+# Copyright 2014 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Definitions to be used when building stand-alone PDFium binaries.
+
+{
+ 'variables': {
+ 'component%': 'static_library',
+ 'clang%': 0,
+ 'msvs_multi_core_compile%': '1',
+ 'variables': {
+ 'variables': {
+ 'variables': {
+ 'conditions': [
+ ['OS=="linux" or OS=="mac"', {
+ # This handles the Unix platforms we generally deal with.
+ # Anything else gets passed through, which probably won't work
+ # very well; such hosts should pass an explicit target_arch
+ # to gyp.
+ 'host_arch%':
+ '<!(uname -m | sed -e "s/i.86/ia32/;\
+ s/x86_64/x64/;\
+ s/amd64/x64/;\
+ s/arm.*/arm/;\
+ s/aarch64/arm64/;\
+ s/mips.*/mipsel/")',
+ }, {
+ # OS!="linux" and OS!="mac"
+ 'host_arch%': 'ia32',
+ }],
+ ],
+ },
+ 'host_arch%': '<(host_arch)',
+ 'target_arch%': '<(host_arch)',
+ },
+ 'host_arch%': '<(host_arch)',
+ 'target_arch%': '<(target_arch)',
+ },
+ 'host_arch%': '<(host_arch)',
+ 'target_arch%': '<(target_arch)',
+ 'werror%': '-Werror',
+ 'v8_optimized_debug%': 0,
+ 'icu_gyp_path': '../v8/third_party/icu/icu.gyp',
+ 'conditions': [
+ ['OS == "win"', {
+ 'os_posix%': 0,
+ }, {
+ 'os_posix%': 1,
+ }],
+ ],
+ },
+ 'target_defaults': {
+ 'default_configuration': 'Debug',
+ 'configurations': {
+ 'Debug': {
+ 'cflags': [
+ '-g',
+ '-O0',
+ '-fdata-sections',
+ '-ffunction-sections',
+ ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'Optimization': '0',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'RuntimeLibrary': '3', # /MDd
+ }, {
+ 'RuntimeLibrary': '1', # /MTd
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'LinkIncremental': '2',
+ },
+ },
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '0', # -O0
+ },
+ },
+ 'Release': {
+ 'cflags': [
+ '-fno-strict-aliasing',
+ ],
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '3', # -O3
+ 'GCC_STRICT_ALIASING': 'NO',
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'Optimization': '2',
+ 'InlineFunctionExpansion': '2',
+ 'EnableIntrinsicFunctions': 'true',
+ 'FavorSizeOrSpeed': '0',
+ 'StringPooling': 'true',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'RuntimeLibrary': '2', #/MD
+ }, {
+ 'RuntimeLibrary': '0', #/MT
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'LinkIncremental': '1',
+ 'OptimizeReferences': '2',
+ 'EnableCOMDATFolding': '2',
+ },
+ },
+ 'conditions': [
+ ['OS=="linux"', {
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ '-O3',
+ '-O2',
+ ],
+ }],
+ ['OS=="android"', {
+ 'cflags!': [
+ '-O3',
+ '-Os',
+ ],
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ '-O2',
+ ],
+ }],
+ ], # conditions
+ },
+ },
+ 'defines!': [
+ 'DEBUG',
+ ],
+ 'cflags!': [
+ '-Wall',
+ '-W',
+ '-Wno-unused-parameter',
+ '-pthread', '-fno-exceptions',
+ '-fvisibility=hidden',
+ ],
+ 'cflags_cc': [
+ '-Wnon-virtual-dtor',
+ '-fno-rtti',
+ ],
+ 'ldflags': [
+ '-pthread',
+ ],
+ 'msvs_cygwin_dirs': ['<(DEPTH)/v8/third_party/cygwin'],
+ 'msvs_configuration_attributes': {
+ 'OutputDirectory': '<(DEPTH)\\out\\$(ConfigurationName)',
+ 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
+ 'CharacterSet': '1',
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'MinimalRebuild': 'false',
+ 'BufferSecurityCheck': 'true',
+ 'EnableFunctionLevelLinking': 'true',
+ 'RuntimeTypeInfo': 'false',
+ 'WarningLevel': '3',
+ 'WarnAsError': 'false',
+ 'DebugInformationFormat': '3',
+ 'Detect64BitPortabilityProblems': 'false',
+ 'conditions': [
+ [ 'msvs_multi_core_compile', {
+ 'AdditionalOptions': ['/MP'],
+ }],
+ ['component=="shared_library"', {
+ 'ExceptionHandling': '1', # /EHsc
+ }, {
+ 'ExceptionHandling': '0',
+ }],
+ ],
+ },
+ 'VCLibrarianTool': {
+ 'AdditionalOptions': ['/ignore:4221'],
+ },
+ 'VCLinkerTool': {
+ 'GenerateDebugInformation': 'true',
+ 'LinkIncremental': '1',
+ # SubSystem values:
+ # 0 == not set
+ # 1 == /SUBSYSTEM:CONSOLE
+ # 2 == /SUBSYSTEM:WINDOWS
+ 'SubSystem': '1',
+ 'AdditionalDependencies': [
+ 'advapi32.lib',
+ 'gdi32.lib',
+ 'user32.lib',
+ ],
+ },
+ },
+ 'xcode_settings': {
+ 'ALWAYS_SEARCH_USER_PATHS': 'NO',
+ 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
+ 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
+ # (Equivalent to -fPIC)
+ 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
+ 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
+ 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
+ # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
+ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
+ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
+ 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
+ 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
+ 'SYMROOT': '<(DEPTH)/xcodebuild',
+ 'USE_HEADERMAP': 'NO',
+ 'OTHER_CFLAGS': [
+ '-fno-strict-aliasing',
+ ],
+ 'WARNING_CFLAGS': [
+ '-Wall',
+ '-Wendif-labels',
+ '-W',
+ '-Wno-unused-parameter',
+ ],
+ },
+ },
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'cflags': [
+ '-fPIC',
+ ],
+ }],
+ ['OS=="win"', {
+ 'target_defaults': {
+ 'defines': [
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_CRT_NONSTDC_NO_DEPRECATE',
+ ],
+ 'conditions': [
+ ['component=="static_library"', {
+ 'defines': [
+ '_HAS_EXCEPTIONS=0',
+ ],
+ }],
+ ],
+ },
+ }], # OS=="win"
+ ['OS=="mac"', {
+ 'target_defaults': {
+ 'link_settings': {
+ 'libraries': [
+ '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
+ '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
+ ],
+ },
+ 'target_conditions': [
+ ['_type!="static_library"', {
+ 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
+ }],
+ ], # target_conditions
+ }, # target_defaults
+ }], # OS=="mac"
+ ],
+} \ No newline at end of file
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
new file mode 100644
index 0000000000..67c15e0ea5
--- /dev/null
+++ b/samples/pdfium_test.cc
@@ -0,0 +1,309 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <list>
+#include <string>
+#include <utility>
+
+#include "fpdfsdk/include/fpdf_dataavail.h"
+#include "fpdfsdk/include/fpdf_ext.h"
+#include "fpdfsdk/include/fpdfformfill.h"
+#include "fpdfsdk/include/fpdftext.h"
+#include "fpdfsdk/include/fpdfview.h"
+#include "v8/include/v8.h"
+
+#ifdef _WIN32
+ #define snprintf _snprintf
+ /* in Windows, rb for open and read binary file */
+ #define FOPEN_READ "rb"
+#else
+ #define FOPEN_READ "r"
+#endif
+
+static void WritePpm(const char* pdf_name, int num,
+ const char* buffer, int stride, int width, int height) {
+ if (stride < 0 || width < 0 || height < 0)
+ return;
+ if (height > 0 && width > INT_MAX / height)
+ return;
+ int out_len = width * height;
+ if (out_len > INT_MAX / 3)
+ return;
+ out_len *= 3;
+
+ char filename[256];
+ snprintf(filename, sizeof(filename), "%s.%d.ppm", pdf_name, num);
+ FILE* fp = fopen(filename, "w");
+ if (!fp)
+ return;
+ fprintf(fp, "P6\n# PDF test render\n%d %d\n255\n", width, height);
+ // Source data is B, G, R, unused.
+ // Dest data is R, G, B.
+ char* result = new char[out_len];
+ if (result) {
+ for (int h = 0; h < height; ++h) {
+ const char* src_line = buffer + (stride * h);
+ char* dest_line = result + (width * h * 3);
+ for (int w = 0; w < width; ++w) {
+ // R
+ dest_line[w * 3] = src_line[(w * 4) + 2];
+ // G
+ dest_line[(w * 3) + 1] = src_line[(w * 4) + 1];
+ // B
+ dest_line[(w * 3) + 2] = src_line[w * 4];
+ }
+ }
+ fwrite(result, out_len, 1, fp);
+ delete [] result;
+ }
+ fclose(fp);
+}
+
+int Form_Alert(IPDF_JSPLATFORM*, FPDF_WIDESTRING, FPDF_WIDESTRING, int, int) {
+ printf("Form_Alert called.\n");
+ return 0;
+}
+
+void Unsupported_Handler(UNSUPPORT_INFO*, int type) {
+ std::string feature = "Unknown";
+ switch (type) {
+ case FPDF_UNSP_DOC_XFAFORM:
+ feature = "XFA";
+ break;
+ case FPDF_UNSP_DOC_PORTABLECOLLECTION:
+ feature = "Portfolios_Packages";
+ break;
+ case FPDF_UNSP_DOC_ATTACHMENT:
+ case FPDF_UNSP_ANNOT_ATTACHMENT:
+ feature = "Attachment";
+ break;
+ case FPDF_UNSP_DOC_SECURITY:
+ feature = "Rights_Management";
+ break;
+ case FPDF_UNSP_DOC_SHAREDREVIEW:
+ feature = "Shared_Review";
+ break;
+ case FPDF_UNSP_DOC_SHAREDFORM_ACROBAT:
+ case FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM:
+ case FPDF_UNSP_DOC_SHAREDFORM_EMAIL:
+ feature = "Shared_Form";
+ break;
+ case FPDF_UNSP_ANNOT_3DANNOT:
+ feature = "3D";
+ break;
+ case FPDF_UNSP_ANNOT_MOVIE:
+ feature = "Movie";
+ break;
+ case FPDF_UNSP_ANNOT_SOUND:
+ feature = "Sound";
+ break;
+ case FPDF_UNSP_ANNOT_SCREEN_MEDIA:
+ case FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA:
+ feature = "Screen";
+ break;
+ case FPDF_UNSP_ANNOT_SIG:
+ feature = "Digital_Signature";
+ break;
+ }
+ printf("Unsupported feature: %s.\n", feature.c_str());
+}
+
+bool ParseCommandLine(int argc, const char* argv[], bool* write_images,
+ std::list<const char*>* files) {
+ *write_images = false;
+ files->clear();
+
+ int cur_arg = 1;
+ if (cur_arg < argc &&
+ strcmp(argv[cur_arg], "--write_images") == 0) {
+ *write_images = true;
+ cur_arg++;
+ }
+
+ if (cur_arg >= argc)
+ return false;
+
+ for (int i = cur_arg; i < argc; i++)
+ files->push_back(argv[i]);
+
+ return true;
+}
+
+class TestLoader {
+ public:
+ TestLoader(const char* pBuf, size_t len);
+
+ const char* m_pBuf;
+ size_t m_Len;
+};
+
+TestLoader::TestLoader(const char* pBuf, size_t len)
+ : m_pBuf(pBuf), m_Len(len) {
+}
+
+int Get_Block(void* param, unsigned long pos, unsigned char* pBuf,
+ unsigned long size) {
+ TestLoader* pLoader = (TestLoader*) param;
+ if (pos + size < pos || pos + size > pLoader->m_Len) return 0;
+ memcpy(pBuf, pLoader->m_pBuf + pos, size);
+ return 1;
+}
+
+bool Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
+ return true;
+}
+
+void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {
+}
+
+void RenderPdf(const char* name, const char* pBuf, size_t len,
+ bool write_images) {
+ printf("Rendering PDF file %s.\n", name);
+
+ IPDF_JSPLATFORM platform_callbacks;
+ memset(&platform_callbacks, '\0', sizeof(platform_callbacks));
+ platform_callbacks.version = 1;
+ platform_callbacks.app_alert = Form_Alert;
+
+ FPDF_FORMFILLINFO form_callbacks;
+ memset(&form_callbacks, '\0', sizeof(form_callbacks));
+ form_callbacks.version = 1;
+ form_callbacks.m_pJsPlatform = &platform_callbacks;
+
+ TestLoader loader(pBuf, len);
+
+ FPDF_FILEACCESS file_access;
+ memset(&file_access, '\0', sizeof(file_access));
+ file_access.m_FileLen = len;
+ file_access.m_GetBlock = Get_Block;
+ file_access.m_Param = &loader;
+
+ FX_FILEAVAIL file_avail;
+ memset(&file_avail, '\0', sizeof(file_avail));
+ file_avail.version = 1;
+ file_avail.IsDataAvail = Is_Data_Avail;
+
+ FX_DOWNLOADHINTS hints;
+ memset(&hints, '\0', sizeof(hints));
+ hints.version = 1;
+ hints.AddSegment = Add_Segment;
+
+ FPDF_DOCUMENT doc;
+ FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access);
+
+ (void) FPDFAvail_IsDocAvail(pdf_avail, &hints);
+
+ if (!FPDFAvail_IsLinearized(pdf_avail)) {
+ printf("Non-linearized path...\n");
+ doc = FPDF_LoadCustomDocument(&file_access, NULL);
+ } else {
+ printf("Linearized path...\n");
+ doc = FPDFAvail_GetDocument(pdf_avail, NULL);
+ }
+
+ (void) FPDF_GetDocPermissions(doc);
+ (void) FPDFAvail_IsFormAvail(pdf_avail, &hints);
+
+ FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnviroument(doc, &form_callbacks);
+ FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD);
+ FPDF_SetFormFieldHighlightAlpha(form, 100);
+
+ int first_page = FPDFAvail_GetFirstPageNum(doc);
+ (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints);
+
+ int page_count = FPDF_GetPageCount(doc);
+ for (int i = 0; i < page_count; ++i) {
+ (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints);
+ }
+
+ FORM_DoDocumentJSAction(form);
+ FORM_DoDocumentOpenAction(form);
+
+ for (int i = 0; i < page_count; ++i) {
+ FPDF_PAGE page = FPDF_LoadPage(doc, i);
+ FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
+ FORM_OnAfterLoadPage(page, form);
+ FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN);
+
+ int width = static_cast<int>(FPDF_GetPageWidth(page));
+ int height = static_cast<int>(FPDF_GetPageHeight(page));
+ FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0);
+ FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 255, 255, 255, 255);
+
+ FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0);
+ FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0);
+ if (write_images) {
+ const char* buffer = reinterpret_cast<const char*>(
+ FPDFBitmap_GetBuffer(bitmap));
+ int stride = FPDFBitmap_GetStride(bitmap);
+ WritePpm(name, i, buffer, stride, width, height);
+ }
+
+ FPDFBitmap_Destroy(bitmap);
+
+ FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE);
+ FORM_OnBeforeClosePage(page, form);
+ FPDFText_ClosePage(text_page);
+ FPDF_ClosePage(page);
+ }
+
+ FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
+ FPDFDOC_ExitFormFillEnviroument(form);
+ FPDF_CloseDocument(doc);
+ FPDFAvail_Destroy(pdf_avail);
+
+ printf("Loaded, parsed and rendered %d pages.\n", page_count);
+}
+
+int main(int argc, const char* argv[]) {
+ v8::V8::InitializeICU();
+ bool write_images = false;
+ std::list<const char*> files;
+ if (!ParseCommandLine(argc, argv, &write_images, &files)) {
+ printf("Usage is: test [--write_images] /path/to/pdf\n");
+ printf("--write_images - to write page images <pdf-name>.<page-number>.ppm\n");
+ return 1;
+ }
+
+ FPDF_InitLibrary(NULL);
+
+ UNSUPPORT_INFO unsuppored_info;
+ memset(&unsuppored_info, '\0', sizeof(unsuppored_info));
+ unsuppored_info.version = 1;
+ unsuppored_info.FSDK_UnSupport_Handler = Unsupported_Handler;
+
+ FSDK_SetUnSpObjProcessHandler(&unsuppored_info);
+
+ while (!files.empty()) {
+ const char* filename = files.front();
+ files.pop_front();
+ FILE* file = fopen(filename, FOPEN_READ);
+ if (!file) {
+ fprintf(stderr, "Failed to open: %s\n", filename);
+ continue;
+ }
+ (void) fseek(file, 0, SEEK_END);
+ size_t len = ftell(file);
+ (void) fseek(file, 0, SEEK_SET);
+ char* pBuf = (char*) malloc(len);
+ size_t ret = fread(pBuf, 1, len, file);
+ (void) fclose(file);
+ if (ret != len) {
+ fprintf(stderr, "Failed to read: %s\n", filename);
+ } else {
+ RenderPdf(filename, pBuf, len, write_images);
+ }
+ free(pBuf);
+ }
+
+ FPDF_DestroyLibrary();
+
+ return 0;
+}
+
diff --git a/samples/samples.gyp b/samples/samples.gyp
new file mode 100644
index 0000000000..f7b7237d8f
--- /dev/null
+++ b/samples/samples.gyp
@@ -0,0 +1,21 @@
+# Copyright 2014 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'target_defaults': {
+ 'type': 'executable',
+ 'dependencies': [
+ '../pdfium.gyp:fpdfsdk',
+ ],
+ 'include_dirs': ['<(DEPTH)'],
+ },
+ 'targets': [
+ {
+ 'target_name': 'pdfium_test',
+ 'sources': [
+ 'pdfium_test.cc',
+ ],
+ },
+ ],
+} \ No newline at end of file