HELP with HPDF_Page_TextRect()

252 views
Skip to first unread message

Alexsander Santos

unread,
Feb 10, 2017, 12:44:19 PM2/10/17
to libHaru
Hi.

I am using libHaru in a Lua Script (AutoPlay Media Studio). Everything is ok BUT I cannot use the command HPDF_Page_TextRect().

Ex:

require "hpdf"
local pdf = hpdf.New()
if pdf then
  local page = hpdf.AddPage(pdf)
  hpdf.Page_SetSize(page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT)
  local height = hpdf.Page_GetHeight(page)
  local width = hpdf.Page_GetWidth(page)
 
  --Cabeçalho
  local image = hpdf.LoadPngImageFromFile(pdf,"esquerda.png")
  local image2 = hpdf.LoadPngImageFromFile(pdf,"direita.png")
  hpdf.Page_DrawImage(page,image, 30, height - 100, 138, 50.5)
  hpdf.Page_DrawImage(page,image2, width-30-140.5, height - 100, 140.5, 50,5)
  
  --Identificação
  local font = hpdf.GetFont(pdf, "Times-Bold", "WinAnsiEncoding")
  hpdf.Page_SetFontAndSize(page, font, 12)
  hpdf.Page_BeginText(page)
  hpdf.Page_TextOut(page, 30, height - 250, "Processo:")
  hpdf.Page_TextOut(page, 30, height - 275, "Interessado:")
  hpdf.Page_EndText(page)

This works very well. Now, I will try to add a long text in a rectangle and justify it.

 local ementa = "Esse é um texto muito específico e longo. Sua função é testar a funcionalidade de colocação de um texto justificado dentro de um determindo espaço de página. Vamos ver se funciona. Parece bom!";
  hpdf.Page_TextRect(page,0,0,200,200,HPDF_TALIGN_JUSTIFY,ementa);

hpdf.Page_TextRect does not work.The IDE says that the 7th argument must be 'string' but the 7th argument is the  HPDF_TextAlignment

Anybody helps?

Thanks and sorry about bad English




erro.png

Maurizio la Cecilia

unread,
Feb 10, 2017, 2:29:22 PM2/10/17
to lib...@googlegroups.com
Hi Alexsander,

Il 10/02/2017 17:36, Alexsander Santos ha scritto:
...
 local ementa = "Esse é um texto muito específico e longo. Sua função é testar a funcionalidade de colocação de um texto justificado dentro de um determindo espaço de página. Vamos ver se funciona. Parece bom!";
  hpdf.Page_TextRect(page,0,0,200,200,HPDF_TALIGN_JUSTIFY,ementa);

hpdf.Page_TextRect does not work.The IDE says that the 7th argument must be 'string' but the 7th argument is the  HPDF_TextAlignment

Anybody helps?

Thanks and sorry about bad English


the correct syntax is:

HPDF_Page_TextRect( hPage, nLeft, nTop, nRight, nBottom, cText, nAlign ) -> hStatus

So you just swapped HPDF_TALIGN_JUSTIFY and ementa positions.
Please, try with:

hpdf.Page_TextRect(page,0,0,200,200,ementa,HPDF_TALIGN_JUSTIFY)

Best regards.
--
Maurizio

Alexsander Santos

unread,
Feb 10, 2017, 2:47:54 PM2/10/17
to libHaru
Hi Maurizio

Thank you for your answer. But, this makes the same error, now just saying that the erros is in the 6th argumen (image added)

I think it coud be an error in the version of libhpdf.dll (2.2). I tryed to compile 2.3, but I gave up. I looked for a precompiled last version of libhpdf.dll and hpdf.dll but I could not find.

Do you have another idea?

Thanks
erro2.png
Reply all
Reply to author
Forward
0 new messages