% ------------------------------------------------------------------------ % @file: test.pdf % % @author: Jens Kallup - % @license: (c) 2022 kallup non-profit software % all rights reserved. % % only for education, and/or test usage. NO WARRANTIES !!! % % @brief shows, how to coding a PDF (Portable Document Format) file % with help of a native text editor like nano or notepad++ % The result shall be a page with a blue box on the bottom of % the PDF file. % ------------------------------------------------------------------------ %PDF-1.7 % ------------------------------------------------------------------------ % object 1: paint a box on the bottom part of the page % ------------------------------------------------------------------------ 1 0 obj << >> stream 0 0 1 RGB % RGB - blue 2 w % border: 2 pixels width 10 10 m % moveTo: x:10 pixels from left; y:10 pixels from bottom up 600 10 l % lineTo: x:600 pixels from left; y:10 pixels from bottom up 600 50 l % lineTo: x:600 pixels from left; y:50 pixels from bottom up 10 50 l % lineTo: x:10 pixels from left; y:50 pixels from bottum up s % ------------------------------------------------------------------------ % normal text at top of pdf page sized in 10 pixel's % ------------------------------------------------------------------------ BT % (B)egin(T)ext /F1 10 Tf % font:1 size: 10pt 1 0 0 rgb % RGB set outstroke, rgb set normal (non-outstroke) % 0.0 .. 1.0 - here 1 is "red" 10 780 TD % text position x:10 pixel form left; y:780 (A stream text normal) Tj % text string ET % (E)nd(T)ext % ------------------------------------------------------------------------ % italic text emulattion through a Textmatrix (Tm) % ------------------------------------------------------------------------ BT /F1 1 Tf % font:1 size: 10pt % ---------------------------------------------------------------- % 1 2 3 4 5 6 % parameter % ---------------------------------------------------------------- 10 0 2 10 10 770 Tm % text matrix: % 1: 10 pixel of size % 2: 0 pixel of start base line % 3: 2 pixel italics to right % 4: 10 scale pixels % 5: 10 x-pixel from left % 6: 770 y-pixel from bottom up 0 0 1 rgb % RGB set outstroke, rgb set normal (non-outstroke) 1 Tr % text rendering "on" (1) - to simulate bold text 1 w % bold with sized 1 pixel in width (A stream text bold) Tj % text string ET % ------------------------------------------------------------------------ % text in outlines % ------------------------------------------------------------------------ BT /F13 48 Tf % font:13 size: 48pt 10 720 Td % text position 1 Tr % 1 - Text rendering "on" (1) 2 w % 2 pixel width outline (HELLO) Tj % stroke the text ET endstream endobj % ------------------------------------------------------------------------ % object 2 (catalog) - object: 3 are the pages % ------------------------------------------------------------------------ 2 0 obj << /Pages 3 0 R >> % ------------------------------------------------------------------------ % object 3 (pages) - 4. obj are the page childs with count of (1) page(s) % ------------------------------------------------------------------------ 3 0 obj << /Kids [4 0 R ] /Count 1 >> endobj % ------------------------------------------------------------------------ % object 4 describe a page % ------------------------------------------------------------------------ 4 0 obj << /Type /Page /Parent 3 0 R /MediaBox [0 0 610 800 ] /Contents 1 0 R >> endobj % ------------------------------------------------------------------------ % cross-table: 0 item is fix, next 4 items (objects) are offsets % ------------------------------------------------------------------------ xref 0 4 0000000000 65535 f 0000000001 00000 n 0000000002 00000 n 0000000004 00000 n 0000000006 00000 n % ------------------------------------------------------------------------ % the size are 4 objects, (root) is object: 2 % ------------------------------------------------------------------------ trailer << /Size 4 /Root 2 0 R >> startxref 344 %%EOF