Skip to content

Commit 64d1a55

Browse files
committed
Samples & PDFix SDK headers update
1 parent 3f03a54 commit 64d1a55

30 files changed

Lines changed: 251 additions & 270 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ xcuserdata/
88
bin/PDFixSDKSample*
99
bin/*.dll
1010
bin/*.dylib
11-
bin/output/
11+
bin/output/
12+
bin/resources/tessdata

bin/resources/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resources required to run samples
2+
3+
/test.pdf - sample PDF to process
4+
/watermark.png - image used for watermark
5+
/test.pfx - sample digital signature
6+
/tessdata/ - folder for Tesseract OCR data (not present in the repository please copy from Tesserct official web site)

include/Pdfix.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@
6969
#define kTemplateTagAlternate "tag-alternate"
7070
#define kTemplateAltText "alt-text"
7171
#define kTemplateTagAttribute "tag-attribute"
72-
#define kTemplateLayout "layout"
7372
#define kTemplateList "list"
7473
#define kTemplateTable "table"
74+
#define kTemplateTableLayout "table_layout"
75+
#define kTemplateCellLayout "cell_layout"
76+
#define kTemplateRectLayout "rect_layout"
7577
#define kTemplateTextLine "text-line"
7678
#define kTemplateReflow "reflow"
7779
#define kTemplateCreateTextBlock "create-text-block"
@@ -339,6 +341,7 @@ enum {
339341
kErrorDocTemplateInvalidValue = 114,
340342
kErrorPdsStructTreeInvalid = 115,
341343
kErrorPsRegexIndexOutOfBounds = 116,
344+
kErrorInit = 117,
342345
} ;
343346

344347
typedef enum {

src/AddComment.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Example how to add a text annotation with a reply.
2121

2222
// Adds a new text annotation.
2323
void AddComment(
24-
std::wstring email, // authorization email
25-
std::wstring license_key, // authorization license key
26-
std::wstring open_file, // source PDF document
27-
std::wstring save_file // directory where to save PDF docuemnt
24+
const std::wstring& email, // authorization email
25+
const std::wstring& license_key, // authorization license key
26+
const std::wstring& open_file, // source PDF document
27+
const std::wstring& save_file // directory where to save PDF docuemnt
2828
) {
2929
// initialize Pdfix
3030
if (!Pdfix_init(Pdfix_MODULE_NAME))

src/AddWatermark.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
// Adds watermark from img_path and saves the document to save_path.
2323
void AddWatermark(
24-
std::wstring email, // authorization email
25-
std::wstring license_key, // authorization license key
26-
std::wstring open_path, // source PDF document
27-
std::wstring save_path, // path to save PDF docuemnt
28-
std::wstring img_path, // watermark to apply
29-
PdfWatermarkParams watermark_params // watermark parameters
24+
const std::wstring& email, // authorization email
25+
const std::wstring& license_key, // authorization license key
26+
const std::wstring& open_path, // source PDF document
27+
const std::wstring& save_path, // path to save PDF docuemnt
28+
const std::wstring& img_path, // watermark to apply
29+
PdfWatermarkParams& watermark_params // watermark parameters
3030
) {
3131
// initialize Pdfix
3232
if (!Pdfix_init(Pdfix_MODULE_NAME))
@@ -50,12 +50,12 @@ void AddWatermark(
5050
watermark_params.opacity = 0.5;
5151
watermark_params.order_top = true;
5252

53-
5453
if (!doc->AddWatermarkFromImage(&watermark_params, img_path.c_str()))
5554
throw std::runtime_error(pdfix->GetError());
56-
doc->Save(save_path.c_str(), kSaveFull);
57-
doc->Close();
55+
if (!doc->Save(save_path.c_str(), kSaveFull))
56+
throw std::runtime_error(pdfix->GetError());
5857

58+
doc->Close();
5959
pdfix->Destroy();
6060
}
6161

src/CertDigitalSignature.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ static BOOL CALLBACK CertFilterCallback(PCCERT_CONTEXT pCertContext,
3939

4040
// Applies digital signature.
4141
void CertDigitalSignature(
42-
std::wstring email, // authorization email
43-
std::wstring license_key, // authorization license key
44-
std::wstring open_path, // source PDF document
45-
std::wstring save_path, // signed PDF document
46-
std::wstring time_stamp_server // time stamp server
42+
const std::wstring& email, // authorization email
43+
const std::wstring& license_key, // authorization license key
44+
const std::wstring& open_path, // source PDF document
45+
const std::wstring& save_path, // signed PDF document
46+
const std::wstring& time_stamp_server // time stamp server
4747
) {
4848
#ifdef WIN32
4949
HCERTSTORE cert_store = NULL;

src/ConvertToHtml.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ PdfToHtml_statics;
2424

2525
// Converts PDF to HTML.
2626
void ConvertToHtml(
27-
std::wstring email, // authorization email
28-
std::wstring license_key, // authorization license key
29-
std::wstring open_path, // source PDF document
30-
std::wstring save_path, // output HTML file
31-
std::wstring config_path, // configuration file
32-
PdfHtmlParams html_params // conversion parameters
27+
const std::wstring& email, // authorization email
28+
const std::wstring& license_key, // authorization license key
29+
const std::wstring& open_path, // source PDF document
30+
const std::wstring& save_path, // output HTML file
31+
const std::wstring& config_path, // configuration file
32+
PdfHtmlParams& html_params // conversion parameters
3333
) {
3434
// initialize Pdfix
3535
if (!Pdfix_init(Pdfix_MODULE_NAME))
@@ -46,7 +46,7 @@ void ConvertToHtml(
4646
throw std::runtime_error("PdfToHtml_init fail");
4747

4848
PdfToHtml* pdf_to_html = GetPdfToHtml();
49-
if (!pdfix)
49+
if (!pdf_to_html)
5050
throw std::runtime_error("GetPdfToHtml fail");
5151

5252
std::cout << "PDFix PDF to HTML " << pdf_to_html->GetVersionMajor() << "." <<

src/DigitalSignature.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Example how to add a text annotation with a reply.
2121

2222
// Example how to apply a digital signature from the PFX file.
2323
void DigitalSignature(
24-
std::wstring email, // authorization email
25-
std::wstring license_key, // authorization license key
26-
std::wstring open_path, // source PDF document
27-
std::wstring save_path, // signed PDF document
28-
std::wstring pfx_path, // pfx file
29-
std::wstring pfx_password // pfx password
24+
const std::wstring& email, // authorization email
25+
const std::wstring& license_key, // authorization license key
26+
const std::wstring& open_path, // source PDF document
27+
const std::wstring& save_path, // signed PDF document
28+
const std::wstring& pfx_path, // pfx file
29+
const std::wstring& pfx_password // pfx password
3030
) {
3131
// initialize Pdfix
3232
if (!Pdfix_init(Pdfix_MODULE_NAME))

src/DocumentMetadata.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Example how to get or set document metadata.
2121

2222
// Gets/sets document metadata.
2323
void DocumentMetadata(
24-
std::wstring email, // authorization email
25-
std::wstring license_key, // authorization license key
26-
std::wstring open_path, // source PDF document
27-
std::wstring save_path, // output PDF doucment
28-
std::wstring xml_path // metadata file path
24+
const std::wstring& email, // authorization email
25+
const std::wstring& license_key, // authorization license key
26+
const std::wstring& open_path, // source PDF document
27+
const std::wstring& save_path, // output PDF doucment
28+
const std::wstring& xml_path // metadata file path
2929
) {
3030
// initialize Pdfix
3131
if (!Pdfix_init(Pdfix_MODULE_NAME))

src/EmbedFonts.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Example how to Embed Fonts.
2121

2222
// Gets/sets document metadata.
2323
void EmbedFonts(
24-
std::wstring email, // authorization email
25-
std::wstring license_key, // authorization license key
26-
std::wstring open_path, // source PDF document
27-
std::wstring save_path // output PDF doucment
24+
const std::wstring& email, // authorization email
25+
const std::wstring& license_key, // authorization license key
26+
const std::wstring& open_path, // source PDF document
27+
const std::wstring& save_path // output PDF doucment
2828
) {
2929
// initialize Pdfix
3030
if (!Pdfix_init(Pdfix_MODULE_NAME))

0 commit comments

Comments
 (0)