Exemplo n.º 1
0
int
xps_load_page(xps_page **pagep, xps_context *ctx, int number)
{
	xps_page *page;
	int code;
	int n = 0;

	for (page = ctx->first_page; page; page = page->next)
	{
		if (n == number)
		{
			if (!page->root)
			{
				code = xps_load_fixed_page(ctx, page);
				if (code)
					return fz_rethrow(code, "cannot load page %d", number + 1);
			}
			*pagep = page;
			return fz_okay;
		}
		n ++;
	}

	return fz_throw("cannot find page %d", number + 1);
}
Exemplo n.º 2
0
xps_page *
xps_load_page(fz_context *ctx, xps_document *doc, int number)
{
	xps_page *page = NULL;
	xps_fixpage *fix;
	fz_xml *root;
	int n = 0;

	fz_var(page);

	for (fix = doc->first_page; fix; fix = fix->next)
	{
		if (n == number)
		{
			root = xps_load_fixed_page(ctx, doc, fix);
			fz_try(ctx)
			{
				page = fz_new_page(ctx, sizeof *page);
				page->super.load_links = (fz_page_load_links_fn *)xps_load_links;
				page->super.bound_page = (fz_page_bound_page_fn *)xps_bound_page;
				page->super.run_page_contents = (fz_page_run_page_contents_fn *)xps_run_page;
				page->super.drop_page_imp = (fz_page_drop_page_imp_fn *)xps_drop_page_imp;

				page->doc = (xps_document*) fz_keep_document(ctx, &doc->super);
				page->fix = fix;
				page->root = root;
			}
			fz_catch(ctx)
			{
				fz_drop_xml(ctx, root);
				fz_rethrow(ctx);
			}
			return page;
		}
		n ++;
	}