All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Convert.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFConvert
6 #define PDFTRON_H_CPPPDFConvert
7 
8 #include <PDF/PDFDoc.h>
9 #include <PDF/Page.h>
10 #include <PDF/PDFRasterizer.h>
11 #include <PDF/DocumentConversion.h>
12 #include <PDF/WordToPDFOptions.h>
13 #include <PDF/CADConvertOptions.h>
15 #include <PDF/Reflow.h>
16 #include <C/PDF/TRN_Convert.h>
17 #include <SDF/Obj.h>
18 #include <SDF/ObjSet.h>
19 
20 namespace pdftron{
21  namespace PDF {
22 
24 // Experimental - Developer use only
26 {
27 public:
28  bool Next();
29  bool Ready();
30  UInt32 Progress();
33  void Destroy();
37 
41  operator bool () { return mp_impl!=0;}
42 #ifndef SWIGHIDDEN
43  TRN_ConversionMonitor mp_impl;
44  ConversionMonitor(TRN_ConversionMonitor impl, bool is_owner);
45  bool m_owner;
46 #endif
47 };
49 
50 class XPSOutputOptions;
51 class XODOutputOptions;
52 class HTMLOutputOptions;
53 class WordOutputOptions;
54 class EPUBOutputOptions;
55 class SVGOutputOptions;
56 class TiffOutputOptions;
57 class Printer;
102 class Convert
103 {
104 public:
113 
125  };
126 
127  enum FlattenFlag {
145 
152  };
153 
163  static void FromXps(PDFDoc & in_pdfdoc, const UString & in_filename);
164 
176  static void FromXps(PDFDoc & in_pdfdoc, const char* buf, size_t buf_sz);
177 
188  static void FromEmf(PDFDoc & in_pdfdoc, const UString & in_filename);
189 
214  static void FromText(PDFDoc & in_pdfdoc, const UString& in_filename, const SDF::Obj& in_options = SDF::Obj());
215 
225  static void ToEmf(PDFDoc & in_pdfdoc, const UString & in_filename);
226 
236  static void ToEmf(Page & in_page, const UString & in_filename);
237 
238 
248  static void ToSvg(PDFDoc & in_pdfdoc, const UString & in_filename, const SVGOutputOptions& in_options);
249 
257  static void ToSvg(PDFDoc & in_pdfdoc, const UString & in_filename);
258 
268  static void ToSvg(Page & in_page, const UString & in_filename, const SVGOutputOptions& in_options);
269 
277  static void ToSvg(Page & in_page, const UString & in_filename);
278 
291  static void ToXps(PDFDoc & in_pdfdoc, const UString & in_filename, const XPSOutputOptions& options);
292 
301  static void ToXps(PDFDoc & in_pdfdoc, const UString & in_filename);
302 
319  static void ToXps(const UString & in_inputFilename, const UString & in_outputFilename, const XPSOutputOptions& options);
320 
333  static void ToXps(const UString & in_inputFilename, const UString & in_outputFilename);
334 
351  static void ToXod(const UString & in_filename, const UString & out_filename, const XODOutputOptions& options);
352 
365  static void ToXod(const UString & in_filename, const UString & out_filename);
366 
381  static void ToXod(PDFDoc & in_pdfdoc, const UString & out_filename, const XODOutputOptions& options);
382 
393  static void ToXod(PDFDoc & in_pdfdoc, const UString & out_filename);
394 
416  static void ToHtml(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& options);
417 
431  static void ToHtml(const UString & in_filename, const UString & out_path);
432 
433 
442  static UString PageToHtml(const Page & page);
453  static UString PageToHtmlZoned(const Page & page, const UString & json_zones);
454 
473  static void ToHtml(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& options);
474 
485  static void ToHtml(PDFDoc & in_pdfdoc, const UString & out_path);
486 
502  static void ToWord(const UString & inputFilename, const UString & outputPath, const WordOutputOptions& options);
503 
515  static void ToWord(const UString & inputFilename, const UString & outputPath);
516 
534  static void ToWord(PDFDoc & pdfdoc, const UString & outputPath, const WordOutputOptions& options);
535 
549  static void ToWord(PDFDoc & pdfdoc, const UString & outputPath);
550 
571  static void ToEpub(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& html_options, const EPUBOutputOptions& epub_options);
572 
589  static void ToEpub(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& html_options);
590 
603  static void ToEpub(const UString & in_filename, const UString & out_path);
604 
623  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& html_options, const EPUBOutputOptions& epub_options);
624 
639  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& html_options);
640 
651  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path);
652 
665  static void ToTiff(const UString & in_filename, const UString & out_path, const TiffOutputOptions& options);
666 
675  static void ToTiff(const UString & in_filename, const UString & out_path);
676 
689  static void ToTiff(PDFDoc & in_pdfdoc, const UString & out_path, const TiffOutputOptions& options);
690 
699  static void ToTiff(PDFDoc & in_pdfdoc, const UString & out_path);
700 
717  static Filters::Filter ToXod(const UString & in_filename, const XODOutputOptions& options);
718 
731  static Filters::Filter ToXod(const UString & in_filename);
732 
747  static Filters::Filter ToXod(PDFDoc & in_pdfdoc, const XODOutputOptions& options);
748 
759  static Filters::Filter ToXod(PDFDoc & in_pdfdoc);
761  // Experimental - Developer use only
762  static ConversionMonitor ToXodWithMonitor(PDFDoc & in_pdfdoc, const XODOutputOptions& options);
763  static ConversionMonitor ToXodWithMonitor(PDFDoc & in_pdfdoc);
764 
765 
787  static void WordToPDF( PDFDoc & in_pdfdoc, const UString & in_filename, WordToPDFOptions* options);
788 
815  static DocumentConversion WordToPDFConversion( PDFDoc & in_pdfdoc, const UString & in_filename, WordToPDFOptions* options);
816 
838  static void WordToPDF( PDFDoc & in_pdfdoc, Filters::Filter in_stream, WordToPDFOptions* options);
839 
866  static DocumentConversion WordToPDFConversion( PDFDoc & in_pdfdoc, Filters::Filter in_stream, WordToPDFOptions* options);
867 
889  static void OfficeToPDF( PDFDoc & in_pdfdoc, const UString & in_filename, ConversionOptions* options);
890 
916  static DocumentConversion StreamingPDFConversion( PDFDoc & in_pdfdoc, const UString & in_filename, ConversionOptions* options);
917 
941  static DocumentConversion StreamingPDFConversion(const UString & in_filename, ConversionOptions* options);
942 
943  static Reflow CreateReflow(Page & in_page, const UString & json_zones);
944 
966  static void OfficeToPDF( PDFDoc & in_pdfdoc, Filters::Filter in_stream, ConversionOptions* options);
967 
993  static DocumentConversion StreamingPDFConversion( PDFDoc & in_pdfdoc, Filters::Filter in_stream, ConversionOptions* options);
994 
1018  static DocumentConversion StreamingPDFConversion(Filters::Filter in_stream, ConversionOptions* options);
1019 
1039  static void ToPdf(PDFDoc & in_pdfdoc, const UString & in_filename);
1040 
1051  static void FromCAD(PDFDoc& in_pdfdoc, const UString& in_filename, CADConvertOptions* opts = 0);
1052 
1063  static void FromDICOM(PDFDoc& in_pdfdoc, const UString& in_filename, AdvancedImagingConvertOptions* opts = 0);
1064 
1071  static void FromTiff(PDFDoc& in_pdfdoc, Filters::Filter in_data);
1072 
1085  static bool RequiresPrinter(const UString & in_filename);
1086 
1087 
1088 private:
1089  Convert ();
1090  ~Convert ();
1091 };
1092 
1097 {
1098 public:
1107  void SetPrintMode(bool print_mode);
1108 
1113  void SetDPI(UInt32 dpi);
1114 
1119  void SetRenderPages(bool render);
1120 
1125  void SetThickenLines(bool thicken);
1126 
1132  void GenerateURLLinks(bool generate);
1133 
1135  {
1139  };
1140 
1149  void SetOverprint(enum OverprintPreviewMode mode);
1150 
1151  TRN_Obj m_obj;
1152 protected:
1153  friend class Convert;
1155 };
1156 
1161 {
1162 public:
1167  void SetOpenXps(bool openxps);
1168 };
1169 
1174 {
1175 public:
1176 
1178  e_internal_xfdf, // include the annotation file in the XOD output. This is the default option
1179  e_external_xfdf, // output the annotation file externally to the same output path with extension .xfdf.
1180  // This is not available when using streaming conversion
1181  e_flatten // flatten all annotations that are not link annotations
1182  };
1183 
1188  void SetOutputThumbnails(bool include_thumbs);
1189 
1196  void SetThumbnailSize(UInt32 size);
1197 
1205  void SetThumbnailSize(UInt32 regular_size, UInt32 large_size);
1206 
1212  void SetElementLimit(UInt32 element_limit);
1213 
1220  void SetOpacityMaskWorkaround(bool opacity_render);
1221 
1230  void SetMaximumImagePixels(UInt32 max_pixels);
1231 
1238  void SetFlattenContent(enum Convert::FlattenFlag flatten);
1239 
1246 
1252  void SetPreferJPG(bool prefer_jpg);
1253 
1258  void SetJPGQuality(UInt32 quality);
1259 
1265  void SetSilverlightTextWorkaround(bool workaround);
1266 
1271  void SetAnnotationOutput(enum AnnotationOutputFlag annot_output);
1272 
1278  void SetExternalParts(bool generate);
1279 
1285  void SetEncryptPassword(const char* pass);
1286 
1294  void UseSilverlightFlashCompatible(bool compatible);
1295 };
1296 
1301 {
1302 public:
1307 
1312  void SetPreferJPG(bool prefer_jpg);
1313 
1318  void SetJPGQuality(UInt32 quality);
1319 
1326  void SetDPI(UInt32 dpi);
1327 
1337  void SetMaximumImagePixels(UInt32 max_pixels);
1338 
1340  {
1341  e_fixed_position = 0, /* Content uses fixed positioning (default). */
1342  e_reflow_paragraphs /* Text flows within paragraphs. */
1343  };
1344 
1354 
1360  void SetScale(double scale);
1361 
1367  void SetExternalLinks(bool enable);
1368 
1374  void SetInternalLinks(bool enable);
1375 
1381  void SetSimplifyText(bool enable);
1382 
1388  void SetReportFile(const UString& path);
1389 
1395  void SetTitle(const UString& title);
1396 
1403  void SetImageDPI(UInt32 dpi);
1404 
1410  void SetEmbedImages(bool embed);
1411 
1418  void SetFileConversionTimeoutSeconds(int seconds);
1419 
1427  void SetPages(int pageFrom, int pageTo);
1428 
1434  void SetPDFPassword(const UString& password);
1435 
1437  {
1438  e_ocr_image_text = 0, /* Indicates that both text and image are going to be visible (default). */
1439  e_ocr_image, /* Indicates that only the images are going to be visible. */
1440  e_ocr_text /* Indicates that only the text is going to be visible. */
1441  };
1442 
1451 
1457  void SetSimpleLists(bool enable);
1458 
1464  void SetConnectHyphens(bool connect);
1465 
1472  void SetDisableVerticalSplit(bool disable);
1473 
1479  void SetNoPageWidth(bool enable);
1480 
1481 protected:
1482  TRN_Obj m_obj;
1483  friend class Convert;
1485 };
1486 
1491 {
1492 public:
1497 
1502  void SetJPGQuality(UInt32 quality);
1503 
1509  void SetImageDPI(UInt32 dpi);
1510 
1512  {
1516  };
1517 
1525 
1531  void SetFileConversionTimeoutSeconds(int seconds);
1532 
1539  void SetPages(int pageFrom, int pageTo);
1540 
1545  void SetPDFPassword(const UString& password);
1546 
1548  {
1549  e_bm_none = 0, /* Indicates that no bookmarks are created. */
1550  e_bm_page, /* Indicates that a bookmark is created for each page (default). */
1551  e_bm_extract /* Indicates that bookmarks are converted from PDF to Word. */
1552  };
1553 
1560 
1562  {
1563  e_ocr_image_text = 0, /* Indicates that both text and image are going to be visible (default). */
1564  e_ocr_image, /* Indicates that only the images are going to be visible. */
1565  e_ocr_text /* Indicates that only the text is going to be visible. */
1566  };
1567 
1575 
1580  void SetShrinkCharacterSpacingToPreventWrap(bool shrink);
1581 
1587  void SetMatchPDFLineBreaks(bool match);
1588 
1593  void SetConnectHyphens(bool connect);
1594 
1599  void SetDoNotAdjustFonts(bool do_not_adjust);
1600 
1606  void SetDisableVerticalSplit(bool disable);
1607 
1608 protected:
1609  TRN_Obj m_obj;
1610  friend class Convert;
1612 };
1613 
1618 {
1619 public:
1624 
1629  void SetExpanded(bool expanded);
1630 
1637  void SetReuseCover(bool reuse);
1638 protected:
1639  TRN_Obj m_obj;
1640  friend class Convert;
1642 };
1643 
1648 {
1649 public:
1650 
1654  SVGOutputOptions();
1655 
1660  void SetEmbedImages(bool embed_images);
1661 
1666  void SetNoFonts(bool no_fonts);
1667 
1673  void SetSvgFonts(bool svg_fonts);
1674 
1681  void SetEmbedFonts(bool embed_fonts);
1682 
1687  void SetNoUnicode(bool no_unicode);
1688 
1693  void SetIndividualCharPlacement(bool individual_char_placement);
1694 
1699  void SetRemoveCharPlacement(bool remove_char_placement);
1700 
1707  void SetFlattenContent(enum Convert::FlattenFlag flatten);
1708 
1715 
1721  void SetFlattenDPI(UInt32 dpi);
1722 
1731  void SetFlattenMaximumImagePixels(UInt32 max_pixels);
1732 
1737  void SetCompress(bool svgz);
1738 
1743  void SetOutputThumbnails(bool include_thumbs);
1744 
1750  void SetThumbnailSize(UInt32 size);
1751 
1756  void SetCreateXmlWrapper(bool xml);
1757 
1762  void SetDtd(bool dtd);
1763 
1768  void SetAnnots(bool annots);
1769 
1779 protected:
1780  TRN_Obj m_obj;
1781  friend class Convert;
1783 };
1784 
1789 {
1790 public:
1795 
1802  void SetBox(enum Page::Box type);
1803 
1810  void SetRotate(enum Page::Rotate rotation);
1811 
1817  void SetClip(double x1, double y1, double x2, double y2);
1818 
1823  void SetPages(const char* page_desc);
1824 
1834 
1840  void SetCMYK(bool enable);
1841 
1848  void SetDither(bool enable);
1849 
1856  void SetGray(bool enable);
1857 
1867  void SetMono(bool enable);
1868 
1875  void SetAnnots(bool enable);
1876 
1881  void SetSmooth(bool enable);
1882 
1891  void SetPrintmode(bool enable);
1892 
1904  void SetTransparentPage(bool enable);
1905 
1906 
1912  void SetPalettized(bool enable);
1913 
1920  void SetDPI(double dpi);
1921 
1933  void SetGamma(double gamma);
1934 
1938  void SetHRes(int hres);
1939 
1943  void SetVRes(int vres);
1944 
1945 
1946 protected:
1947  TRN_Obj m_obj;
1948  friend class Convert;
1950 };
1951 
1956 class Printer
1957 {
1958 public:
1973  static void Install(const UString & in_printerName = "PDFTron PDFNet");
1974 
1982  static void Uninstall();
1983 
1992  static const UString GetPrinterName();
1993 
2002  static void SetPrinterName(const UString & in_printerName = "PDFTron PDFNet");
2003 
2015  static bool IsInstalled(const UString & in_printerName = "PDFTron PDFNet");
2016 
2017  enum Mode {
2034  };
2035 
2041  static void SetMode(Mode mode);
2042 
2048  static Mode GetMode();
2049 
2050 
2051 };
2052 
2053 #include <Impl/Convert.inl>
2054 
2055  }; // namespace PDF
2056 }; // namespace pdftron
2057 
2058 #endif // PDFTRON_H_CPPPDFConvert
void SetThumbnailSize(UInt32 size)
void SetSearchableImageSetting(SearchableImageSetting setting)
void SetPages(int pageFrom, int pageTo)
void SetExternalLinks(bool enable)
void SetPages(int pageFrom, int pageTo)
void SetExternalParts(bool generate)
void SetEmbedFonts(bool embed_fonts)
void SetFlattenContent(enum Convert::FlattenFlag flatten)
void SetBookmarkConversionMethod(BookmarkConversionMethod method)
void SetJPGQuality(UInt32 quality)
void SetPages(const char *page_desc)
static void FromCAD(PDFDoc &in_pdfdoc, const UString &in_filename, CADConvertOptions *opts=0)
void SetCreateXmlWrapper(bool xml)
void SetShrinkCharacterSpacingToPreventWrap(bool shrink)
void SetFlattenThreshold(enum Convert::FlattenThresholdFlag threshold)
static void SetPrinterName(const UString &in_printerName="PDFTron PDFNet")
void SetRotate(enum Page::Rotate rotation)
void SetFlattenMaximumImagePixels(UInt32 max_pixels)
static DocumentConversion StreamingPDFConversion(PDFDoc &in_pdfdoc, const UString &in_filename, ConversionOptions *options)
void SetSimpleLists(bool enable)
void SetOpacityMaskWorkaround(bool opacity_render)
pdftron::PDF::HTMLOutputOptions HTMLOutputOptions
Definition: Convert.h:107
pdftron::PDF::WordOutputOptions WordOutputOptions
Definition: Convert.h:108
pdftron::PDF::XODOutputOptions XODOutputOptions
Definition: Convert.h:106
static void ToEmf(PDFDoc &in_pdfdoc, const UString &in_filename)
static void FromXps(PDFDoc &in_pdfdoc, const UString &in_filename)
void SetMaximumImagePixels(UInt32 max_pixels)
void SetThumbnailSize(UInt32 size)
void SetRemoveCharPlacement(bool remove_char_placement)
static Mode GetMode()
void SetConnectHyphens(bool connect)
static Reflow CreateReflow(Page &in_page, const UString &json_zones)
ConversionMonitor & operator=(const ConversionMonitor &other)
pdftron::PDF::XPSOutputOptions XPSOutputOptions
Definition: Convert.h:105
void SetReportFile(const UString &path)
TRN_ConversionMonitor mp_impl
Definition: Convert.h:43
static const UString GetPrinterName()
pdftron::PDF::Printer Printer
Definition: Convert.h:112
void SetSearchableImageSetting(SearchableImageSetting setting)
static void FromEmf(PDFDoc &in_pdfdoc, const UString &in_filename)
void SetWordOutputFormat(WordOutputFormat format)
void SetOutputThumbnails(bool include_thumbs)
static ConversionMonitor ToXodWithMonitor(PDFDoc &in_pdfdoc, const XODOutputOptions &options)
static void FromDICOM(PDFDoc &in_pdfdoc, const UString &in_filename, AdvancedImagingConvertOptions *opts=0)
void SetMaximumImagePixels(UInt32 max_pixels)
static void ToXod(const UString &in_filename, const UString &out_filename, const XODOutputOptions &options)
void SetTitle(const UString &title)
void SetFlattenDPI(UInt32 dpi)
pdftron::PDF::EPUBOutputOptions EPUBOutputOptions
Definition: Convert.h:109
void SetFileConversionTimeoutSeconds(int seconds)
void SetPDFPassword(const UString &password)
static void ToHtml(const UString &in_filename, const UString &out_path, const HTMLOutputOptions &options)
void SetOverprint(PDFRasterizer::OverprintPreviewMode mode)
void SetDisableVerticalSplit(bool disable)
void SetIndividualCharPlacement(bool individual_char_placement)
void SetPrintMode(bool print_mode)
static void FromText(PDFDoc &in_pdfdoc, const UString &in_filename, const SDF::Obj &in_options=SDF::Obj())
void SetPalettized(bool enable)
static UString PageToHtmlZoned(const Page &page, const UString &json_zones)
void SetJPGQuality(UInt32 quality)
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
void SetConnectHyphens(bool connect)
static void ToSvg(PDFDoc &in_pdfdoc, const UString &in_filename, const SVGOutputOptions &in_options)
static DocumentConversion WordToPDFConversion(PDFDoc &in_pdfdoc, const UString &in_filename, WordToPDFOptions *options)
void SetSilverlightTextWorkaround(bool workaround)
void SetTransparentPage(bool enable)
void SetOverprint(enum OverprintPreviewMode mode)
void SetPDFPassword(const UString &password)
pdftron::PDF::TiffOutputOptions TiffOutputOptions
Definition: Convert.h:111
void SetEmbedImages(bool embed_images)
void GenerateURLLinks(bool generate)
void SetPreferJPG(bool prefer_jpg)
void SetSimplifyText(bool enable)
pdftron::PDF::SVGOutputOptions SVGOutputOptions
Definition: Convert.h:110
void UseSilverlightFlashCompatible(bool compatible)
static bool IsInstalled(const UString &in_printerName="PDFTron PDFNet")
void SetExpanded(bool expanded)
static void ToPdf(PDFDoc &in_pdfdoc, const UString &in_filename)
static void SetMode(Mode mode)
void SetFlattenThreshold(enum Convert::FlattenThresholdFlag threshold)
void SetPrintmode(bool enable)
void SetClip(double x1, double y1, double x2, double y2)
void SetPreferJPG(bool prefer_jpg)
void SetInternalLinks(bool enable)
static void ToXps(PDFDoc &in_pdfdoc, const UString &in_filename, const XPSOutputOptions &options)
static bool RequiresPrinter(const UString &in_filename)
static void Uninstall()
void SetSvgFonts(bool svg_fonts)
void SetNoFonts(bool no_fonts)
void SetFileConversionTimeoutSeconds(int seconds)
void SetOutputThumbnails(bool include_thumbs)
void SetNoPageWidth(bool enable)
void SetOverprint(enum PDFRasterizer::OverprintPreviewMode mode)
void SetAnnotationOutput(enum AnnotationOutputFlag annot_output)
void SetMatchPDFLineBreaks(bool match)
static void ToWord(const UString &inputFilename, const UString &outputPath, const WordOutputOptions &options)
void SetJPGQuality(UInt32 quality)
static void WordToPDF(PDFDoc &in_pdfdoc, const UString &in_filename, WordToPDFOptions *options)
static void ToEpub(const UString &in_filename, const UString &out_path, const HTMLOutputOptions &html_options, const EPUBOutputOptions &epub_options)
void SetContentReflowSetting(ContentReflowSetting reflow)
void SetBox(enum Page::Box type)
void SetNoUnicode(bool no_unicode)
void SetEncryptPassword(const char *pass)
static void Install(const UString &in_printerName="PDFTron PDFNet")
void SetDoNotAdjustFonts(bool do_not_adjust)
static void ToTiff(const UString &in_filename, const UString &out_path, const TiffOutputOptions &options)
static void FromTiff(PDFDoc &in_pdfdoc, Filters::Filter in_data)
void SetFlattenContent(enum Convert::FlattenFlag flatten)
void SetDisableVerticalSplit(bool disable)
void SetElementLimit(UInt32 element_limit)
static void OfficeToPDF(PDFDoc &in_pdfdoc, const UString &in_filename, ConversionOptions *options)
static UString PageToHtml(const Page &page)
void SetOpenXps(bool openxps)