Finish -draw documentation first draft

This commit is contained in:
John Whitington 2023-06-08 15:06:58 +01:00
parent 88b0cdefee
commit b9a0663988
6 changed files with 195 additions and 0 deletions

Binary file not shown.

View File

@ -4504,6 +4504,85 @@ We can draw text in a \textit{text section}, which must start with \texttt{-bt}
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/stext.pdf}}
\bigskip
\noindent We can use \texttt{-text} multiple times, interspersing operators which change the text state, such as font and font size:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -mtrans "10 20" -font-size 72?\\
\noindent\small\verb? -bt -text "Different " -font Times-BoldItalic -text "fonts"?\\
\noindent\small\verb? -font-size 36 -text " and sizes" -et -o out.pdf?\\
\end{framed}
\noindent Here is the result:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/fonts.pdf}}
\bigskip
\noindent We can alter the character space, word space, horizontal scaling (100 = no scaling, <100 shrink, >100 stretch), and text rise:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -mtrans "10 20" -font-size 72?\\
\noindent\small\verb? -bt -textscale 75 -charspace 5 -wordspace 20 -text "Different "?\\
\noindent\small\verb? -font Times-BoldItalic -text "fonts" -font-size 36 -rise 40?\\
\noindent\small\verb? -text " and sizes" -et -o out.pdf?\\
\end{framed}
\noindent Now we see:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/fontparams.pdf}}
\bigskip
\noindent Text may appear on multiple lines. We set up the line spacing with \texttt{-leading} then make new lines with \texttt{-nl}:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -mtrans "100 200" -font-size 50?\\
\noindent\small\verb? -leading 55 -bt -text "This is" -nl -text "on multiple"?\\
\noindent\small\verb? -nl -text "lines" -et -o out.pdf?
\end{framed}
\noindent Now we have:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/lines.pdf}}
\bigskip
\noindent When composing text, we may need to find the width of a piece of text to see where to break it, or for right alignment. We can use \texttt{-textwidth} for this:
\begin{framed}
\noindent\small\verb?cpdf -font Times-Roman -font-size 20 -text-width "Hello"?
\end{framed}
\noindent The result is in points.
We can change the text rendering mode to show outline text or, in this example, to use text as a clipping region:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -rendermode 7 -mtrans "100 200" -font-size 50?\\
\noindent\small\verb? -leading 55 -bt -text "This is" -nl -text "on multiple"?\\
\noindent\small\verb? -nl -text "lines" -et -circle "100 0 100" -fill -o out.pdf?
\end{framed}
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/textclip.pdf}}
\bigskip
\noindent Here are the text rendering modes:
\bigskip
\begin{tabular}{ll}
0 & Fill text (default)\\
1 & Stroke text\\
2 & Fill, then stroke text\\
3 & Neither fill nor stroke (invisible)\\
4 & Fill text and add to path for clipping\\
5 & Stroke text and add to path for clipping\\
6 & Fill, then stroke text and add to path for clipping\\
7 & Add text to path for clipping
\end{tabular}
\bigskip
\section{The next page}
{\small\begin{framed}
@ -4521,6 +4600,7 @@ The drawing operation \texttt{-newpage} creates a fresh page of the same dimensi
\noindent This will create a two page PDF with "Page 1" written on page one and "Page 2" written on page two.
\clearpage\pagestyle{empty}
%We wanted to call this "Chapter M", but the following commands messed up the PDF bookmarks, so this chapter will simply have to float for now, until we can return to this problem.
%\setcounter{chapter}{12}

View File

@ -0,0 +1,40 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Catalog/Pages 5 0 R>>
endobj
2 0 obj
<</Length 96/Filter/FlateDecode>>
stream
x-ÊM
à«Ì²V©ý¸<C3BD>òïa
¤xúž³øf$GB
({b&èTÀe«ÑÓ ­@¾Y÷îv1£¥£3êgÅœX0ð=Uï§êØ⎊ûÆ•^¹pÏ
endstream
endobj
3 0 obj
<</Type/Page/Parent 5 0 R/Resources<</Font<</F1 4 0 R/F2 6 0 R>>>>/MediaBox[0 0 595.2765 841.89105]/Contents[2 0 R]>>
endobj
4 0 obj
<</Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/BaseFont/Times-Roman>>
endobj
5 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
6 0 obj
<</Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/BaseFont/Times-BoldItalic>>
endobj
xref
0 7
0000000000 65535 f
0000000015 00000 n
0000000060 00000 n
0000000223 00000 n
0000000356 00000 n
0000000446 00000 n
0000000497 00000 n
trailer
<</Size 7/Root 1 0 R/ID[<84a6ceb9a015940eeeab0d7b671b2c1f><84a6ceb9a015940eeeab0d7b671b2c1f>]>>
startxref
592
%%EOF

39
manualimages/fonts.pdf Normal file
View File

@ -0,0 +1,39 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Catalog/Pages 5 0 R>>
endobj
2 0 obj
<</Length 81/Filter/FlateDecode>>
stream
x-È1
€0 ЫüQ§6tí rÑ*ÁvòôZ(o{ÿ#<23>GðØ/Ìì"a
`í–¤*<2A>XAϧ¡µÞVra¬ƒÍäôJm¬ü¥Q
endstream
endobj
3 0 obj
<</Type/Page/Parent 5 0 R/Resources<</Font<</F1 4 0 R/F2 6 0 R>>>>/MediaBox[0 0 595.2765 841.89105]/Contents[2 0 R]>>
endobj
4 0 obj
<</Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/BaseFont/Times-Roman>>
endobj
5 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
6 0 obj
<</Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/BaseFont/Times-BoldItalic>>
endobj
xref
0 7
0000000000 65535 f
0000000015 00000 n
0000000060 00000 n
0000000208 00000 n
0000000341 00000 n
0000000431 00000 n
0000000482 00000 n
trailer
<</Size 7/Root 1 0 R/ID[<03010e3b477e40d88f434378e4c3a965><03010e3b477e40d88f434378e4c3a965>]>>
startxref
577
%%EOF

36
manualimages/lines.pdf Normal file
View File

@ -0,0 +1,36 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Page/Parent 5 0 R/Resources<</Font<</F1 3 0 R>>>>/MediaBox[0 0 595.2765 841.89105]/Contents[4 0 R]>>
endobj
2 0 obj
<</Type/Catalog/Pages 5 0 R>>
endobj
3 0 obj
<</Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/BaseFont/Times-Roman>>
endobj
4 0 obj
<</Length 82/Filter/FlateDecode>>
stream
x]Š1
€0¿²¥Úx'äVû‰xD!úƒ<7F>mfF!e
ÁP¾F8.ÙÏ
'àÖp· Ë-°ûñ™ŸpÛ|­%ÿõ_ŒÀ¿
endstream
endobj
5 0 obj
<</Type/Pages/Kids[1 0 R]/Count 1>>
endobj
xref
0 6
0000000000 65535 f
0000000015 00000 n
0000000139 00000 n
0000000184 00000 n
0000000274 00000 n
0000000423 00000 n
trailer
<</Size 6/Root 2 0 R/ID[<cb107da4a52e12de12f7ab883816129d><cb107da4a52e12de12f7ab883816129d>]>>
startxref
474
%%EOF

BIN
manualimages/textclip.pdf Normal file

Binary file not shown.