fpVectorial Page Orientation lazarus / 39-Graphics ---------------------------------------------------------------------- Weitentaaal · 2024-08-19 12:00 Hello, is it possible to set the page oriantation to horizontal instead of vertical ? i tried to figure it out but couldn't. The wiki does say following "Each Page Sequence can have it's own Header and Footer, and it's own Page Setup (size, orientation)" https://wiki.lazarus.freepascal.org/fpvectorial_- _Text_Document_Support#General ---------------------------------------------------------------------- paweld · 2024-08-19 12:28 if width is greater than heigth then is landscape. modified sample from wiki: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} Uses  Classes, SysUtils, fpvectorialpkg, fpvectorial, LCLIntf; Var  Document: TvVectorialDocument;  Page: TvTextPageSequence;  Paragraph: TvParagraph;  BoldTextStyle: TvStyle;  Begin  Document := TvVectorialDocument.Create;  Try    //  Adds the defaut Paragraph Styles    //    StyleTextBody, StyleHeading1,    //    StyleHeading2 & StyleHeading3    Document.AddStandardTextDocumentStyles(vfUnknown);     // Add our own Style    BoldTextStyle := Document.AddStyle();     BoldTextStyle.Kind := vskTextSpan;    BoldTextStyle.Name := 'Bold';    BoldTextStyle.Font.Bold := True;    BoldTextStyle.SetElements := BoldTextStyle.SetElements + [spbfFontBold];     // Create the page A4 portait    Page := Document.AddTextPageSequence;    Page.SetPageFormat(vpA4);   //set page to A4 portait - only A4 size is supported    Page.AddParagraph.AddText('A4 portait');    Paragraph := Page.AddParagraph;    Paragraph.Style := Document.StyleTextBody;     // Add Hello World as two text spans within the same paragraph,    // and make 'World' bold    Paragraph.AddText('Hello ');    Paragraph.AddText('World!').Style := BoldTextStyle;     // Create the page A3 landscpe    Page := Document.AddTextPageSequence;    Page.Width := 420;   //set page to A3 landscape    Page.Height := 297;  //if width is greater than heigth then is landscape    Page.AddParagraph.AddText('A3 Landscape');    Paragraph := Page.AddParagraph;    Paragraph.Style := Document.StyleTextBody;     // Add Hello World as two text spans within the same paragraph,    // and make 'World' bold    Paragraph.AddText('Witaj ');    Paragraph.AddText('Świecie!').Style := BoldTextStyle;     Document.WriteToFile('Hello_World.docx', vfDOCX);    Document.WriteToFile('Hello_World.odt', vfODT);    OpenDocument('Hello_World.docx');  Finally    Document.Free;  End;End. ---------------------------------------------------------------------- Weitentaaal · 2024-08-19 13:22 Quote from: paweld on August 19, 2024, 02:28:54 pmif width is greater than heigth then is landscape. modified sample from wiki: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} Uses  Classes, SysUtils, fpvectorialpkg, fpvectorial, LCLIntf; Var  Document: TvVectorialDocument;  Page: TvTextPageSequence;  Paragraph: TvParagraph;  BoldTextStyle: TvStyle;  Begin  Document := TvVectorialDocument.Create;  Try    //  Adds the defaut Paragraph Styles    //    StyleTextBody, StyleHeading1,    //    StyleHeading2 & StyleHeading3    Document.AddStandardTextDocumentStyles(vfUnknown);     // Add our own Style    BoldTextStyle := Document.AddStyle();     BoldTextStyle.Kind := vskTextSpan;    BoldTextStyle.Name := 'Bold';    BoldTextStyle.Font.Bold := True;    BoldTextStyle.SetElements := BoldTextStyle.SetElements + [spbfFontBold];     // Create the page A4 portait    Page := Document.AddTextPageSequence;    Page.SetPageFormat(vpA4);   //set page to A4 portait - only A4 size is supported    Page.AddParagraph.AddText('A4 portait');    Paragraph := Page.AddParagraph;    Paragraph.Style := Document.StyleTextBody;     // Add Hello World as two text spans within the same paragraph,    // and make 'World' bold    Paragraph.AddText('Hello ');    Paragraph.AddText('World!').Style := BoldTextStyle;     // Create the page A3 landscpe    Page := Document.AddTextPageSequence;    Page.Width := 420;   //set page to A3 landscape    Page.Height := 297;  //if width is greater than heigth then is landscape    Page.AddParagraph.AddText('A3 Landscape');    Paragraph := Page.AddParagraph;    Paragraph.Style := Document.StyleTextBody;     // Add Hello World as two text spans within the same paragraph,    // and make 'World' bold    Paragraph.AddText('Witaj ');    Paragraph.AddText('Świecie!').Style := BoldTextStyle;     Document.WriteToFile('Hello_World.docx', vfDOCX);    Document.WriteToFile('Hello_World.odt', vfODT);    OpenDocument('Hello_World.docx');  Finally    Document.Free;  End;End.   thank you ! ---------------------------------------------------------------------- Weitentaaal · 2024-08-20 07:03 Hey, it works fine with odt Files but i can't get it to work with PDF Files. is it possible to create a Landscape pdf ? ---------------------------------------------------------------------- paweld · 2024-08-20 08:08 And why are you creating a PDF using fpVectorial as there is a dedicated fpPDF module for that.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} uses  Classes, SysUtils, Graphics, fppdf, fpttf, LCLIntf; const  colarr: Array [1..5] of TColor = (clYellow, clAqua, clLime, clRed, clSkyBlue);var  d: TPDFDocument;  s: TPDFSection;  p: TPDFPage;  g: TFPFontCacheList;  f: TFPFontCacheItem;  i, j, pw, ph: Integer;  fname: String;begin  fname := 'fclpdf-test.pdf';  g := TFPFontCacheList.Create;  g.SearchPath.Add('C:\Windows\Fonts\');  g.BuildFontCache;  //doc properties  d := TPDFDocument.Create(nil);  d.Options := [poCompressText, poCompressImages, poUseRawJPEG, poNoEmbeddedFonts, poPageOriginAtTop];  d.Infos.Title := 'sample pdf';  d.Infos.Author := 'me';  d.Infos.Producer := 'lazarus';  d.Infos.ApplicationName := 'test';  d.Infos.CreationDate := Now;  d.StartDocument;  s := d.Sections.AddSection;  f := g.Find('Courier', False, False);  if f <> nil then    d.AddFont(f.FileName, f.FamilyName);  f := g.Find('Arial', False, False);  if f <> nil then    d.AddFont(f.FileName, f.FamilyName);  f := g.Find('Times New Roman', False, False);  if f <> nil then    d.AddFont(f.FileName, f.FamilyName);  //  for j := 1 to 5 do  begin    p := d.Pages.AddPage;    case j of      2: p.PaperType := ptA5;      3: p.PaperType := ptLetter;      5: p.PaperType := ptComm10;      else        p.PaperType := ptA4;    end;    if j mod 2 = 0 then      p.Orientation := ppoLandscape    else      p.Orientation := ppoPortrait;    p.UnitOfMeasure := uomMillimeters;    s.AddPage(p);    pw := trunc(p.Paper.W * 25.4 / 72);    ph := trunc(p.Paper.H * 25.4 / 72);    for i := 10 to ph - 10 do    begin    if (i mod 10 = 0) or (i = ph - 10) then      p.DrawLine(10, i, pw - 10, i, 0.1);    end;    for i := 10 to pw - 10 do    begin      if (i mod 10 = 0) or (i = pw - 10) then      p.DrawLine(i, 10, i, ph - 10, 0.1);    end;    p.SetFont(0, 40);    p.SetColor(clBlack, false);    p.WriteText(20, 20, 'Page ' + IntToStr(j));    p.SetColor(colarr[j], False);    p.DrawRect(100, 100, 50, 50, 1, True, False);    if j = 1 then    begin      p.SetColor(clMaroon, False);      p.SetFont(1, 24);      p.WriteText(10, 50, 'table of contents:');      for i := 2 to 5 do      begin        p.WriteText(10, 50 + (i * 10) - 10, 'Page ' + IntToStr(i));        {$IF FPC_FULLVERSION>30202}p.AddInternalLink(10, 50 + (i * 10) - 10, 30, 8, i - 1){$ENDIF}; //link to page      end;    end    else    begin      p.SetColor(clMaroon, False);      p.SetFont(1, 24);      p.WriteText(10, 50, 'goto page 1');      p.AddInternalLink(10, 50, 30, 8, 0);    end;  end;  d.SaveToFile(fname);  d.Free;  OpenDocument(fname);end.