Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
emKaroly committed Oct 2, 2020
1 parent f403a09 commit 77aa8f5
Show file tree
Hide file tree
Showing 1,638 changed files with 270,389 additions and 4,056 deletions.
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
bin/
build/

.vs/
*.user

xcuserdata/
*.xcworkspace/

bin/PDFixSDKSample*
bin/*.dll
bin/*.dylib
bin/output/

include/boost
211 changes: 211 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
cmake_minimum_required(VERSION 3.10)

project(pdfixsdksample)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(HEADERS
include/pdfixsdksamples/Utils.h
include/pdfixsdksamples/ExtractText.h
include/pdfixsdksamples/AcroFormExport.h
include/pdfixsdksamples/AcroFormImport.h
include/pdfixsdksamples/AddComment.h
include/pdfixsdksamples/AddTags.h
include/pdfixsdksamples/AddWatermark.h
include/pdfixsdksamples/ApplyRedaction.h
include/pdfixsdksamples/BookmarksToJson.h
include/pdfixsdksamples/CertDigitalSignature.h
#include/pdfixsdksamples/ConvertTaggedPdf.h
include/pdfixsdksamples/ConvertToHtml.h
include/pdfixsdksamples/ConvertToHtmlEx.h
include/pdfixsdksamples/ConvertToJson.h
include/pdfixsdksamples/ConvertToXml.h
include/pdfixsdksamples/CreateNewDocument.h
include/pdfixsdksamples/CreateNewDocuments.h
include/pdfixsdksamples/CreatePage.h
include/pdfixsdksamples/DeletePages.h
include/pdfixsdksamples/DigitalSignature.h
include/pdfixsdksamples/DocumentMetadata.h
include/pdfixsdksamples/EmbedFonts.h
include/pdfixsdksamples/ExportFormFieldValues.h
include/pdfixsdksamples/ExtractHighlightedText.h
include/pdfixsdksamples/ExtractImages.h
include/pdfixsdksamples/ExtractTables.h
include/pdfixsdksamples/ExtractText.h
include/pdfixsdksamples/FillForm.h
include/pdfixsdksamples/FlattenAnnots.h
include/pdfixsdksamples/GetWhitespace.h
include/pdfixsdksamples/ImportFormData.h
include/pdfixsdksamples/Initialization.h
include/pdfixsdksamples/LicenseReset.h
include/pdfixsdksamples/LicenseStatus.h
include/pdfixsdksamples/MakeAccessible.h
include/pdfixsdksamples/MovePage.h
include/pdfixsdksamples/NamedDestsToJson.h
include/pdfixsdksamples/OcrPageImagesWithTesseract.h
include/pdfixsdksamples/OcrWithTesseract.h
include/pdfixsdksamples/OpedDocumentFromStream.h
include/pdfixsdksamples/PagesToJson.h
include/pdfixsdksamples/ParsePageContent.h
include/pdfixsdksamples/ParsePdsObjects.h
include/pdfixsdksamples/PrintPage.h
include/pdfixsdksamples/ReadOCGLayers.h
include/pdfixsdksamples/RegexSearch.h
include/pdfixsdksamples/RegexSetPattern.h
include/pdfixsdksamples/RegisterEvent.h
include/pdfixsdksamples/RemoveComments.h
include/pdfixsdksamples/RemoveTags.h
include/pdfixsdksamples/RenderPage.h
include/pdfixsdksamples/RenderPages.h
include/pdfixsdksamples/SetAnnotationAppearance.h
include/pdfixsdksamples/SetFieldFlags.h
include/pdfixsdksamples/SetFormFieldValue.h
include/pdfixsdksamples/StandardLicenseActivate.h
include/pdfixsdksamples/StandardLicenseDeactivate.h
include/pdfixsdksamples/StandardLicenseUpdate.h
include/pdfixsdksamples/samples.h
)

set(SOURCES
#src/RenderPageWithoutText.cpp
#src/TagAsArtifact.cpp
#src/ExtractTextFromOCGLayer.cpp
src/AcroFormExport.cpp
src/AcroFormImport.cpp
src/AddComment.cpp
src/AddTags.cpp
src/AddWatermark.cpp
src/ApplyRedaction.cpp
src/BookmarksToJson.cpp
src/CertDigitalSignature.cpp
#src/ConvertTaggedPdf.cpp
src/ConvertToHtml.cpp
src/ConvertToHtmlEx.cpp
src/ConvertToJson.cpp
src/ConvertToXml.cpp
src/CreateNewDocument.cpp
src/CreateNewDocuments.cpp
src/CreatePage.cpp
src/DeletePages.cpp
src/DigitalSignature.cpp
src/DocumentMetadata.cpp
src/EmbedFonts.cpp
src/ExportFormFieldValues.cpp
src/ExtractHighlightedText.cpp
src/ExtractImages.cpp
src/ExtractTables.cpp
src/ExtractText.cpp
src/FillForm.cpp
src/FlattenAnnots.cpp
src/GetWhitespace.cpp
src/ImportFormData.cpp
src/Initialization.cpp
src/LicenseReset.cpp
src/LicenseStatus.cpp
src/MakeAccessible.cpp
src/MovePage.cpp
src/NamedDestsToJson.cpp
src/OcrPageImagesWithTesseract.cpp
src/OcrWithTesseract.cpp
src/OpedDocumentFromStream.cpp
src/PagesToJson.cpp
src/ParsePageContent.cpp
src/ParsePdsObjects.cpp
src/PrintPage.cpp
src/ReadOCGLayers.cpp
src/RegexSearch.cpp
src/RegexSetPattern.cpp
src/RegisterEvent.cpp
src/RemoveComments.cpp
src/RemoveTags.cpp
src/RenderPage.cpp
src/RenderPages.cpp
src/SetAnnotationAppearance.cpp
src/SetFieldFlags.cpp
src/SetFormFieldValue.cpp
src/StandardLicenseActivate.cpp
src/StandardLicenseDeactivate.cpp
src/StandardLicenseUpdate.cpp
#src/TagAnnotation.cpp
#src/TagHeadings.cpp
#src/TagTableAsFigure.cpp
#src/TagsEditStructTree.cpp
#src/TagsReadStructTree.cpp
#src/TagsReadingOrder.cpp
src/Utils.cpp
)

add_library(pdfixsdksample
${HEADERS}
${SOURCES}
)

# idendify project architecture
if (${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set (PROJECTNAME_ARCHITECTURE "x64")
else ()
set (PROJECTNAME_ARCHITECTURE "x86")
endif ()

# set output directory
if(MSVC)
if (CMAKE_CL_64 OR ${PROJECTNAME_ARCHITECTURE} EQUAL "x64") # -- 64-bit builds.
set(OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/x64")
else()
set(OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/x86")
endif()
set(DOWNLOAD_PLATFORM Windows)
elseif(APPLE)
set(OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/darwin")
set(DOWNLOAD_PLATFORM MacOS)
elseif(UNIX)
set(OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/linux")
set(DOWNLOAD_PLATFORM Linux)
else()
endif()

include(FetchContent)

FetchContent_Declare(
pdfixdist
URL "https://github.com/PDFixSDKSample-cpp/releases/download/6.0.0/PDFix_SDK_6.0.0_${DOWNLOAD_PLATFORM}.zip"
)

FetchContent_Populate(pdfixdist)

file(COPY ${pdfixdist_SOURCE_DIR}/bin/darwin DESTINATION ${CMAKE_SOURCE_DIR}/bin)

set_target_properties(pdfixsdksample
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE
RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OUTPUT_DIRECTORY}
)

target_compile_definitions(pdfixsdksample
PUBLIC
"$<$<CONFIG:DEBUG>:_DEBUG>"
)

target_include_directories(pdfixsdksample
PUBLIC
"$<IF:$<TARGET_EXISTS:pdfix_app>,${CMAKE_SOURCE_DIR}/libs/boost/include,${CMAKE_SOURCE_DIR}/external>"
"$<IF:$<TARGET_EXISTS:pdfix_app>,${CMAKE_SOURCE_DIR}/include/c++,${pdfixdist_SOURCE_DIR}/include/c++>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>"
)

set_target_properties(pdfixsdksample
PROPERTIES
PUBLIC_HEADER "include/pdfixsdksamples/samples.h"
)

install(TARGETS pdfixsdksample
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBRARY_TARGET_NAME}" COMPONENT dev)

add_subdirectory(example)
1 change: 0 additions & 1 deletion bin/README.md

This file was deleted.

4 changes: 4 additions & 0 deletions build_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cmake -G Ninja --target example -B build -S .
cmake --build build --target example
13 changes: 13 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_executable(example example.cpp)

set_target_properties(example
PROPERTIES
CXX_STANDARD 17
CMAKE_MACOSX_RPATH OFF
CXX_STANDARD_REQUIRED TRUE
RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OUTPUT_DIRECTORY}
)

target_link_libraries(example PRIVATE pdfixsdksample)
123 changes: 123 additions & 0 deletions example/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Main.cpp
// Copyright (c) 2018 Pdfix. All Rights Reserved.
///////////////////////////////////////////////////////////////////////////////

#include "pdfixsdksamples/samples.h"

extern std::wstring GetAbsolutePath(const std::wstring& path);

int main()
{
std::wstring email = L"YOUR_EMAIL"; // authorization email
std::wstring key = L"LICENSE_KEY"; // authorization license key

std::wstring resources_dir = GetAbsolutePath(L"../../resources");
std::wstring output_dir = GetAbsolutePath(L"../../output");

std::wstring open_path = resources_dir + L"/test.pdf"; // source PDF document
std::wstring save_path = output_dir + L"/test.pdf"; // source PDF document
std::wstring config_path = resources_dir + L"/config.json"; // configuration file

try {
Initialization();

std::wcout << open_path << "\n";
std::wcout << save_path << "\n";
// Markup & Comment
AddComment(open_path, save_path);
//RemoveComments(email, key, open_path, output_dir + L"/RemoveComments.pdf");

//// Convert to HTML
//PdfHtmlParams html_params;
//html_params.flags |= (kHtmlNoExternalCSS | kHtmlNoExternalIMG | kHtmlNoExternalJS);
//ConvertToHtml(email, key, open_path, output_dir + L"/fixed.html", config_path,
// html_params);
//html_params.type = kPdfHtmlResponsive;
//ConvertToHtml(email, key, open_path, output_dir + L"/responsive.html", config_path,
// html_params);
//PdfHtmlParams html_params_ex;
//html_params.flags |= (kHtmlNoExternalCSS | kHtmlNoExternalIMG | kHtmlNoExternalJS);
//
//// Convert to HTML by parts
//ConvertToHtmlEx(email, key, open_path, output_dir + L"/ConvertToHtmlPage_script.js", config_path,
// html_params_ex, L"js", L"");
//ConvertToHtmlEx(email, key, open_path, output_dir + L"/ConvertToHtmlPage_style.css", config_path,
// html_params_ex, L"css", L"");
//ConvertToHtmlEx(email, key, open_path, output_dir + L"/ConvertToHtmlPage_doc.html", config_path,
// html_params_ex, L"document", L"");
//ConvertToHtmlEx(email, key, open_path, output_dir + L"/ConvertToHtmlPage_page_1.html", config_path,
// html_params_ex, L"page", L"1");
//
////PdfTaggedParams tagged_params;
////ConvertTaggedPdf(email, key, open_path, GetAbsolutePath(L"output/fixed.html"), config_path,
//// tagged_params);
//DigitalSignature(email, key, open_path, output_dir + L"/DigitalSignature.pdf",
// resources_dir + L"/test.pfx", L"TEST_PASSWORD");
//DocumentMetadata(email, key, open_path, output_dir + L"/DocumentMetadata.pdf",
// output_dir + L"/metadata.xml");
//EmbedFonts(email, key, open_path, output_dir + L"/EmbedFonts.pdf");
//
//// Data Extraction
//ExtractHighlightedText(email, key, open_path,
// output_dir + L"/ExtractHighlightedText.txt", config_path);
//PdfImageParams image_params;
//ExtractImages(email, key, open_path, output_dir + L"/", 800, image_params);
//ExtractTables(email, key, open_path, output_dir + L"/");
//ExtractText(email, key, open_path, output_dir + L"/ExtractText.txt", config_path);
//ConvertToXml(email, key, open_path, output_dir + L"/ConvertToXml.xml", config_path);
//
//// OCR Tesseract
//OcrWithTesseract(email, key, open_path, output_dir + L"/OcrTesseract.pdf",
// resources_dir + L"/tessdata", L"eng", 2., kRotate0);
//OcrPageImagesWithTesseract(email, key, open_path, output_dir + L"/OcrPageImagesWithTesseract.pdf",
// resources_dir + L"/tessdata", L"eng", 2., kRotate0);
//
//// Regex
//RegexSearch(email, key, open_path, L"(\\d{4}[- ]){3}\\d{4}");
//RegexSetPattern(email, key, open_path);
//
//RegisterEvent(email, key, open_path);
//
//// Render & Print
//RenderPage(email, key, open_path, output_dir + L"/RenderPage.jpg", 2.0, kRotate0);
//RenderPageWithoutText(email, key, open_path, output_dir + L"/RenderPageWithoutText.jpg", 2.0, kRotate0);
////PrintPage(email, key, open_path);
//
//// Tags & Accessibility
//AddTags(email, key, open_path, output_dir + L"/AddTags.pdf", config_path);
//TagsReadStructTree(email, key, open_path, output_dir + L"/TagsReadStructTree.txt", config_path);
//TagTableAsFigure::Run(email, key, open_path, output_dir + L"/TagTableAsFigure.pdf");
//TagsReadingOrder::Run(email, key, open_path, output_dir + L"/TagsReadingOrder.pdf");
//TagAnnotation::Run(email, key, open_path, output_dir + L"/TagAnnotation.pdf");
//TagHeadings::Run(email, key, open_path, output_dir + L"/TagHeadings.pdf");
//TagAsArtifact::Run(email, key, open_path, output_dir + L"/TagAsArtifact.pdf");
//TagsEditStructTree(email, key, open_path, output_dir + L"/TagsEditStructTree.pdf");
//MakeAccessible(email, key, open_path, output_dir + L"/MakeAccessible.pdf", L"", L"", config_path);
//
//// Form fields
//ExportFormFieldValues(email, key, open_path,
// output_dir + L"/ExportFormFieldValues.txt");
//SetFieldFlags(email, key, open_path, output_dir + L"/SetFieldFlags.pdf");
//SetFormFieldValue(email, key, open_path, output_dir + L"/SetFormFieldValue.pdf");
//
//// Misc
//PdfFlattenAnnotsParams flatten_annots_params;
//FlattenAnnots(email, key, open_path, output_dir + L"/FlattenAnnots.pdf",
// flatten_annots_params);
//BookmarksToJson(email, key, open_path, output_dir + L"/BookmarksToJson.json");
//GetWhitespace(email, key, open_path);
//PdfWatermarkParams watermark_params;
//AddWatermark(email, key, open_path, output_dir + L"/AddWatermark.pdf",
// resources_dir + L"/watermark.png", watermark_params);
//// OpedDocumentFromStream(email, key, open_path);
//ParsePdsObjects(email, key, open_path, output_dir + L"/ParsePdsObjects.txt");
//ParsePageContent(email, key, open_path, output_dir + L"/ParsePageContent.txt");
}
catch (std::exception& ex) {
std::cout << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}

18 changes: 18 additions & 0 deletions external/boost/aligned_storage.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//-----------------------------------------------------------------------------
// boost aligned_storage.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003
// Eric Friedman, Itay Maman
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_ALIGNED_STORAGE_HPP
#define BOOST_ALIGNED_STORAGE_HPP

#include <boost/type_traits/aligned_storage.hpp>

#endif // BOOST_ALIGNED_STORAGE_HPP
Loading

0 comments on commit 77aa8f5

Please sign in to comment.