#ifndef __HGPDFIMPL_HPP__ #define __HGPDFIMPL_HPP__ #include "HGPdf.h" #include "../base/HGDll.h" #include "mupdf/pdf.h" #include "mupdf/fitz.h" #include "pdflib.h" class HGPdfReaderImpl { public: HGPdfReaderImpl(); ~HGPdfReaderImpl(); HGResult Open(const HGChar* fileName); HGResult Close(); HGResult GetPageCount(HGUInt* count); HGResult GetPageInfo(HGUInt page, HGPdfPageInfo* info); HGResult LoadImage(HGUInt page, HGFloat xScale, HGFloat yScale, HGUInt imgType, HGUInt imgOrigin, HGImage* image); private: fz_context* fz_new_context_imp(const fz_alloc_context* alloc, const fz_locks_context* locks, size_t max_store, const char* version); void fz_register_document_handlers(fz_context* ctx); fz_document* fz_open_document(fz_context* ctx, const char* filename); void fz_drop_context(fz_context* ctx); void fz_drop_document(fz_context* ctx, fz_document* doc); int fz_count_pages(fz_context* ctx, fz_document* doc); fz_page* fz_load_page(fz_context* ctx, fz_document* doc, int number); pdf_page* pdf_page_from_fz_page(fz_context* ctx, fz_page* ptr); fz_rect pdf_bound_page(fz_context* ctx, pdf_page* page); void fz_drop_page(fz_context* ctx, fz_page* page); fz_matrix fz_scale(float sx, float sy); fz_pixmap* fz_new_pixmap_from_page_number(fz_context* ctx, fz_document* doc, int number, fz_matrix ctm, fz_colorspace* cs, int alpha); fz_colorspace* fz_device_rgb(fz_context* ctx); int fz_pixmap_width(fz_context* ctx, const fz_pixmap* pix); int fz_pixmap_height(fz_context* ctx, const fz_pixmap* pix); void fz_drop_pixmap(fz_context* ctx, fz_pixmap* pix); fz_jmp_buf* fz_push_try(fz_context* ctx); int fz_do_try(fz_context* ctx); int fz_do_catch(fz_context* ctx); private: HGDll m_dll; fz_context* m_pContext; fz_document* m_pDoc; }; class HGPdfImageWriterImpl { public: HGPdfImageWriterImpl(); ~HGPdfImageWriterImpl(); HGResult Open(const HGChar* fileName); HGResult Close(); HGResult SaveJpegImage(HGImage image, const HGJpegSaveInfo* info); private: PDF* PDF_new(void); void PDF_set_parameter(PDF* p, const char* key, const char* value); int PDF_begin_document(PDF* p, const char* filename, int len, const char* optlist); void PDF_delete(PDF* p); void PDF_end_document(PDF* p, const char* optlist); void PDF_create_pvf(PDF* p, const char* filename, int len, const void* data, size_t size, const char* optlist); int PDF_load_image(PDF* p, const char* imagetype, const char* filename, int len, const char* optlist); void PDF_begin_page_ext(PDF* p, double width, double height, const char* optlist); void PDF_fit_image(PDF* p, int image, double x, double y, const char* optlist); void PDF_end_page_ext(PDF* p, const char* optlist); void PDF_close_image(PDF* p, int image); int PDF_delete_pvf(PDF* p, const char* filename, int len); pdf_jmpbuf* pdf_jbuf(PDF* p); int pdf_catch(PDF* p); private: HGDll m_dll; PDF* m_pPdf; }; #endif /* __HGPDFIMPL_HPP__ */