• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef QPDF_PDFTOPDF_PROCESSOR_H
2 #define QPDF_PDFTOPDF_PROCESSOR_H
3 
4 #include "pdftopdf_processor.h"
5 #include <qpdf/QPDF.hh>
6 
7 class QPDF_PDFTOPDF_PageHandle : public PDFTOPDF_PageHandle {
8  public:
9   virtual PageRect getRect() const;
10   virtual void add_border_rect(const PageRect &rect,BorderType border,float fscale);
11   virtual void add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop=NULL);
12   virtual void mirror();
13   virtual void rotate(Rotation rot);
14   virtual void add_label(const PageRect &rect, const std::string label);
15   virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Rotation param_orientation,Position xpos,Position ypos,bool scale,bool autorotate);
16   virtual bool is_landscape(Rotation orientation);
17   void debug(const PageRect &rect,float xpos,float ypos);
18  private:
19   bool isExisting() const;
20   QPDFObjectHandle get(); // only once!
21  private:
22   friend class QPDF_PDFTOPDF_Processor;
23   // 1st mode: existing
24   QPDF_PDFTOPDF_PageHandle(QPDFObjectHandle page,int orig_no=-1);
25   QPDFObjectHandle page;
26   int no;
27 
28   // 2nd mode: create new
29   QPDF_PDFTOPDF_PageHandle(QPDF *pdf,float width,float height);
30   std::map<std::string,QPDFObjectHandle> xobjs;
31   std::string content;
32 
33   Rotation rotation;
34 };
35 
36 class QPDF_PDFTOPDF_Processor : public PDFTOPDF_Processor {
37  public:
38   virtual bool loadFile(FILE *f,ArgOwnership take=WillStayAlive,int flatten_forms=1);
39   virtual bool loadFilename(const char *name,int flatten_forms=1);
40 
41   // TODO: virtual bool may_modify/may_print/?
42   virtual bool check_print_permissions();
43 
44   // virtual bool setProcess(const ProcessingParameters &param) =0;
45 
46   virtual std::vector<std::shared_ptr<PDFTOPDF_PageHandle>> get_pages();
47   virtual std::shared_ptr<PDFTOPDF_PageHandle> new_page(float width,float height);
48 
49   virtual void add_page(std::shared_ptr<PDFTOPDF_PageHandle> page,bool front);
50 
51   virtual void multiply(int copies,bool collate);
52 
53   virtual void autoRotateAll(bool dst_lscape,Rotation normal_landscape);
54   virtual void addCM(const char *defaulticc,const char *outputicc);
55 
56   virtual void setComments(const std::vector<std::string> &comments);
57 
58   virtual void emitFile(FILE *dst,ArgOwnership take=WillStayAlive);
59   virtual void emitFilename(const char *name);
60 
61   virtual bool hasAcroForm();
62  private:
63   void closeFile();
64   void error(const char *fmt,...);
65   void start(int flatten_forms);
66  private:
67   std::unique_ptr<QPDF> pdf;
68   std::vector<QPDFObjectHandle> orig_pages;
69 
70   bool hasCM;
71   std::string extraheader;
72 };
73 
74 #endif
75