InLine: Insert raw PDF instruction(s)   [ 45 ]

Description

This instruction enables users to add raw PDF instructions to get special effects which are not possible with other FPDF4ZOS primitives.  Examples of such effects: change default word spacing, change default character spacing, change character rendering mode, draw dashed lines, etc. It takes one parameter which is a character string pointer at the raw PDF instruction, or the set of raw PDF instructions, to be inserted.

Developer Notes:

  1. Users are warned to use this function with caution because a small glitch in the string provided may result in an unreadable PDF.  Not to mention that in such cases, pinpointing the error may be a rather difficult task.
  2. Besides, programmers are also remembered that if PDF instructions contains positionning information, it should be given in DPI unit, DPI standing for Dots Per Inch.  For the record, 1 mm = 2.835 DPI. For the record, positionning figures which appear in FPDF4ZOS instructions are usually in mm. If only for that reason, it is NOT recommanded to use that feature when PDF instruction to be inserted involves positioning information.

C calling syntax
void InLine (char *PdfComd)
Cobol calling syntax
CALL "InLine" using by value PDFCOMD.
C sample code
#include   "fpdf.h"

static char   f_ini ??(??) = ??< "ini??/??/demofpdf.ini" ??>;
static char   f_out ??(??) = ??< "pdf??/??/demo_e.pdf" ??>;
static char   buf0 ??(1024??);
static float  points ??(??) =
       ??<105, 160, 145, 190, 145, 240, 115, 240, 115, 215, 95, 215, 95, 240, 65, 240, 65, 190, 104.4, 160.4, -1??>;

/* ----------------------------------------------------------------- */

int  main (int argc, char *argv [])

??<
int   link1, link2;

NewPdfy (f_ini, 1);
AddPage("P");

SetLineWidth (0.3);
Line (20,10,180,10);
InLine ("[3 3] 0 d");
Line (20,18,180,18);
InLine ("[6 6] 0 d");
Line (20,26,180,26);
InLine ("[] 0 d");

SetLineWidth (1);
SetDrawColor (32, 32, 32);
SetFillColor (160, 255, 200);
Sector (50, 80, 40, 0, 60, "DF", true, 90);
SetFillColor (240, 255, 16);
Sector (50, 80, 40, 60, 90, "DF", true, 90);
SetFillColor (64, 64, 255);
Sector (50, 80, 40, 90, 150, "DF", true, 90);
SetFillColor (255, 30, 50);
Sector (50, 80, 40, 150, 260, "DF", true, 90);
SetFillColor (120, 200, 64);
Sector (50, 80, 40, 260, 360, "DF", true, 90);

SetLineWidth (2);
SetDrawColor (128, 32, 32);
SetFillColor (0, 240, 240);
Rect (130, 80, 40, 70, "DF");
Circle (150, 80, 40, "DF");

link1 = AddLink ();
link2 = AddLink ();
SetLink (link1, 0, -1);

SetMargins (40, 10, 40);
SetXY (40, 180);
SetFont ("Arial", "N", 10);
strcpy (buf0, "Lorem ipsum dolor sit amet consectetuer nonummy et convallis parturient et. ");
strcat (buf0, "Volutpat congue Quisque neque Nulla vitae non ut quis Vestibulum wisi. ");
strcat (buf0, "Curabitur et suscipit non Quisque Nam eros non semper convallis Morbi.\n\n");
strcat (buf0, "Lorem ipsum dolor sit amet consectetuer nonummy et convallis parturient et. ");
strcat (buf0, "Volutpat congue Quisque neque Nulla vitae non ut quis Vestibulum wisi. ");
strcat (buf0, "Curabitur et suscipit non Quisque Nam eros non semper convallis Morbi.");
Write (4, buf0, 0);
SetMargins (15, 10, 15);
Ln (20);
SetFont ("Courier", "B", 12);
Write (4, "This is a text carrying no link\n\n\n", 0);
SetHorzScaling (120);
Write (4, "This is an expanded text carrying a link to the top of next page\n\n\n", link2);
SetHorzScaling (50);
Write (4, "This is a shrunken text without any link", 0);
SetHorzScaling (100);


AddPage("P");
SetLink (link2, 0, -1);
SetFont ("Courier", "B", 12);
SetXY (20, 20);
Write (4, "This is a text carrying a link to the top of previous page", link1);
SetFillColor (30, 50, 240);
SetTextColor (64, 64, 64);
Code39 (20, 50, "195454828620151618", 1, 12,  "H", "N");
SetFillColor (240, 30, 50);
i25 (20, 80, "195454828620151618", 1, 12);
SetFillColor (10, 128, 20);
Code39 (150, 140, "195454828620151618", 1, 12,  "V", "P");

SetFillColor (240, 255, 16);
Polygon (points, "DF");

Output (f_out);
??>
Description of sample code
This programs illustrates various functions found in FPDF4ZOS interface.  It opens a PDF context, draws 3 different lines with 3 different dash patterns, thanks to the Inline instructions.
It then draws side by side 
- a circle formed by 5 different sectors each of which exhibit a different fill color,
- a circle above a rectangle with Draw and Fill pattern.

It then writes text in flow mode which takes into account left and right margins as well as LineFeed characters.  The final write also illustrates Various Horizontal scaling which enables to expand or shrink text.
Another page is added which illustrates the usage of the two codebar functions, say Code39 and i25.  Note that two among write calls exhibit an internal link usage.
On the second page, a Polygon is also drawn.

The following functions are used in this piece:
- NewPdfy()         -->  Initialisation of a pdf context
- AddPage()         -->  As it says
- SetLineWidth()    -->  Instruct that PDF is to be protected at user and owner levels
- Line()            -->  Draw a straight line between point P1 [X1,Y1] and point P2 [X2,Y2]
- InLine()          -->  Insert a Raw PDF instruction
- SetDrawColor()    -->  Set the color of lines to be drawn
- SetFillColor()    -->  Set the color of area to be filled
- Rect()            -->  Draw a Rectangle
- Circle()          -->  Draw a Circle
- AddLink()         -->  Allocate an internal link
- SetLink()         -->  Specify destination (page number and Y position) of a previously defined internal link
- SetFont()         -->  Set current font
- SetMargins()      -->  Specify page margins (left, top, right)
- Ln()              -->  Insert a line break, meaning return to left margin while incrementing Y position
- Write()           -->  Write text in flow mode
- SetHorzScaling()  -->  Change default hirizontal scaling when writing text
- SetXY()           -->  Set X and Y current position
- Code39()          -->  Output a Code39 codebar
- i25()             -->  Output a Interleaved I25 codebar
- Polygon()         -->  Draw a Polygon defined as a set of points
- Output()          -->  Output PDF file taking into account all the instructions invoked since context initialization
See sample source code in 'C' as well as PDF execution result  -  NB: For encrypted PDFs, user password is USER-PSWD