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-2020 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>
14 #include <C/PDF/TRN_Convert.h>
15 #include <SDF/Obj.h>
16 #include <SDF/ObjSet.h>
17 
18 namespace pdftron{
19  namespace PDF {
20 
22 // Experimental - Developer use only
24 {
25 public:
26  bool Next();
27  bool Ready();
28  UInt32 Progress();
31  void Destroy();
35 
39  operator bool () { return mp_impl!=0;}
40 #ifndef SWIGHIDDEN
41  TRN_ConversionMonitor mp_impl;
42  ConversionMonitor(TRN_ConversionMonitor impl, bool is_owner);
43  bool m_owner;
44 #endif
45 };
47 
48 class XPSOutputOptions;
49 class XODOutputOptions;
50 class HTMLOutputOptions;
51 class EPUBOutputOptions;
52 class SVGOutputOptions;
53 class TiffOutputOptions;
54 class Printer;
99 class Convert
100 {
101 public:
109 
121  };
122 
123  enum FlattenFlag {
141 
148  };
149 
159  static void FromXps(PDFDoc & in_pdfdoc, const UString & in_filename);
160 
172  static void FromXps(PDFDoc & in_pdfdoc, const char* buf, size_t buf_sz);
173 
184  static void FromEmf(PDFDoc & in_pdfdoc, const UString & in_filename);
185 
210  static void FromText(PDFDoc & in_pdfdoc, const UString& in_filename, const SDF::Obj& in_options = SDF::Obj());
211 
221  static void ToEmf(PDFDoc & in_pdfdoc, const UString & in_filename);
222 
232  static void ToEmf(Page & in_page, const UString & in_filename);
233 
234 
244  static void ToSvg(PDFDoc & in_pdfdoc, const UString & in_filename, const SVGOutputOptions& in_options);
245  static void ToSvg(PDFDoc & in_pdfdoc, const UString & in_filename);
246 
256  static void ToSvg(Page & in_page, const UString & in_filename, const SVGOutputOptions& in_options);
257  static void ToSvg(Page & in_page, const UString & in_filename);
258 
271  static void ToXps(PDFDoc & in_pdfdoc, const UString & in_filename, const XPSOutputOptions& options);
272  static void ToXps(PDFDoc & in_pdfdoc, const UString & in_filename);
273 
290  static void ToXps(const UString & in_inputFilename, const UString & in_outputFilename, const XPSOutputOptions& options);
291  static void ToXps(const UString & in_inputFilename, const UString & in_outputFilename);
292 
309  static void ToXod(const UString & in_filename, const UString & out_filename, const XODOutputOptions& options);
310  static void ToXod(const UString & in_filename, const UString & out_filename);
311 
326  static void ToXod(PDFDoc & in_pdfdoc, const UString & out_filename, const XODOutputOptions& options);
327  static void ToXod(PDFDoc & in_pdfdoc, const UString & out_filename);
328 
346  static void ToHtml(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& options);
347  static void ToHtml(const UString & in_filename, const UString & out_path);
348 
349 
358  static UString PageToHtml(const Page & page);
373  static void ToHtml(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& options);
374  static void ToHtml(PDFDoc & in_pdfdoc, const UString & out_path);
375 
397  static void ToEpub(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& html_options, const EPUBOutputOptions& epub_options);
398  static void ToEpub(const UString & in_filename, const UString & out_path, const HTMLOutputOptions& html_options);
399  static void ToEpub(const UString & in_filename, const UString & out_path);
400 
419  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& html_options, const EPUBOutputOptions& epub_options);
420  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path, const HTMLOutputOptions& html_options);
421  static void ToEpub(PDFDoc & in_pdfdoc, const UString & out_path);
422 
435  static void ToTiff(const UString & in_filename, const UString & out_path, const TiffOutputOptions& options);
436  static void ToTiff(const UString & in_filename, const UString & out_path);
437 
450  static void ToTiff(PDFDoc & in_pdfdoc, const UString & out_path, const TiffOutputOptions& options);
451  static void ToTiff(PDFDoc & in_pdfdoc, const UString & out_path);
452 
469  static Filters::Filter ToXod(const UString & in_filename, const XODOutputOptions& options);
470  static Filters::Filter ToXod(const UString & in_filename);
471 
486  static Filters::Filter ToXod(PDFDoc & in_pdfdoc, const XODOutputOptions& options);
487  static Filters::Filter ToXod(PDFDoc & in_pdfdoc);
489  // Experimental - Developer use only
490  static ConversionMonitor ToXodWithMonitor(PDFDoc & in_pdfdoc, const XODOutputOptions& options);
491  static ConversionMonitor ToXodWithMonitor(PDFDoc & in_pdfdoc);
492 
493 
515  static void WordToPDF( PDFDoc & in_pdfdoc, const UString & in_filename, WordToPDFOptions* options);
516 
543  static DocumentConversion WordToPDFConversion( PDFDoc & in_pdfdoc, const UString & in_filename, WordToPDFOptions* options);
544 
566  static void WordToPDF( PDFDoc & in_pdfdoc, Filters::Filter in_stream, WordToPDFOptions* options);
567 
594  static DocumentConversion WordToPDFConversion( PDFDoc & in_pdfdoc, Filters::Filter in_stream, WordToPDFOptions* options);
595 
617  static void OfficeToPDF( PDFDoc & in_pdfdoc, const UString & in_filename, ConversionOptions* options);
618 
644  static DocumentConversion StreamingPDFConversion( PDFDoc & in_pdfdoc, const UString & in_filename, ConversionOptions* options);
645 
669  static DocumentConversion StreamingPDFConversion(const UString & in_filename, ConversionOptions* options);
670 
692  static void OfficeToPDF( PDFDoc & in_pdfdoc, Filters::Filter in_stream, ConversionOptions* options);
693 
719  static DocumentConversion StreamingPDFConversion( PDFDoc & in_pdfdoc, Filters::Filter in_stream, ConversionOptions* options);
720 
744  static DocumentConversion StreamingPDFConversion(Filters::Filter in_stream, ConversionOptions* options);
745 
765  static void ToPdf(PDFDoc & in_pdfdoc, const UString & in_filename);
766 
777  static void FromCAD(PDFDoc& in_pdfdoc, const UString& in_filename, CADConvertOptions* opts = 0);
778 
785  static void FromTiff(PDFDoc& in_pdfdoc, Filters::Filter in_data);
786 
799  static bool RequiresPrinter(const UString & in_filename);
800 
801 
802 private:
803  Convert ();
804  ~Convert ();
805 };
806 
811 {
812 public:
821  void SetPrintMode(bool print_mode);
822 
827  void SetDPI(UInt32 dpi);
828 
833  void SetRenderPages(bool render);
834 
839  void SetThickenLines(bool thicken);
840 
846  void GenerateURLLinks(bool generate);
847 
849  {
850  e_op_off = 0,
853  };
854 
863  void SetOverprint(enum OverprintPreviewMode mode);
864 
865  TRN_Obj m_obj;
866 protected:
867  friend class Convert;
869 };
870 
875 {
876 public:
881  void SetOpenXps(bool openxps);
882 };
883 
888 {
889 public:
890 
892  e_internal_xfdf, // include the annotation file in the XOD output. This is the default option
893  e_external_xfdf, // output the annotation file externally to the same output path with extension .xfdf.
894  // This is not available when using streaming conversion
895  e_flatten // flatten all annotations that are not link annotations
896  };
897 
902  void SetOutputThumbnails(bool include_thumbs);
903 
910  void SetThumbnailSize(UInt32 size);
911 
919  void SetThumbnailSize(UInt32 regular_size, UInt32 large_size);
920 
926  void SetElementLimit(UInt32 element_limit);
927 
934  void SetOpacityMaskWorkaround(bool opacity_render);
935 
944  void SetMaximumImagePixels(UInt32 max_pixels);
945 
952  void SetFlattenContent(enum Convert::FlattenFlag flatten);
953 
960 
966  void SetPreferJPG(bool prefer_jpg);
967 
972  void SetJPGQuality(UInt32 quality);
973 
979  void SetSilverlightTextWorkaround(bool workaround);
980 
985  void SetAnnotationOutput(enum AnnotationOutputFlag annot_output);
986 
992  void SetExternalParts(bool generate);
993 
999  void SetEncryptPassword(const char* pass);
1000 
1008  void UseSilverlightFlashCompatible(bool compatible);
1009 };
1010 
1015 {
1016 public:
1021 
1026  void SetPreferJPG(bool prefer_jpg);
1027 
1032  void SetJPGQuality(UInt32 quality);
1033 
1039  void SetDPI(UInt32 dpi);
1040 
1049  void SetMaximumImagePixels(UInt32 max_pixels);
1050 
1055  void SetReflow(bool reflow);
1056 
1061  void SetScale(double scale);
1062 
1067  void SetExternalLinks(bool enable);
1068 
1073  void SetInternalLinks(bool enable);
1074 
1079  void SetSimplifyText(bool enable);
1080 
1085  void SetReportFile(const UString& path);
1086 
1087 protected:
1088  TRN_Obj m_obj;
1089  friend class Convert;
1091 };
1092 
1093 
1098 {
1099 public:
1104 
1109  void SetExpanded(bool expanded);
1110 
1117  void SetReuseCover(bool reuse);
1118 protected:
1119  TRN_Obj m_obj;
1120  friend class Convert;
1122 };
1123 
1128 {
1129 public:
1130 
1134  SVGOutputOptions();
1135 
1140  void SetEmbedImages(bool embed_images);
1141 
1146  void SetNoFonts(bool no_fonts);
1147 
1153  void SetSvgFonts(bool svg_fonts);
1154 
1161  void SetEmbedFonts(bool embed_fonts);
1162 
1167  void SetNoUnicode(bool no_unicode);
1168 
1173  void SetIndividualCharPlacement(bool individual_char_placement);
1174 
1179  void SetRemoveCharPlacement(bool remove_char_placement);
1180 
1187  void SetFlattenContent(enum Convert::FlattenFlag flatten);
1188 
1195 
1201  void SetFlattenDPI(UInt32 dpi);
1202 
1211  void SetFlattenMaximumImagePixels(UInt32 max_pixels);
1212 
1217  void SetCompress(bool svgz);
1218 
1223  void SetOutputThumbnails(bool include_thumbs);
1224 
1230  void SetThumbnailSize(UInt32 size);
1231 
1236  void SetCreateXmlWrapper(bool xml);
1237 
1242  void SetDtd(bool dtd);
1243 
1248  void SetAnnots(bool annots);
1249 
1259 protected:
1260  TRN_Obj m_obj;
1261  friend class Convert;
1263 };
1264 
1269 {
1270 public:
1275 
1282  void SetBox(enum Page::Box type);
1283 
1290  void SetRotate(enum Page::Rotate rotation);
1291 
1297  void SetClip(double x1, double y1, double x2, double y2);
1298 
1303  void SetPages(const char* page_desc);
1304 
1314 
1320  void SetCMYK(bool enable);
1321 
1328  void SetDither(bool enable);
1329 
1336  void SetGray(bool enable);
1337 
1347  void SetMono(bool enable);
1348 
1355  void SetAnnots(bool enable);
1356 
1361  void SetSmooth(bool enable);
1362 
1371  void SetPrintmode(bool enable);
1372 
1384  void SetTransparentPage(bool enable);
1385 
1386 
1392  void SetPalettized(bool enable);
1393 
1400  void SetDPI(double dpi);
1401 
1413  void SetGamma(double gamma);
1414 
1418  void SetHRes(int hres);
1419 
1423  void SetVRes(int vres);
1424 
1425 
1426 protected:
1427  TRN_Obj m_obj;
1428  friend class Convert;
1430 };
1431 
1436 class Printer
1437 {
1438 public:
1453  static void Install(const UString & in_printerName = "PDFTron PDFNet");
1454 
1462  static void Uninstall();
1463 
1472  static const UString GetPrinterName();
1473 
1482  static void SetPrinterName(const UString & in_printerName = "PDFTron PDFNet");
1483 
1495  static bool IsInstalled(const UString & in_printerName = "PDFTron PDFNet");
1496 
1497  enum Mode {
1514  };
1515 
1521  static void SetMode(Mode mode);
1522 
1528  static Mode GetMode();
1529 
1530 
1531 };
1532 
1533 #include <Impl/Convert.inl>
1534 
1535  }; // namespace PDF
1536 }; // namespace pdftron
1537 
1538 #endif // PDFTRON_H_CPPPDFConvert
void SetThumbnailSize(UInt32 size)
void SetExternalLinks(bool enable)
void SetExternalParts(bool generate)
void SetEmbedFonts(bool embed_fonts)
void SetFlattenContent(enum Convert::FlattenFlag flatten)
void SetPages(const char *page_desc)
static void FromCAD(PDFDoc &in_pdfdoc, const UString &in_filename, CADConvertOptions *opts=0)
void SetCreateXmlWrapper(bool xml)
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 SetOpacityMaskWorkaround(bool opacity_render)
pdftron::PDF::HTMLOutputOptions HTMLOutputOptions
Definition: Convert.h:104
pdftron::PDF::XODOutputOptions XODOutputOptions
Definition: Convert.h:103
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()
ConversionMonitor & operator=(const ConversionMonitor &other)
pdftron::PDF::XPSOutputOptions XPSOutputOptions
Definition: Convert.h:102
void SetReportFile(const UString &path)
TRN_ConversionMonitor mp_impl
Definition: Convert.h:41
static const UString GetPrinterName()
pdftron::PDF::Printer Printer
Definition: Convert.h:108
static void FromEmf(PDFDoc &in_pdfdoc, const UString &in_filename)
void SetOutputThumbnails(bool include_thumbs)
static ConversionMonitor ToXodWithMonitor(PDFDoc &in_pdfdoc, const XODOutputOptions &options)
void SetMaximumImagePixels(UInt32 max_pixels)
static void ToXod(const UString &in_filename, const UString &out_filename, const XODOutputOptions &options)
void SetFlattenDPI(UInt32 dpi)
pdftron::PDF::EPUBOutputOptions EPUBOutputOptions
Definition: Convert.h:105
static void ToHtml(const UString &in_filename, const UString &out_path, const HTMLOutputOptions &options)
void SetOverprint(PDFRasterizer::OverprintPreviewMode mode)
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)
void SetJPGQuality(UInt32 quality)
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
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)
pdftron::PDF::TiffOutputOptions TiffOutputOptions
Definition: Convert.h:107
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:106
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 SetOutputThumbnails(bool include_thumbs)
void SetOverprint(enum PDFRasterizer::OverprintPreviewMode mode)
void SetAnnotationOutput(enum AnnotationOutputFlag annot_output)
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 SetBox(enum Page::Box type)
void SetNoUnicode(bool no_unicode)
void SetEncryptPassword(const char *pass)
static void Install(const UString &in_printerName="PDFTron PDFNet")
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 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)