pdfapp_t *app=new pdfapp_t;
memset(app, 0, sizeof(pdfapp_t));
app->scrw = 640;
app->scrh = 480;
app->resolution = 72;
fz_error error;
fz_stream *file;
fz_obj *obj;
fz_obj *info;
file=fz_open_fd(0);
int fd = _wopen(L"1.pdf", O_BINARY | O_RDONLY, 0666);
if(fd<0)
MessageBox("not exists file");
file=fz_open_fd(fd);
error=pdf_open_xref_with_stream(&app->xref,file,NULL);
if(error)
MessageBox("not exists file");
fz_close(file);
app->outline=pdf_load_outline(app->xref);
info=fz_dict_gets(app->xref->trailer,"info");
if(info)
{
obj=fz_dict_gets(info,"Title");
if(obj)
app->doctitle=pdf_to_utf8(obj);
}
error=pdf_load_page_tree(app->xref);
if(error)
MessageBox("not exists file");
app->pagecount=pdf_count_pages(app->xref);
CString s;
fz_obj *infos=fz_dict_gets(app->xref->trailer,"Info");
if(!infos)
return ;
if ((obj = fz_dict_gets(infos, "ModDate")));
app->cache = fz_new_glyph_cache();
pdf_page *page;
fz_device *mdev;
app->pageno=1;
error=pdf_load_page(&page,app->xref,app->pageno-1);
if(error)
MessageBox("加载pdf失败");
HDC hdc=::GetDC(m_hWnd);
fz_matrix ctm;
fz_bbox bbox1;
fz_pixmap *image=NULL;
double zoomreal=1/100.0;
ctm=viewctm(page, zoomreal, 0);
fz_colorspace *colorspace = fz_device_bgr;
image = fz_new_pixmap_with_rect(colorspace, bbox1);
ConvertPixmapForWindows(image);
int bmpDx = image->w;
int bmpDy = image->h;
int bmpRowSize = ((image->w * 3 + 3) / 4) * 4;
BITMAPINFOHEADER bmih;
bmih.biSize = sizeof(bmih);
bmih.biHeight = -bmpDy;
bmih.biWidth = bmpDx;
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = bmpDy * bmpRowSize;;
bmih.biXPelsPerMeter = bmih.biYPelsPerMeter = 0;
bmih.biClrUsed = bmih.biClrImportant = 0;
unsigned char* bmpData = image->samples;
::StretchDIBits(hdc,
0,0, 100, 100,
0, 0, bmpDx, bmpDy,
bmpData,
(BITMAPINFO *)&bmih ,
DIB_RGB_COLORS,
SRCCOPY);
i want to show pdf on hdc of mfc dialog,but i failed,can you help me!or so,can you tell me some project based on mupdf using mfc