From 17a231f53fb526b8bb8c82f7967facbfd19eecee Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 11 Jun 2017 00:05:30 +0800 Subject: Update how to build native examples. --- docs/examples/example.c | 27 ++++++++++-------- docs/examples/multi-threaded.c | 62 +++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 40 deletions(-) (limited to 'docs') diff --git a/docs/examples/example.c b/docs/examples/example.c index 1bf67635..2cfe2b73 100644 --- a/docs/examples/example.c +++ b/docs/examples/example.c @@ -1,16 +1,19 @@ /* - How to use MuPDF to render a single page and print the result as a PPM to stdout. - - Build the mupdf library using make, then either run 'make examples' or - compile the example manually: - - gcc -Iinclude -o example.exe docs/example.c \ - build/debug/libmupdf.a \ - build/debug/libmupdfthird.a - -lcrypto \ - -lm - - ./example.exe document.pdf 100 0 1 +How to use MuPDF to render a single page and print the result as +a PPM to stdout. + +To build this example in a source tree and render first page at +100% zoom with no rotation, run: +make examples +./build/debug/example document.pdf 1 100 0 > page1.ppm + +To build from installed sources, and render the same document, run: +gcc -I/usr/local/include -o example \ + /usr/local/share/doc/mupdf/examples/example.c \ + /usr/local/lib/libmupdf.a \ + /usr/local/lib/libmupdfthird.a \ + -lm +./example document.pdf 1 100 0 > page1.ppm */ #include diff --git a/docs/examples/multi-threaded.c b/docs/examples/multi-threaded.c index 15fdcba2..d8541983 100644 --- a/docs/examples/multi-threaded.c +++ b/docs/examples/multi-threaded.c @@ -1,31 +1,37 @@ -// Multi-threaded rendering of all pages in a document to PNG images. - -// First look at doc/example.c and make sure you understand it. -// Then read the multi-threading section in doc/overview.txt, -// before coming back here to see an example of multi-threading. - -// This example will create one main thread for reading pages from the -// document, and one thread per page for rendering. After rendering -// the main thread will wait for each rendering thread to complete before -// writing that thread's rendered image to a PNG image. There is -// nothing in MuPDF requiring a rendering thread to only render a -// single page, this is just a design decision taken for this example. - -// Compile a debug build of mupdf, then compile and run this example: -// -// gcc -g -o build/debug/example-mt -Iinclude docs/multi-threaded.c \ -// build/debug/libmupdf.a \ -// build/debug/libmupdfthird.a \ -// -lpthread -lcrypto -lm -// -// build/debug/example-mt /path/to/document.pdf -// -// Caution! As all pages are rendered simultaneously, please choose a -// file with just a few pages to avoid stressing your machine too -// much. Also you may run in to a limitation on the number of threads -// depending on your environment. - -// Include the MuPDF header file, and pthread's header file. +/* +Multi-threaded rendering of all pages in a document to PNG images. + +First look at doc/example.c and make sure you understand it. +Then read the multi-threading section in doc/overview.txt, +before coming back here to see an example of multi-threading. + +This example will create one main thread for reading pages from the +document, and one thread per page for rendering. After rendering +the main thread will wait for each rendering thread to complete before +writing that thread's rendered image to a PNG image. There is +nothing in MuPDF requiring a rendering thread to only render a +single page, this is just a design decision taken for this example. + +To build this example in a source tree and render every page as a +separate PNG, run: +make examples +./build/debug/multi-threaded document.pdf + +To build from installed sources, and render the same document, run: +gcc -I/usr/local/include -o multi-threaded \ + /usr/local/share/doc/mupdf/examples/multi-threaded.c \ + /usr/local/lib/libmupdf.a \ + /usr/local/lib/libmupdfthird.a \ + -lpthread -lm +./multi-threaded document.pdf + +Caution! As all pages are rendered simultaneously, please choose a +file with just a few pages to avoid stressing your machine too +much. Also you may run in to a limitation on the number of threads +depending on your environment. +*/ + +//Include the MuPDF header file, and pthread's header file. #include #include -- cgit v1.2.3