Click here to Skip to main content
15,913,388 members

Comments by chp845 (Top 5 by date)

chp845 27-Mar-12 5:16am View    
Thank you! according to the mupdf library,i have idea about pridictor algorithm.I'm trying decompressing the cross-reference stream.
I decompress the stream in zlib,then use predictor algorithm to chang the inflated data.
I wish to do it well.
but only say,it's too painful to see in english as a Chinese.
chp845 16-Mar-12 4:04am View    
i have finished it on hdc,thank you!
chp845 1-Mar-12 23:14pm View    
I have exlpained my proble,can you helpe me
chp845 1-Mar-12 23:13pm View    
Deleted
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();
//unsigned short * ucs;
//ucs = pdf_to_ucs2(obj);
//MessageBox((LPCTSTR)ucs);
//fz_free(ucs);
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);


//bbox1=page->mediabox;
fz_colorspace *colorspace = fz_device_bgr;
image = fz_new_pixmap_with_rect(colorspace, bbox1);
//fz_clear_pixmap_with_color(image, 255);

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,
// destination rectangle
0,0, 100, 100,
// source rectangle
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
chp845 27-Feb-12 21:28pm View    
i know t,quite some time ago,i have using the openssl and CryptoAPI to do a project.but i want to do it in pdf!