Changes

Jump to navigation Jump to search
m
no edit summary
< [[Graphics]] | [[Using_Graphics]] | [[Overlays]] | [[Layers]] | [[Graphical_text_manipulation|Manipulation]] >== Introduction ==__TOC__
[http://source.contextgarden.net/tex/context/base/page-imp.tex mkii page-imp.mkii] and [http://source.contextgarden.net/tex/context/base/page-sel.mkiv page-sel.mkiv] defines some handy macros for handling import of existing PDF documents.
= Insert a PDF page as a figure = To include only insert a specific single page from a PDF document into your text as a figure, you can write
<texcode>
\externalfigure[file.pdf][page=1,width=...]
</texcode>
orBy default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use <texcode>\externalfigure[filename.pdf][interaction=yes]</texcode> = Insert PDF page(s) as full-page figures =
If you simply want to insert the first "n" number of pages from a PDF as full-page figures, use {{cmd|copypages}}. For example, to insert the first 30 pages scaled down to 95%, you can write
<texcode>
\copypages[file.pdf][n=30][scale=950]
</texcode>
Insertion always starts from the first page. Your existing headers, footers, crop marks will be printed on each page.
 
If, in addition, you want to insert blank pages after specified pages use {{cmd|insertpages}}. For example, to insert the first 30 pages of a PDF and add a blank page after the first and the third page, you can write
<texcode>
\insertpages[file.pdf][1,3][n=30,width=18cm]
</texcode>
 
If you do not want to start insertion from page 1 and you want to specify precisely, which pages or page-ranges to insert, then use {{cmd|filterpages}}. For example, to insert pages 1, 3, 4, 5 and 6, you can write
<texcode>
\filterpages[file.pdf][1,3,4:6][width=18cm]
</texcode>
To insert even/odd pages up to page 30.
<texcode>
\filterpages[file.pdf][even][width=18cm] % even/odd
</texcode>
(See also Taco's hack in [[Processing Lists]] for handling ranges of numbers or [http://archive.contextgarden.net/thread/20050704.222033.bbadb15a.en.html this] thread in the mailing list.)
 
= Merge a single PDF page into your document =
 
To insert a single page from a PDF document after the current page as a full page without adding any headers, footers, etc., use this:
 
<texcode>
\startpagefigure[file.pdf][page=1,...]\stoppagefigure
</texcode>
which is equal to
<texcode>
\startTEXpage
\stopTEXpage
</texcode>
Optionally, you can also add some text to the bottom of the PDF page. For more info, see {{cmd|startpagefigure}}. '''Note''' that with the latest CTX standalone beta as of '''2017/05/27''' (mkiv, LuaTeX) the way described seems not to work properly. In the output you might find the first page only, no matter which is equal to<code>page</code> argument (<code>page=2...n</code>) you use.The following workaround might provide useful in that case:
<texcode>
\startpagefigurestartpagemakeup \filterpages[file.pdf][page=1,...n]% n in Natural \stoppagefigurestoppagemakeup
</texcode>
= Page numbering with {{cmd|startpagefigure}} = Experience shows that when you include a page from a PDF file using {{cmd|startpagefigure}}, the page number of your document is not increased. The included PDF page is completely excluded from the page numbering process. This one inserts is annoying if you include a PDF page in the first 30 pages middle of the your document , and adds a blank expect your page numbers to be correct after the first PDF page. One solution is to use the commands {{cmd|insertpages}}, {{cmd|filterpages}}, and {{cmd|copypages}}. They correctly increment the page numbers. But those commands include the PDF pages like additional "layers" on your page, so it means that your headers, footers, crop marks, etc. will be printed on top of or behind the included PDF pages. (Headers and footers will be printed behind, crop marks will be printed on top of the included PDF.) Another solution is to fix the third pagenumber manually after using {{cmd|startpagefigure}}.
Let's say we include 3 pages from a PDF like this:
<texcode>
% Several pages of text here
\startpagefigure[include_this.pdf][page=4]\stoppagefigure
\startpagefigure[include_this.pdf][page=6]\stoppagefigure
\startpagefigure[include_this.pdf][page=11]\stoppagefigure
% Several pages of text here
</texcode>
Notice that {{cmd|startpagefigure}} can include only 1 page at a time. After compiling the above file with ConTeXt, your page numbers will look like this:
<texcode>
\insertpages[file...Page 10Page 11Page 12include_this.pdf page 4include_this.pdf page 6include_this.pdf page 11Page 13Page 14...</texcode>This behavior is also reflected in the command line output of ConTeXt. The value of <code>userpage</code> is the page number which will be printed in your header/footer. Continuing the above example:<texcode>pages > flushing realpage 12, userpage 10pages > flushing realpage 13, userpage 11pages > flushing realpage 14, userpage 12 &lt;include_this.pdf&gt;pages > flushing realpage 15, userpage 13 <-- include_this.pdf page 4pages > flushing realpage 16, userpage 13 <-- include_this.pdf page 6pages > flushing realpage 17, userpage 13 <-- include_this.pdf][1page 11pages > flushing realpage 18,3][n=30userpage 13 <-- First ConTeXt page after PDF pagespages > flushing realpage 19,width=18cm]userpage 14
</texcode>
 If Therefore, you want must "fix" your page number after you finish including PDF pages. You can either set it to insert a couple of pages use thisfixed number by saying:
<texcode>
% Several pages of text here\filterpagesstartpagefigure[fileinclude_this.pdf][1,3,page=4:]\stoppagefigure\startpagefigure[include_this.pdf][page=6]\stoppagefigure\startpagefigure[include_this.pdf][widthpage=18cm11]\stoppagefigure\setcounter [userpage] [16]% Several pages of text here
</texcode>
to insert pages 1Or, 3which is even better, 4, 5 and 6 orincrement the page number by the number of included PDF pages:
<texcode>
% Several pages of text here\startpagefigure[include_this.pdf][page=4]\stoppagefigure\filterpagesstartpagefigure[fileinclude_this.pdf][evenpage=6]\stoppagefigure\startpagefigure[include_this.pdf][widthpage=18cm11]\stoppagefigure\setcounter [userpage] [\pagenumber+3] % even/oddSeveral pages of text here
</texcode>
to insert even/odd pages up to the page 30. (See also Taco's hack in [[Processing Lists]] for handling ranges of numbers or [http://archive.contextgarden.net/thread/20050704.222033.bbadb15a.en.html this] thread in the mailing list.)
Yet another alternative isThis way your command line output will be:
<texcode>
\copypages[filepages > flushing realpage 12, userpage 10pages > flushing realpage 13, userpage 11pages > flushing realpage 14, userpage 12 &lt;include_this.pdf][n=30&gt;pages > flushing realpage 15, userpage 13 <-- include_this.pdf page 4pages > flushing realpage 16, userpage 13 <-- include_this.pdf page 6pages > flushing realpage 17, userpage 13 <-- include_this.pdf page 11pages > flushing realpage 18, userpage 16 <-- First ConTeXt page after PDF pagespages > flushing realpage 19,scale=950]userpage 17
</texcode>
to insert the first 30 pages scaled down to 95%.
=This {{cmd|setcounter}} command was tested and worked correctly with<code>ConTeXt ver: 2013.10.01 20:08 MKIV beta</code>. Other commands like <code>\incrementnumber[page]</code> or <code>\page[+1]</code> or <code>\page[16]</code> did not help to solve this problem correctly. = Printing Slides from a presentation ==
If you want to make a 2*3 matrix from all the slides in the document you can use the following example:
</texcode>
== Slicing the pages ==
The opposite of combining the pages together is to slice them in pieces.
</texcode>
== Adding comments to pages ==
<texcode>
== Reformatting a Single-Sided pdf for Double-Sided Printing ==
Context can be used as a pdf postprocessor.
[[Category:PDF]]
[[Category:Graphics]]

Navigation menu