123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [Jeff], 保留所有权利;
- /* 模 块 名:;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[Jeff];
- /* 日 期:[3/17/2017];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[Jeff];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #ifndef __PRINTER_DEF__
- #define __PRINTER_DEF__
- #pragma once
- #include "..\..\..\common\Base64\Base64.h"
- #include "..\..\..\common\cJson\cJSON.h"
- #include <string>
- #include <vector>
- using namespace std;
- #ifdef _UNICODE
- typedef wstring TString;
- #else
- typedef string TString;
- #endif
- #include <gdiplus.h>
- using namespace Gdiplus;
- #pragma comment(lib, "gdiplus.lib")
- #define AlignNormal 0 // 正常对齐方式;
- #define AlignHCenter 1 // 水平居中;
- #define AlignVCenter 2 // 垂直居中;
- #define AlignTopRight 4 // 向右上角对齐;
- #define AlignTopLeft 8 // 向左上角对齐;
- #define AlignBottomRight 16 // 向右下角对齐;
- #define AlignBottomLeft 32 // 向左下角对齐;
- #define AlignHVCenter 64 // 向左下角对齐;
- // 打印图元结构;
- typedef struct __PRINTCELL__
- {
- // 图元名称;
- TString strCellName;
- // 图元key名;
- TString strCellKey;
- // 图元边距值;
- INT nCellMargins;
- // 图元打印位置;
- INT top;
- INT left;
- INT right;
- INT bottom;
- // 图元原始位置;
- CRect rcOrg;
- // 图元变化位置;
- CRect rcChg;
- // 是否自动换行;
- BOOL bAutoWraps;
- // 是否已经自动换行;
- BOOL bHasWrapped;
- // 图元top\left\right\bottom边样式:0=透明、1=虚线、2=实线;
- INT nTopLineType;
- INT nLeftLineType;
- INT nRightLineType;
- INT nBottomLineType;
- // 图元边线宽;
- INT nLineWide;
- // 图元填充内容:0=文本,1=图片;
- INT nFillerType;
- // 文本内容;
- TString strTextContent;
- // 文本的字体名;
- TString strTextFontName;
- // 文本的字体大小(号);
- INT nTextFontSize;
- // 文本颜色;
- COLORREF clrText;
- // 文本对齐方式:0 = 默认左对齐, 1 = 居中对齐,2 =右对齐;
- INT nTextAlignType;
- // 文本行间距;
- INT nLineSpacing;
- // 文本是否粗体;
- BOOL bTextBold;
- // 文本是否斜体;
- BOOL bTextItalic;
- // 如果文本在图元区域内不能一行显示完全,则需要换行;
- vector<TString> vtSubText;
- // 图片描述;
- TString strImgName;
- // 图片内容,由文件流转成Base64的字符串;
- TString strImgContent;
- // 图元是否在换页时,只画了一部分区域边框;
- BOOL bDrawHalf;
- // 是否被上下衔接过;
- BOOL bTypesetting;
- __PRINTCELL__()
- {
- strCellName = _T("");
- strCellKey = _T("");
- nCellMargins = 0;
- top = 0;
- left = 0;
- right = 0;
- bottom = 0;
- rcOrg.SetRect(0, 0, 0, 0);
- rcChg.SetRect(0, 0, 0, 0);
- bAutoWraps = FALSE;
- bHasWrapped = FALSE;
- nTopLineType = 0;
- nBottomLineType = 0;
- nLeftLineType = 0;
- nRightLineType = 0;
- nLineWide = 0;
- nFillerType = 0;
- strTextContent = _T("");
- strTextFontName = _T("");
- nTextFontSize = 0;
- clrText = 0;
- nTextAlignType = 0;
- nLineSpacing = 0;
- bTextBold = FALSE;
- bTextItalic = FALSE;
- strImgName = _T("");
- strImgContent = _T("");
- bDrawHalf = FALSE;
- bTypesetting = FALSE;
- }
- }STPrintCell, *pSTPrintCell;
- typedef struct __KEY_VALUE__
- {
- TString strName;
- TString strKey;
- TString strTextValue;
- TString strImgValue;
- }KeyValue, *pKeyValue;
- // 打印列表;
- typedef struct __PRINTLIST__
- {
- CRect rcPage; // rcPage.bottom是换行或换页的坐标y值;
- BOOL bShowFrame;
- INT nLineWide;
- TString strPrinterName;
- vector<STPrintCell> vtPrintCell;
- }PrintList, *pPrintList;
- extern BOOL GIsHalfHZ(const CStringA &str);
- extern BOOL IsHalfChineseWord(IN LPCCH lpText);
- // 加载模板;
- extern BOOL LoadTemplateFromJson(IN PrintList &printlist, IN TString strTemplateJson);
- extern BOOL LoadTemplateFromFile(IN PrintList &printlist, IN TString strTemplateFile);
- // 加载键值;
- extern BOOL LoadValuesFromJson(IN PrintList& printlist, IN TString strValuesJson);
- extern BOOL LoadValuesFromFile(IN PrintList& printlist, IN TString strValuesFile);
- // 保存Json;
- extern void SaveJson(IN PrintList &printlist, IN TString strSavePath, IN BOOL bChange = FALSE);
- extern void SaveJson(IN PrintList &printlist, IN TString strSavePath, IN const double lfValues);
- extern void GetImgBufferFromBase64(IN TString strBase64, IN BYTE **pBuffer, IN DWORD& dwBufferLen);
- extern BOOL LoadImgFromBuffer(IN Image** pImg, IN BYTE* pBuffer, IN CONST INT& nBufLen);
- extern int GetEncoderClsid(IN CONST WCHAR* format, OUT CLSID* pClsid);
- extern BOOL SaveImg2newfile(IN Image* pImg, IN CString strNewfile, IN ULONG uQuality);
- extern BOOL SaveImg2newfile(IN Image* pImg, IN TString strNewfile, IN ULONG uQuality);
- #endif//__PRINTER_DEF__
|