2121
2222 // Adds watermark from img_path and saves the document to save_path.
2323void 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
0 commit comments