SetHorzScaling: Set Horizontal Scaling [ 71 ]
Description
This function enables Developper to change horizontal scaling of text to be output. This means that text can be either shrunk or expansed by means of this function. By default, horizontal scaling is set to 100 and remains so when this function is not used.
It takes one integer parameter which instructs FPDF4ZOS engine which horizontal scaling factor to apply.
- When a value below 100 is given, text display will be shrunken so that overall width of text output will be a percentage of what it would have been should this function not be called. For example, a value of 50 means that text will be shrunk in such a way that its width will be half of what it would have been.
- When a value above 100 is given, text display will be expanded with the same logic as above.
- If value is lower than 10 or greater than 500, it is somehow considered as an error and the call is ignored.
- Each time a call to AddPage() is issued, current horizontal scaling is automatically cancelled which implies that its value is reset to 100.
C calling syntax
void SetHorzScaling (int value);
Cobol calling syntax
Call "SetHorzScaling" using by value VALUE.
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