[ABU] 13-dec-2016 '''tclMuPdf''' is a porting of the MuPdf framework (see at mupdf.org), for fast and high-quality rendering of PDF pages. ***Download *** * [https://sourceforge.net/projects/irrational-numbers/files/tclMuPdf-1.0b1.zip/download] multi-platform binary package (Win 32/64, Linux 32/64, (support for MacOS .. coming soon) (Warning: 36 MB) * [https://sourceforge.net/p/irrational-numbers/code/HEAD/tree/pkgs/tclMuPdf-devkit] tclMuPdf Development-Kit. For developers/maintainers. ***Examples*** %|code|output|% &|$page0 savePNG img0.png -zoom 0.5|[Image tclmupdf-thumb]|& &|$page2 savePNG x2.png -zoom 2.75 -from 50 450 200 700|[Image tclmupdf-particular]|& <> Reference manual ---- '''tclMuPdf 1.0''' ''Tcl meets mupdf'' **SYNOPSIS** package require '''Tcl 8.5''' package require '''mupdf ?1.0?''' * '''mupdf::open''' ''filename'' * ''pdfHandle'' '''npages''' * ''pdfHandle'' '''getpage''' ''n'' * ''pdfHandle'' '''openedpages''' * ''pdfHandle'' '''closeallpages''' * ''pageHandle'' '''size''' * ''pageHandle'' '''docref''' * ''pageHandle'' '''pagenumber''' * ''pageHandle'' '''savePNG''' ''filename'' ?'''-zoom''' ''zoom''? ?'''-from''' ''x0'' ''y0'' ''x1'' ''y1''? * ''pageHandle'' '''saveImage''' ''image'' ?'''-zoom''' ''zoom''? ?'''-from''' ''x0'' ''y0'' ''x1'' ''y1''? ?'''-to''' ''x0'' ''y0''? * '''mupdf::close''' ''handle'' * '''mupdf::isobject''' ''handle'' * '''mupdf::type''' ''handle'' * '''mupdf::documents''' **DESCRIPTION** Package '''mupdf''' integrates the http://mupdf.com%|%MuPdf%|% framework in Tcl. The focus of http://mupdf.com%|%MuPdf%|% is on speed, small code size, and high-quality anti-aliased rendering. The main goal of this integration is to generate images of the pdf pages, in a .png format, or directly in a Tk's photo image type. Thanks to its speed '''mupdf''' can be used for building interactive pdf-viewers with high-quality and real-time zooming. '''mupdf''' is a binary package, distributed in a multi-platform bundle, i.e. it can be used on * Windows 32/64 bit * Linux 32/64 bit * MacOS 64 bit Just an example to get the flavor of how to use '''mupdf''': ====== # open a file and save 1st page as a .png file package require mupdf set pdf [mupdf::open /mydir/sample.pdf] set page [$pdf getpage 0] ;# 0 is the 1st page $page savePNG /mydir/page0.png mupdf::close $pdf ====== **mupdf Commands** '''mupdf''' supports the following commands: '''mupdf::open''' ''filename'': This is the main command: it opens the pdf-file ''filename'' and returns a ''pdfHandle'' to be used in subsequent operations. ''pdfHandle'' '''npages''': return the number of pages. ''pdfHandle'' '''getpage''' ''n'': return a new ''pageHandle'' to be used in subsequent operations. Note that first page is page 0. ''pdfHandle'' '''openedpages''': return a list of all ''pageHandles'' currently opened related to ''pdfHandle'' ''pdfHandle'' '''closeallpages''': close all currently opened pages related to ''pdfHandle'' ''pageHandle'' '''size''': return the physical size of the page as a list of two decimal numbers. Note that page size is expressed in ''points'', i.e. 1/72 inch. ''pageHandle'' '''docref''': return a reference to the related pdf-document as a ''pdfHandle'' ''pageHandle'' '''pagenumber''': return the pagenumber of ''pageHandler'' ''pageHandle'' '''savePNG''' ''filename'' ?'''-zoom''' ''zoom''? ?'''-from''' ''x0'' ''y0'' ''x1'' ''y1''?: render the page in a .png file named ''filename''. With a default '''-zoom''' factor equal to '''1.0''', a page whose size is W x H ''points'' is rendered as a raster image of W x H ''pixels''. If '''-zoom''' is specified, the resulting image size is scaled by a factor of ''zoom''. By default the whole page is rendered; the '''-from''' option, allows you to render only a given rectangler area of the page. ''x0'' ''y0'' are the coords of the top-left corner and ''x1'' ''y1'' are for the bottom-right corner. These coords must be expressed in terms of the physical size of the page, i.e in ''points'' Note that if these coords lies outside of the page, only the ''intersection'' of this area with the page areais rendered. ====== ... set page [$pdf getpage 0] ;# 0 is the 1st page lassign [$page size] dx dy # save just the upper half of the page $page savePNG /mydir/page0.png -zoom 2.25 -from 0 0 $dx [expr $dy/2] mupdf::close $pdf ====== ''pageHandle'' '''saveImage''' ''image'' ?'''-zoom''' ''zoom''? ?'''-from''' ''x0'' ''y0'' ''x1'' ''y1''? ?'''-to''' ''x0'' ''y0''?: render the page in an existing Tk's photo ''image''. The width and/or height of ''image'' are unchanged if the user has set on it an explicit image width or height (with the -width and/or -height configuration options, respectively). About the '''-zoom''' and '''-from''' options, the same rules for the '''savePNG''' apply. Option '''-to''' allows you to place the resulting raster image at the ''x0'' ''y0'' coords of the destination ''image''. By default, is '''-to''' '''0.0''' '''0.0''' '''mupdf::close''' ''handle'': if ''handle'' refers to a ''pageHandle'', close the page. if ''handle'' refers to a ''pdfHandle'', close the pdf and all its opened pages. '''mupdf::isobject''' ''handle'': return 1 if ''handle'' is a valid reference to a pdf or a page. '''mupdf::type''' ''handle'': return '''document''' or '''page''' if ''handle'' is a valid reference, else raise an error. '''mupdf::documents''' : return a list of currently opened ''pdfHandles'' **KEYWORDS** pdf, photo **CATEGORY** pdf parsing and rendering **COPYRIGHT** Copyright (c) 2016, by A.Buratti <> <>Enter Category Here