#ifndef DOC_OUTPUT_H
#define DOC_OUTPUT_H
#include <memory>
#include <vector>
// Messy
#include "hpdf.h"
enum FontType
{
FT_Normal,
FT_Oblique,
FT_Bold,
FT_BoldOblique,
FT_Fixed
};
class DocOutputDevice;
class DocOutputPage
{
public:
DocOutputPage(DocOutputDevice* parent);
~DocOutputPage();
HPDF_Page page(); // TODO: remove need for this
float width();
float height();
float textWidth(const char* str);
bool imageSize(const char* fileName, float& width, float& height);
//void setColor(float, float, float);
void setFontType(FontType font);
void setFontSize(float size);
void setFillColor(unsigned int color);
void setPenColor(unsigned int color);
void setPenWidth(float width);
void setPenStyle(unsigned int style);
void setAlpha(float);
void setAlphaPenFill(float penAlpha, float fillAlpha);
void setGradient(const std::vector<HPDF_GradientStop>& stops, float p1x, float p1y, float p2x, float p2y);
void drawTriangles(float* points, int numPoints, unsigned char* colors, int nc_comps);
void drawText(float x, float y, const char* str);
void drawLine(float x1, float y1, float x2, float y2);
void drawRect(float x1, float y1, float w, float h);
//void drawImage(DocImage& img, float x1, float y1, float w, float h);
void drawImage(const char* fileName, float x1, float y1, float w, float h);
void drawCheckBox(bool checked, float x, float y, float w, float h);
void drawCircle(float x, float y, float radius);
void drawPolygon(float* pnts, int count);
void startLink(const char* uri, float x, float y);
void endLink(float x, float y);
private:
struct Pimpl;
std::unique_ptr<Pimpl> m_pimpl;
};
class DocOutputDevice
{
public:
DocOutputDevice(HPDF_Error_Handler errorFn = 0);
~DocOutputDevice();
HPDF_Doc doc();
void setAuthor(std::string author);
void setTitle(std::string title, std::string subTitle);
void setPassword(std::string password);
HPDF_Image loadImage(const char* fileName, bool& result);
DocOutputPage* newPage();
void finalize(char* outputBuffer, size_t* size);
void finalize(const char* outputFileName);
void reset();
private:
struct Pimpl;
std::unique_ptr<Pimpl> m_pimpl;
};
#endif // DOC_OUTPUT_H