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-2025 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 
214  void SetSandbox(bool sandbox);
215 
221  void SetLogFilePath(const UString& path);
222 
228  UString GetLog() const;
229 
237  static void SetModulePath(const UString& path);
238 
239 
245  static bool IsModuleAvailable();
246 
250  HTML2PDF();
251 
255  ~HTML2PDF();
256 
263 
272  void SetPaperSize(const UString& width, const UString& height);
273 
280  void SetLandscape(bool enable);
281 
290  void SetDPI(int dpi);
291 
300  void SetOutline(bool enable, int depth = 4);
301 
309  void DumpOutline(const UString& xml_file);
310 
319  void SetPDFCompression(bool enable);
320 
331  void SetMargins(const UString& top, const UString& bottom, const UString& left, const UString& right);
332 
338  void SetHeader(const UString& header);
339 
345  void SetFooter(const UString& footer);
346 
353  void SetImageDPI(int dpi);
354 
361  void SetImageQuality(int quality);
362 
369  void SetCookieJar(const UString& path);
370 
371 /* {{codegen: HTML2PDF}} */
372 
379  void AddCookie(const UString& name, const UString& value);
380 
387  void SetCustomHeader(const UString& name, const UString& value);
388 /* {{codegen: HTML2PDF}} */
389 
393  void Destroy();
394 
395  // @cond PRIVATE_DOC
396 
397  #ifndef SWIGHIDDEN
398  TRN_HTML2PDF mp_html2pdf;
399  #endif
400 
401 private:
402  HTML2PDF(const HTML2PDF&);
403  HTML2PDF& operator= (const HTML2PDF&);
404  // @endcond
405 
406 };
407 
408 
414 class Proxy
415 {
416 public:
420  Proxy();
421 
425  ~Proxy();
426 
435  void SetType(Type type);
436 
442  void SetHost(const UString& host);
443 
449  void SetPort(int port);
450 
456  void SetUsername(const UString& username);
457 
463  void SetPassword(const UString& password);
464 
468  void Destroy();
469 
470  // @cond PRIVATE_DOC
471 
472 #ifndef SWIGHIDDEN
473  TRN_HTML2PDF_Proxy mp_impl;
474 #endif
475  // @endcond
476 
477 };
478 
483 {
484 public:
488  WebPageSettings();
489 
494 
500  void SetPrintBackground(bool background);
501 
508  void SetLoadImages(bool load);
509 
515  void SetAllowJavaScript(bool enable);
516 
524  void SetSmartShrinking(bool enable);
525 
532  void SetMinimumFontSize(int size);
533 
548  void SetDefaultEncoding(const UString& encoding);
549 
557  void SetUserStyleSheet(const UString& url);
558 
566  void SetAllowPlugins(bool enable);
567 
575  void SetPrintMediaType(bool print);
576 
586  void SetIncludeInOutline(bool include);
587 
593  void SetUsername(const UString& username);
594 
600  void SetPassword(const UString& password);
601 
609  void SetJavaScriptDelay(int msec);
610 
618  void SetConvertDelay(int msec);
619 
626  void SetTimeout(int msec);
627 
633  void SetZoom(double zoom);
634 
641  void SetBlockLocalFileAccess(bool block);
642 
649  void SetStopSlowScripts(bool stop);
650 
658  void SetDebugJavaScriptOutput(bool forward);
659 
670  e_abort, // Abort the conversion process.
671  e_skip, // Do not add the object to the final output
672  e_ignore // Try to add the object to the final output.
673  };
675 
684  void SetExternalLinks(bool convert);
685 
693  void SetInternalLinks(bool convert);
694 
702  void SetProduceForms(bool forms);
703 
709  void SetProxy(const Proxy& proxy);
710 
714  void Destroy();
715 
716  // @cond PRIVATE_DOC
717 
718 #ifndef SWIGHIDDEN
719  TRN_HTML2PDF_WebPageSettings mp_impl;
720 #endif
721  // @endcond
722 
723 };
724 
731 {
732 public:
736  TOCSettings();
737 
741  ~TOCSettings();
742 
749  void SetDottedLines(bool enable);
750 
758  void SetLinks(bool enable);
759 
766  void SetCaptionText(const UString& caption);
767 
774  void SetLevelIndentation(int indentation);
775 
782  void SetTextSizeShrink(double shrink);
783 
792  void SetXsl(const UString& style_sheet);
793 
797  void Destroy();
798 
799  // @cond PRIVATE_DOC
800 
801 #ifndef SWIGHIDDEN
802  TRN_HTML2PDF_TOCSettings mp_impl;
803 #endif
804  // @endcond
805 
806 };
807 
808  }; // namespace PDF
809 }; // namespace pdftron
810 
811 #include <Impl/HTML2PDF.inl>
812 
813 #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 SetSandbox(bool sandbox)
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)