void pdfapp_open(pdfapp_t *app, char *filename, int reload) { pdfapp_open_progressive(app, filename, reload, 0); //stacksmith: try to open the corresponding bookmark file char* bookmark_fname = (char*)malloc(strlen(filename)+4); strcpy(bookmark_fname,filename); strcat(bookmark_fname,".bmk"); FILE* fbm = fopen(bookmark_fname,"r"); if(fbm){ int res = fread(app->marks,sizeof(int),10,fbm); printf("read %d items\n",res); int i; for(i=0;i<10;i++) printf("%d",app->marks[i]); fclose(fbm); } free(bookmark_fname); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { int argc; LPWSTR *wargv = CommandLineToArgvW(GetCommandLineW(), &argc); char **argv; char argv0[256]; MSG msg; int code; fz_context *ctx; int bps = 0; int displayRes = get_system_dpi(); int c; char *layout_css = NULL; ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT); if (!ctx) { fprintf(stderr, "cannot initialise context\n"); exit(1); } pdfapp_init(ctx, &gapp); argv = fz_argv_from_wargv(argc, wargv); while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:b:")) != -1) { switch (c) { case 'C': c = strtol(fz_optarg, NULL, 16); gapp.tint = 1; gapp.tint_r = (c >> 16) & 255; gapp.tint_g = (c >> 8) & 255; gapp.tint_b = (c) & 255; break; case 'p': password = fz_optarg; break; case 'r': displayRes = fz_atoi(fz_optarg); break; case 'A': fz_set_aa_level(ctx, fz_atoi(fz_optarg)); break; case 'W': gapp.layout_w = fz_atoi(fz_optarg); break; case 'H': gapp.layout_h = fz_atoi(fz_optarg); break; case 'S': gapp.layout_em = fz_atoi(fz_optarg); break; case 'b': bps = (fz_optarg && *fz_optarg) ? fz_atoi(fz_optarg) : 4096; break; case 'U': layout_css = fz_optarg; break; default: usage(); } } pdfapp_setresolution(&gapp, displayRes); GetModuleFileNameA(NULL, argv0, sizeof argv0); install_app(argv0); winopen(); if (fz_optind < argc) { strcpy(filename, argv[fz_optind]); } else { if (!winfilename(wbuf, nelem(wbuf))) exit(0); code = WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, filename, sizeof filename, NULL, NULL); if (code == 0) winerror(&gapp, "cannot convert filename to utf-8"); } if (layout_css) { fz_buffer *buf = fz_read_file(ctx, layout_css); fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf)); fz_drop_buffer(ctx, buf); } if (bps) pdfapp_open_progressive(&gapp, filename, 0, bps); else pdfapp_open(&gapp, filename, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } fz_free_argv(argc, argv); do_close(&gapp); return 0; }
void pdfapp_open(pdfapp_t *app, char *filename, int reload) { pdfapp_open_progressive(app, filename, reload, 0); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { int argc; LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); char argv0[256]; MSG msg; int code; fz_context *ctx; int arg; int bps = 0; ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT); if (!ctx) { fprintf(stderr, "cannot initialise context\n"); exit(1); } pdfapp_init(ctx, &gapp); GetModuleFileNameA(NULL, argv0, sizeof argv0); install_app(argv0); winopen(); arg = 1; while (arg < argc) { if (!wcscmp(argv[arg], L"-p")) { if (arg+1 < argc) bps = _wtoi(argv[++arg]); else bps = 4096; } else break; arg++; } if (arg < argc) { wcscpy(wbuf, argv[arg]); } else { if (!winfilename(wbuf, nelem(wbuf))) exit(0); } code = WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, filename, sizeof filename, NULL, NULL); if (code == 0) winerror(&gapp, "cannot convert filename to utf-8"); if (bps) pdfapp_open_progressive(&gapp, filename, 0, bps); else pdfapp_open(&gapp, filename, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } do_close(&gapp); fz_free_context(ctx); return 0; }