All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HTML2PDF.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFHTML2PDF
6 #define PDFTRON_H_CPPPDFHTML2PDF
7 
8 #include <PDF/PDFDoc.h>
9 #include <PDF/Print.h>
10 #include <C/PDF/TRN_HTML2PDF.h>
11 
12 namespace pdftron {
13  namespace PDF {
14 
15 class Proxy;
16 class WebPageSettings;
17 class TOCSettings;
18 
64 class HTML2PDF
65 {
66 public:
70 
71 #ifndef SWIG
72 
90  static bool Convert(PDFDoc& doc, const UString& url);
91 
112  static bool Convert(PDFDoc& doc, const UString& url, const WebPageSettings& settings);
113 #endif
114 
120  void InsertFromURL(const UString& url);
121 
129  void InsertFromURL(const UString& url, const WebPageSettings& settings);
130 
136  void InsertFromHtmlString(const UString& html);
137 
144  void InsertFromHtmlString(const UString& html, const WebPageSettings& settings);
145 
150  void InsertTOC();
151 
158  void InsertTOC(const TOCSettings& settings);
159 
176  bool Convert(PDFDoc& doc);
177 
186  int GetHTTPErrorCode() const;
187 
195  void SetQuiet(bool quiet);
196 
205  void SetCompatibilityMode(bool compatibility);
206 
212  void SetLogFilePath(const UString& path);
213 
219  UString GetLog() const;
220 
228  static void SetModulePath(const UString& path);
229 
230 
236  static bool IsModuleAvailable();
237 
241  HTML2PDF();
242 
246  ~HTML2PDF();
247 
254 
263  void SetPaperSize(const UString& width, const UString& height);
264 
271  void SetLandscape(bool enable);
272 
281  void SetDPI(int dpi);
282 
291  void SetOutline(bool enable, int depth = 4);
292 
300  void DumpOutline(const UString& xml_file);
301 
310  void SetPDFCompression(bool enable);
311 
322  void SetMargins(const UString& top, const UString& bottom, const UString& left, const UString& right);
323 
329  void SetHeader(const UString& header);
330 
336  void SetFooter(const UString& footer);
337 
344  void SetImageDPI(int dpi);
345 
352  void SetImageQuality(int quality);
353 
360  void SetCookieJar(const UString& path);
361 
362 /* {{codegen: HTML2PDF}} */
363 
370  void AddCookie(const UString& name, const UString& value);
371 
378  void SetCustomHeader(const UString& name, const UString& value);
379 /* {{codegen: HTML2PDF}} */
380 
384  void Destroy();
385 
386  // @cond PRIVATE_DOC
387 
388  #ifndef SWIGHIDDEN
389  TRN_HTML2PDF mp_html2pdf;
390  #endif
391 
392 private:
393  HTML2PDF(const HTML2PDF&);
394  HTML2PDF& operator= (const HTML2PDF&);
395  // @endcond
396 
397 };
398 
399 
405 class Proxy
406 {
407 public:
411  Proxy();
412 
416  ~Proxy();
417 
426  void SetType(Type type);
427 
433  void SetHost(const UString& host);
434 
440  void SetPort(int port);
441 
447  void SetUsername(const UString& username);
448 
454  void SetPassword(const UString& password);
455 
459  void Destroy();
460 
461  // @cond PRIVATE_DOC
462 
463 #ifndef SWIGHIDDEN
464  TRN_HTML2PDF_Proxy mp_impl;
465 #endif
466  // @endcond
467 
468 };
469 
474 {
475 public:
479  WebPageSettings();
480 
485 
491  void SetPrintBackground(bool background);
492 
499  void SetLoadImages(bool load);
500 
506  void SetAllowJavaScript(bool enable);
507 
515  void SetSmartShrinking(bool enable);
516 
523  void SetMinimumFontSize(int size);
524 
539  void SetDefaultEncoding(const UString& encoding);
540 
548  void SetUserStyleSheet(const UString& url);
549 
557  void SetAllowPlugins(bool enable);
558 
566  void SetPrintMediaType(bool print);
567 
577  void SetIncludeInOutline(bool include);
578 
584  void SetUsername(const UString& username);
585 
591  void SetPassword(const UString& password);
592 
600  void SetJavaScriptDelay(int msec);
601 
609  void SetConvertDelay(int msec);
610 
617  void SetTimeout(int msec);
618 
624  void SetZoom(double zoom);
625 
632  void SetBlockLocalFileAccess(bool block);
633 
640  void SetStopSlowScripts(bool stop);
641 
649  void SetDebugJavaScriptOutput(bool forward);
650 
661  e_abort, // Abort the conversion process.
662  e_skip, // Do not add the object to the final output
663  e_ignore // Try to add the object to the final output.
664  };
666 
675  void SetExternalLinks(bool convert);
676 
684  void SetInternalLinks(bool convert);
685 
693  void SetProduceForms(bool forms);
694 
700  void SetProxy(const Proxy& proxy);
701 
705  void Destroy();
706 
707  // @cond PRIVATE_DOC
708 
709 #ifndef SWIGHIDDEN
710  TRN_HTML2PDF_WebPageSettings mp_impl;
711 #endif
712  // @endcond
713 
714 };
715 
722 {
723 public:
727  TOCSettings();
728 
732  ~TOCSettings();
733 
740  void SetDottedLines(bool enable);
741 
749  void SetLinks(bool enable);
750 
757  void SetCaptionText(const UString& caption);
758 
765  void SetLevelIndentation(int indentation);
766 
773  void SetTextSizeShrink(double shrink);
774 
783  void SetXsl(const UString& style_sheet);
784 
788  void Destroy();
789 
790  // @cond PRIVATE_DOC
791 
792 #ifndef SWIGHIDDEN
793  TRN_HTML2PDF_TOCSettings mp_impl;
794 #endif
795  // @endcond
796 
797 };
798 
799  }; // namespace PDF
800 }; // namespace pdftron
801 
802 #include <Impl/HTML2PDF.inl>
803 
804 #endif // PDFTRON_H_CPPPDFHTML2PDF
void SetCookieJar(const UString &path)
void SetPrintMediaType(bool print)
void SetMargins(const UString &top, const UString &bottom, const UString &left, const UString &right)
int GetHTTPErrorCode() const
void InsertFromURL(const UString &url)
void SetLevelIndentation(int indentation)
void SetImageQuality(int quality)
void DumpOutline(const UString &xml_file)
void SetLogFilePath(const UString &path)
void SetLinks(bool enable)
void SetFooter(const UString &footer)
void SetPDFCompression(bool enable)
void SetXsl(const UString &style_sheet)
void SetIncludeInOutline(bool include)
void SetImageDPI(int dpi)
pdftron::PDF::WebPageSettings WebPageSettings
Definition: HTML2PDF.h:68
void SetStopSlowScripts(bool stop)
void SetType(Type type)
void SetHeader(const UString &header)
void SetTextSizeShrink(double shrink)
void SetSmartShrinking(bool enable)
void SetUserStyleSheet(const UString &url)
void SetQuiet(bool quiet)
void SetProxy(const Proxy &proxy)
void SetPrintBackground(bool background)
static bool IsModuleAvailable()
void SetPassword(const UString &password)
void SetJavaScriptDelay(int msec)
void SetCompatibilityMode(bool compatibility)
UString GetLog() const
void SetCustomHeader(const UString &name, const UString &value)
void SetBlockLocalFileAccess(bool block)
void SetUsername(const UString &username)
void SetOutline(bool enable, int depth=4)
void SetAllowJavaScript(bool enable)
void SetInternalLinks(bool convert)
void SetPaperSize(PrinterMode::PaperSize size)
static void SetModulePath(const UString &path)
void SetAllowPlugins(bool enable)
void SetPassword(const UString &password)
void SetLoadErrorHandling(ErrorHandling type)
void SetDefaultEncoding(const UString &encoding)
void SetHost(const UString &host)
void SetDPI(int dpi)
void InsertFromHtmlString(const UString &html)
pdftron::PDF::Proxy Proxy
Definition: HTML2PDF.h:67
void SetDottedLines(bool enable)
void SetCaptionText(const UString &caption)
pdftron::PDF::TOCSettings TOCSettings
Definition: HTML2PDF.h:69
void SetUsername(const UString &username)
void AddCookie(const UString &name, const UString &value)
void SetLandscape(bool enable)
static bool Convert(PDFDoc &doc, const UString &url)
void SetExternalLinks(bool convert)
void SetDebugJavaScriptOutput(bool forward)
void SetPort(int port)
void SetMinimumFontSize(int size)
void SetProduceForms(bool forms)