Jump to content

Create PDF from your application


taietel
 Share

Recommended Posts

i had try but dont go

explain my problem

i did do a big program for do invoice and i wanna use your script for print pdf file

so in one invoice i can put 30 product , but i thinked if i have 120 product ??

i build a script for do this but when arrive to lunch pdf-script create only one pdf file , because i think , the script not save never a pdf .

example after lucnh a script whit one product go correctly and whit your instruction is perfect not open pdf , but if i after open a pdf and close when i close the pdf reader tell me if i want save , why ???

this is a part mod of your script

$z=_GUICtrlListView_GetItemCount($listcorpofatt)

$a=1

if $z> 30 Then

$j=$z/30

$j= Round($j, 0)

$mz=$z/$j

$mz= round($mz,0)

$c=0

do

$dz= $z-$mz

$pz= $z-$dz

$c=$c+1

;set the properties for the pdf

_SetTitle("Demo PDF in AutoIt")

_SetSubject("Demo PDF in AutoIt, without any ActiveX or DLL...")

_SetKeywords("pdf, demo, AutoIt")

_OpenAfter(True);open after generation

_SetUnit($PDF_UNIT_CM)

_SetPaperSize("A4")

_SetZoomMode($PDF_ZOOM_CUSTOM,90)

_SetOrientation($PDF_ORIENTATION_PORTRAIT)

_SetLayoutMode($PDF_LAYOUT_CONTINOUS)

;initialize the pdf

_InitPDF(@ScriptDir & ""&$J&"fattura.pdf")

;=== load resources used in pdf ===

;images:

_LoadResImage("taietel", @ScriptDir & "configImageslogo2.jpg")

_LoadResImage("taietel1", @ScriptDir & "configImageslogobanca.jpg")

_LoadFontTT("_Arial", $PDF_FONT_ARIAL)

_LoadFontTT("_Calibri", $PDF_FONT_TIMES)

_LoadFontTT("_Calibri", $PDF_FONT_CALIBRI)

_LoadFontTT("_Calibri", $PDF_FONT_Calibri)

;=== create objects that are used in multiple pages ===

;create a header on all pages, except the first:

_StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE)

;insert a image already loaded

_InsertImage("taietel", 1, 26, 6, 3)

_InsertImage("taietel1", 12, 25.5, 9, 4)

;change the colour of the text that follows

_SetColourFill(0x323232)

;stretch it a bit, down to 90%

_SetTextHorizontalScaling(90)

;and begin writting some data

_DrawText(7.5, 28.6, "via", "_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 28.2, "Fuchio ", "_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 27.8, "05401211313484", "_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 27.4, "11313135431313", "_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 27, "335696303005710962175","_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 26.6, "www.sito.com","_Calibri", 10, $PDF_ALIGN_LEFT)

_DrawText(7.5, 26.2, "sito@gmail.com","_Calibri", 10, $PDF_ALIGN_LEFT)

;get the scalling back to default value

_SetTextHorizontalScaling(100)

;and colour also

_SetColourFill(0)

;that's the end of our header!

_Draw_Rectangle(7,25.5, 0, 4, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01)

_EndObject()

;start a page

_BeginPage()

;put some graphics, text etc (see the rest)

;_InsertImage("taietel1", 2, 10, 7, 7)

_Draw_Rectangle(1, 21, 8, 4, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; rettangolo di sinistra sede legale

Local $sText = "Sede Legale "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(1.5,24.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.5,23.8, $AnanomeL, "_Calibri", 10, $PDF_ALIGN_LEFT, 0); intestazione

_DrawText(1.5,23, $AnaindirizzoL, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; via

_DrawText(1.5,22.5, $AnacittaL&" - cap: "&$Anacaplegale, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; citta

_DrawText(1.5,22, $AnaProvinciaL&" - "&$AnaNazioneLegale, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; luogo

_Draw_Rectangle(12, 21, 8, 4, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; rettangolo di destra sede operativa

Local $sText = "Sede Operativa "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(12.5,24.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(12.5,23.8, $Nome, "_Calibri", 10, $PDF_ALIGN_LEFT, 0); intestazione

_DrawText(12.5,23, $prodid, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; via

_DrawText(12.5,22.5, $PCList&" - cap: "&$Anacap, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; citta

_DrawText(12.5,22, $PDList&" - "&$Ananazione, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; luogo

_SetColourStroke(0)

_Draw_Rectangle(1,19.8, 19, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01)

_Draw_Rectangle(4,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; tipo documento

Local $sText = "Tipo Documento "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(1.2,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.2,20, " "&$tipodoc, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(6,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; numero documento

Local $sText = "Num. Doc. "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(4.2,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(4.2,20, $numfat, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

;============================================================================ inizio ciclo per la data giusta

Dim $TableName = "fattura"

;===================================== azzeramento varibili

$fatdata = ""

$Stringid = ""

;====================================== fine azzeramento variabili

$SQLInstance = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName)

$SQLCode = "SELECT * FROM fattura WHERE Fat_NumFattura = " & $numfat

$TableContents = _Query($SQLInstance, $SQLCode)

With $TableContents

While Not .EOF

$fatdata &= .Fields("fat_data").value

.MoveNext

WEnd

EndWith

_MySQLEnd($SQLInstance)

$Stringid = StringSplit($fatdata, "/")

$Stringid[3] = StringLeft($Stringid[3], 4)

;============================================================================ fine ciclo per la data giusta

_Draw_Rectangle(9,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; data

Local $sText = "Data Doc. "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(6.2,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(6.2,20, $Stringid[1]&"/"&$Stringid[2]&"/"&$Stringid[3], "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(12,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; partita iva cliente

Local $sText = "Partita IVA. "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(9.3,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(9,20," "&$Anapiva, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(19,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; codice fiscale inizio

Local $sText = "Codice Fiscale "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(12.3,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(12,20, " "&$Anacdf, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(19,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; pagine

Local $sText = "Pag. "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(19.2,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(19,20, " "&$c, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(15.3,19.8, 0, 1, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; pagamento

Local $sText = "Pagamento "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(15.5,20.5, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(15.5,20, $tipopag, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(1,2.8, 19, 16.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; corpo fattura

$pz=0

;$z=_GUICtrlListView_GetItemCount($listcorpofatt)

$H=18.7

do

$Stringid =""

$labid =_GUICtrlListView_GetItemTextString($listcorpofatt,$pz)

$Stringid = StringSplit($labid, "|")

$pz=$pz+1

Local $sText = "Cod. Articolo "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(1.5,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.5,$H, $Stringid[1], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; codice di esempio

Local $sText = "Descrizione "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(4.5,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(4.5,$H, $Stringid[2], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

;_DrawText(4.5,18.2, $Stringid[2], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

Local $sText = "Quant. "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(13.6,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.6,$H, " "&$Stringid[3], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

Local $sText = "Prezzo "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(15,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(15,$H, $Stringid[4], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

Local $sText = "Importo "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(18.3,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(18.3,$H, $Stringid[5], "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

$H=$H-0.5

;MsgBox (0,"",$z)

Until $pz=$mz

Local $sText = "Sconto "

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(16.5,19.2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(16.5,18.7, "", "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ; cod di esempio

_Draw_Rectangle(1,1, 19, 1.5, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; piè pagina

_Draw_Rectangle(16,1, 4, 1.5, $PDF_STYLE_STROKED, 0, 0xdfdfdf, 0.01) ; totale da pagare

Local $sText = "Totale da Pagare"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(16.3,2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

; inizio importo da pagare

_DrawText(16.3,1.2, " 14500.76 €", "_Calibri", 14, $PDF_ALIGN_LEFT, 0)

_DrawText(16.3,1.2, " 14500.76 €", "_Calibri", 14, $PDF_ALIGN_LEFT, 0)

_DrawText(16.3,1.2, " 14500.76 €", "_Calibri", 14, $PDF_ALIGN_LEFT, 0)

_DrawText(16.3,1.2, " 14500.76 €", "_Calibri", 14, $PDF_ALIGN_LEFT, 0)

; fine importo da pagare

_Draw_Rectangle(1,1, 3, 0.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; spese di trsporto

Local $sText = "Spese di Trasporto"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(1.2,1.5, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(4,1, 3, 0.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; spese di imballo

Local $sText = "Spese di Imballo"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(4.2,1.5, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(4.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(4.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(4.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(4.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(7,1, 3, 0.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; spese di invasso

Local $sText = "Spese di Incasso"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(7.2,1.5, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(7.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(7.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(7.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(7.4,1.1, " 14.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(10,1, 3, 0.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; Totale imponibile

Local $sText = "Totale Imponibile"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(10.2,1.5, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(10.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(10.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(10.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(10.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(13,1, 3, 0.8, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; totale imposta

Local $sText = "Totale Imposta"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(13.2,1.5, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(13.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.4,1.1, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(13,1.8, 3, 0.7, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; totale sconti

Local $sText = "Totale Sconto"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(13.2,2.2, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(13.2,1.9, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.2,1.9, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.2,1.9, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(13.2,1.9, " 14000.00 €", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_Draw_Rectangle(10,1.8, 3, 0.7, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) ; iva

Local $sText = "Iva = 21 %"

Local $sLength = Round(_GetTextLength($sText, "_Calibri", 110),1)

_DrawText(11,2, $sText, "_Calibri", 8, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.9, " Contributo CONAI assolto ove dovuto", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.9, " Contributo CONAI assolto ove dovuto", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.9, " Contributo CONAI assolto ove dovuto", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_DrawText(1.4,1.9, " Contributo CONAI assolto ove dovuto", "_Calibri", 10, $PDF_ALIGN_LEFT, 0)

_SetColourFill(0xFF0000)

_EndPage()

_ClosePDFFile()

;_OpenAfter(False)

until $c=$j

;until $c=$j

else

_stampa_inFAtturaVendita_PDF()

EndIf

EndFunc ;==>_stampa_inFAtturaVendita

Link to comment
Share on other sites

faustf,

1.

i had try but dont go

Change True to False in the following function, in your script:

_OpenAfter(True);open after generation

2.

in one invoice i can put 30 product , but i thinked if i have 120 product ??

Yes, you can. If you can put 30 products on one page, than make three pages for all 120.

3.

pdf reader tell me if i want save

This is NOT my problem, it's ADOBE READER that has this "feature" (ask you to save the pdf).
Link to comment
Share on other sites

Do you mean something like this?:

#include "..MPDF_UDF.au3";<<<<<<<<<<<<<<<<<<<<< DON'T FORGET TO CHANGE THE PATH TO THE UDF

;set the properties for the pdf
_SetTitle("Demo PDF in AutoIt")
_SetSubject("Demo PDF in AutoIt, without any ActiveX or DLL...")
_SetKeywords("pdf, demo, AutoIt")
_OpenAfter(True);open after generation
_SetUnit($PDF_UNIT_CM)
_SetPaperSize("A4")
_SetZoomMode($PDF_ZOOM_FULLPAGE)
_SetOrientation($PDF_ORIENTATION_PORTRAIT)
_SetLayoutMode($PDF_LAYOUT_CONTINOUS)

;initialize the pdf
_InitPDF(@ScriptDir & "Example justified paragraph.pdf")

;=== load resources used in pdf ===
;fonts:
_LoadFontTT("_Calibri", $PDF_FONT_CALIBRI)

;=== create objects that are used in multiple pages ===
;create a header on all pages, except the first:

_BeginPage()
_Draw_Rectangle(1.8, 22.5, 16.8, 4, $PDF_STYLE_STROKED, 0.2, 0xcafea0, 0.02)
$sText = "Anna Montes ridiculus, in penatibus, in aliquam enim sagittis pellentesque? Mattis duis et ut nunc sagittis enim "
$sText &= "tortor urna, eros? Scelerisque? Dapibus scelerisque vel rhoncus porttitor! Porttitor ridiculus. In adipiscing augue "
$sText &= "vel pellentesque tortor porta hac tristique turpis placerat scelerisque elementum hac pulvinar mid dolor pellentesque "
$sText &= "lundium mattis nec. Nec sed. Et adipiscing nec nisi elementum natoque! Turpis penatibus est dictumst magnis integer "
$sText &= "scelerisque, sociis, risus scelerisque ultrices auctor porta, enim? Ac montes pellentesque cum enim augue penatibus "
$sText &= "pulvinar? Vel mid, cum habitasse etiam urna? In? Et, natoque! Integer odio egestas! Rhoncus a vut natoque pellentesque "
$sText &= "diam lundium augue in mus. Auctor, dictumst lacus turpis phasellus etiam, proin mauris. Natoque ultricies turpis nisi "
$sText &= "platea parturient? Nunc nascetur est, adipiscing enim turpis Mihai."
_Paragraph($sText, 2, 26, 16.5, "_Calibri", 10, 0)
_EndPage()
;then, finally, write the buffer to disk
_ClosePDFFile()
Link to comment
Share on other sites

hi sorry have another question ,scenario:

i use your script for print , use one button for start script and printing.

when i press another time(the button) the scritp create another pdf but whit 2 page , if i press another time create pdf whit 3 page

what i must reset ???? , exist a temporary file ?? i must destroy ???

thankss

Link to comment
Share on other sites

  • 3 weeks later...

I have found an error with language specific signs.

The german signs ü,ö,ä are not correct in the pdf. The sign ü produce a backspace, ä and ö produces tabs in the pdf.

has someone a solution for this behaviour ?

Link to comment
Share on other sites

hpda, test this example:

#include "MPDF_UDF.au3"

_SetTitle("Demo PDF in AutoIt")
_SetSubject("Demo PDF in AutoIt, without any ActiveX or DLL...")
_SetKeywords("pdf, demo, AutoIt")
_OpenAfter(True)
_SetUnit($PDF_UNIT_CM)
_SetPaperSize("A4")
_SetZoomMode($PDF_ZOOM_CUSTOM, 90)
_SetOrientation($PDF_ORIENTATION_PORTRAIT)
_SetLayoutMode($PDF_LAYOUT_CONTINOUS)

_InitPDF(@ScriptDir & "test.pdf")

_LoadFontTT("_Arial", $PDF_FONT_ARIAL)
_LoadFontTT("_Times", $PDF_FONT_TIMES)
_LoadFontTT("_Calibri", $PDF_FONT_CALIBRI)
_LoadFontTT("_Garamond", $PDF_FONT_GARAMOND)
_LoadFontTT("_Courier", $PDF_FONT_COURIER)

_BeginPage()
_DrawText(2, 26, "Sample letters ü, ö, ä", "_Calibri", 12, $PDF_ALIGN_LEFT, 0)
_DrawText(2, 25, "Sample letters ü, ö, ä", "_Arial", 12, $PDF_ALIGN_LEFT, 0)
_DrawText(2, 24, "Sample letters ü, ö, ä", "_Garamond", 12, $PDF_ALIGN_LEFT, 0)
_DrawText(2, 23, "Sample letters ü, ö, ä", "_Times", 12, $PDF_ALIGN_LEFT, 0)
_DrawText(2, 22, "Sample letters ü, ö, ä", "_Courier", 12, $PDF_ALIGN_LEFT, 0)
_EndPage()

_ClosePDFFile()

In FoxitReader looks ok, but there are differences when it opens with Adobe. I'll take a look.

Link to comment
Share on other sites

Can someone help me ???

When I use : è ò ecc. The text is not displayed correct. The code is:

_DrawText(5.2, 27.6,"Questo è un Test: quanto si utilizza un carattere accentato", "_TimesT", 14, $PDF_ALIGN_LEFT)

Thank you

:rolleyes:

Link to comment
Share on other sites

Efo74, this example displays correctly those characters you have mentioned:

#include "MPDF_UDF.au3"

_SetTitle("Demo PDF in AutoIt")
_SetSubject("Demo PDF in AutoIt, without any ActiveX or DLL...")
_SetKeywords("pdf, demo, AutoIt")
_OpenAfter(True)
_SetUnit($PDF_UNIT_CM)
_SetPaperSize("A4")
_SetZoomMode($PDF_ZOOM_CUSTOM, 90)
_SetOrientation($PDF_ORIENTATION_PORTRAIT)
_SetLayoutMode($PDF_LAYOUT_CONTINOUS)

_InitPDF(@ScriptDir & "test.pdf")

_LoadFontTT("_Times", $PDF_FONT_TIMES)
_LoadFontTT("_Calibri", $PDF_FONT_CALIBRI)
_LoadFontTT("_Garamond", $PDF_FONT_GARAMOND)
_LoadFontTT("_Courier", $PDF_FONT_COURIER)

_BeginPage()
_DrawText(2, 27,"Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Times", 14, $PDF_ALIGN_LEFT)
_DrawText(2, 26, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Calibri", 12, $PDF_ALIGN_LEFT)
_DrawText(2, 25, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Courier", 12, $PDF_ALIGN_LEFT)
_DrawText(2, 24, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Garamond", 12, $PDF_ALIGN_LEFT)
_EndPage()

_ClosePDFFile()
Link to comment
Share on other sites

Here looks ok.

Have you tried standard fonts? Here is a sample code:

#include "MPDF_UDF.au3"
_SetTitle("Demo PDF in AutoIt")
_SetSubject("Demo PDF in AutoIt, without any ActiveX or DLL...")
_SetKeywords("pdf, demo, AutoIt")
_OpenAfter(True)
_SetUnit($PDF_UNIT_CM)
_SetPaperSize("A4")
_SetZoomMode($PDF_ZOOM_CUSTOM, 90)
_SetOrientation($PDF_ORIENTATION_PORTRAIT)
_SetLayoutMode($PDF_LAYOUT_CONTINOUS)
_InitPDF(@ScriptDir & "test.pdf")
_LoadFontStandard("_Helv", $PDF_FONT_STD_HELVETICA)
_LoadFontStandard("_Tim", $PDF_FONT_STD_TIMES)
_LoadFontStandard("_Cour", $PDF_FONT_STD_COURIER)
_BeginPage()
_DrawText(2, 22, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Helv", 12, $PDF_ALIGN_LEFT)
_DrawText(2, 21, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Cour", 12, $PDF_ALIGN_LEFT)
_DrawText(2, 20, "Questo è un Test: quanto si utilizza un carattere accentato. è ò", "_Tim", 12, $PDF_ALIGN_LEFT)
_EndPage()
_ClosePDFFile()
Link to comment
Share on other sites

Ok ...

I must use Standard Font for workaround problem of "è à ò" not printing correct. But now I must use _Paragraph function in my script, but this function not work correct with Standard fonts, because I think _GetTextLength always return 0

so ...

_LoadFontStandard("_Helv", $PDF_FONT_STD_ARIAL)

_Paragraph("test text", 2, 18, 8, "_Helv", 10, 0)

NOT WORK, is there a solution for this problem. Can someone help me ??

:rolleyes:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...