Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Create PDF from your application


  • Please log in to reply
232 replies to this topic

#181 rob5zero

rob5zero

    Seeker

  • New Members
  • 3 posts

Posted 14 January 2012 - 09:53 PM

Hello

Sorry for my english.


It is possible to get polish fonts ę ó ł ś ą ż ź ć ń?

Could you tell me how can i do it.









#182 taietel

taietel

    I'm the third from the left...

  • Active Members
  • PipPipPipPipPipPip
  • 723 posts

Posted 16 January 2012 - 10:54 AM

rob5zero, it's possible, but that involves adding more functions to the UDF.

Efo74, if you want to use _Paragraph function with standard fonts, you have to add those fonts also (with their properties), just like __FontTimes, for example.

#183 rob5zero

rob5zero

    Seeker

  • New Members
  • 3 posts

Posted 16 January 2012 - 05:37 PM

rob5zero, it's possible, but that involves adding more functions to the UDF.

Efo74, if you want to use _Paragraph function with standard fonts, you have to add those fonts also (with their properties), just like __FontTimes, for example.




Are you going tointroducethis functionality?
Alternativelyyou can giveinstructionsso I canfix ityourself?

#184 novembrezoulou

novembrezoulou

    Seeker

  • Normal Members
  • 5 posts

Posted 04 February 2012 - 08:46 PM

hi Taietel,
Nice UDF ! but... doesn't accept easyly french letters "é" and "à" when browsing with acrobat. (generates plenty of spaces after le letter...)
The other ones work well...
With foxit, it's better but the next letter is too close to the "é" or the "à".
I tried many times, including some "", "@",... but nothing is changing.
Then I only made a txt file with "aeiuoéèçàùâêîôû" and tried Txt2Pdf... Same problem.
Did you heard about this ?
Many thanks !
Sorry for my english...
NovembreZoulou

Edited by novembrezoulou, 04 February 2012 - 08:46 PM.


#185 novembrezoulou

novembrezoulou

    Seeker

  • Normal Members
  • 5 posts

Posted 05 February 2012 - 02:39 PM

HI...
Another question.. on the same topic
this script :
AutoIt         
#include <GUIConstantsEx.au3> #include <GUIButton.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <ArrayEx.au3> #include <file.au3> #include <String.au3> #include <MPDF_UDF.au3> While 1     $nMsg=MsgBox(4,'Décision','Désirez-vous imprimer une lettre ? '& @crlf & 'Wish to print a letter ?')     While 1         Switch $nMsg             Case 6                 _Edilet()                 ExitLoop             Case 7                 ExitLoop         EndSwitch     WEnd     If $nMsg=7 Then         Exit     EndIf WEnd Func _Edilet()     _SetTitle("Association")     _SetSubject("Convocation")     _SetKeywords("Essai, Trial")     _OpenAfter(True);open after generation     _SetUnit($PDF_UNIT_CM)     _SetPaperSize("A4")     _SetZoomMode($PDF_ZOOM_CUSTOM,90)     _SetOrientation($PDF_ORIENTATION_PORTRAIT)     _SetLayoutMode($PDF_LAYOUT_CONTINOUS)     _InitPDF(@ScriptDir & "lettre.pdf")     ;_LoadFontStandard("_Times", $PDF_FONT_STD_TIMES)     _LoadFontTT("_Arial", $PDF_FONT_ARIAL)     _LoadFontTT("_TimesT", $PDF_FONT_TIMES)     _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI)     _LoadFontTT("_Garamond", $PDF_FONT_GARAMOND)     ;_LoadFontTT("_Symbol", $PDF_FONT_SYMBOL)     ;=== create objects that are used in multiple pages ===     ;create a header on all pages, except the first:     _StartObject("Entete", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE)         ;change the colour of the text that follows         _SetColourFill(0x323232)         ;stretch it a bit, down to 90% ;~         _SetTextHorizontalScaling(100)         ;and begin writting some data         _SetColourFill("0x0000FF"); 0xFF00FF=rose 0x0000FF=bleu         _DrawText(12, 28, "Association Jean Dupont", "_Arial", 24, $PDF_ALIGN_CENTER);StringUpper("Et adipiscing nec nisi elementum natoque!")         _DrawText(12, 27, "Accociation loi 1901", "_Arial", 12, $PDF_ALIGN_CENTER)         _DrawText(12, 25.5, "5, rue Victor HUGO", "_Arial", 14, $PDF_ALIGN_CENTER)         _DrawText(12, 24.5, "98765, La rue du puis", "_Arial", 14, $PDF_ALIGN_CENTER)         _DrawText(12, 23.5, 'Téléphone / Fax / Répondeur : +33-1 23 45 67 89', "_Calibri", 12, $PDF_ALIGN_CENTER)     _EndObject()     ;start a page     _BeginPage() ;~         Empty page...     _EndPage()     _ClosePDFFile() EndFunc  


works fine but, if i print many times before leaving the program, the PDF file contains many pages...
I want to begin an empty page for each call of the function because the future page will be another personnal invoice for another member and have to be send to each by mail...
I think I must empty a buffer... but witch ?
Thank you for your answer

#186 novembrezoulou

novembrezoulou

    Seeker

  • Normal Members
  • 5 posts

Posted 19 February 2012 - 10:14 PM

Hi
Is there any solution to the problem (precedent post) ?
Why pages are adding with the precents ones if i do not leave the program ?
Thanks

#187 rodent1

rodent1

    Wayfarer

  • Active Members
  • Pip
  • 78 posts

Posted 21 February 2012 - 07:57 PM

you need to reset all the values. When you generated your earlier page, you filled several global values in the UDF. Those values are still populated. To do this, I added this short function to the UDF, and I call it every time I start generating a new pdf doc. That resolved that issue for me. I can't tell if all the values I'm resetting are included in the original UDF, so if you have a problem with one of them, just comment it out. Good luck!
The code:
Func _ResetValues() $_PaperSize = "A4" $_Orientation = $PDF_ORIENTATION_PORTRAIT $__SetMargin = 0 $_Pages = 0 $_Offset = 0 $_Font = "" $_sPage=" " $_Image="" $_iObject = 0 $_Buffer = "" $_bOpen = False EndFunc


#188 novembrezoulou

novembrezoulou

    Seeker

  • Normal Members
  • 5 posts

Posted 21 February 2012 - 09:33 PM

Many thanks !!! It works perfect.
No problem, all the values come fron the UDF.

#189 rodent1

rodent1

    Wayfarer

  • Active Members
  • Pip
  • 78 posts

Posted 01 March 2012 - 10:37 PM

NovembreZoulou,
I have seen the problem using French characters and "FontArial" in my calls to _Drawtext. Many spaces are added after each foreign character. As a work around, I have been using "FontCourier" instead in my calls to _DrawText, and I add 2 spaces after each foreign characters. That seems to take care of the issue when I use à, é, è. But it does not work well for some German characters. ü gets lots of extra spaces afterwards. But it works for ö. There are several fonts that are included in the udf, and you may need to do some experimentation with them.

Taietel, do you have any pointers to allow us to create our own font functions?

#190 fifish

fifish

    Seeker

  • New Members
  • 1 posts

Posted 20 March 2012 - 03:47 PM

We have fixed our issue with French characters by slightly modifying the _LoadFontTT() function:

Plain Text         
Func _LoadFontTT($sAlias, $BaseFont, $sOptions = $PDF_FONT_NORMAL) Local $sTemp = "" $_Font = $_Font + 1 $BaseFont = StringReplace($BaseFont, " ", "") Switch $BaseFont   Case "TimesNewRoman"    __FontTimes($sOptions)   Case "CourierNew"    __FontCourier($sOptions)   Case "Symbol"    __FontSymbol($sOptions)   Case "Calibri"    __FontCalibri($sOptions)   Case "Garamond"    __FontGaramond($sOptions)   Case Else    __FontArial($sOptions) EndSwitch Local $i = __InitObj() __ToBuffer("<< /Type/Font/Subtype/TrueType/Name/" & $sAlias & "/BaseFont/" & $BaseFont & $sOptions & "/FirstChar " & $FirstChar & "/LastChar " & $LastChar & "/FontDescriptor " & $i + 1 & " 0 R/Encoding/WinAnsiEncoding/Widths [") For $j = $FirstChar To $FirstChar + $LastChar   If $Widths[$j - $FirstChar] <> 0 Then    $sTemp &= __ToStr($Widths[$j - $FirstChar]) & " "    If Mod($j - $FirstChar + 1, 16) = 0 Or $j = $FirstChar + $LastChar Then     __ToBuffer($sTemp)     $sTemp = ""    EndIf   EndIf Next __ToBuffer("] >>") __EndObj() $_sFONT = $_sFONT & "/" & $sAlias & " " & $i & " 0 R " & @CRLF $_sFONTNAME = $_sFONTNAME & "<" & $sAlias & ">" & StringRight("0000" & $_Font, 4) & ";" ;$i = __InitObj() __ToBuffer("<< /Type/FontDescriptor/FontName/" & $BaseFont & $Param & ">>") __EndObj() EndFunc   ;==>_LoadFontTT


We have modified the following lines (added code in red) :
For $j = $FirstChar To $FirstChar + $LastChar
If $Widths[$j - $FirstChar] <> 0 Then
$sTemp &= __ToStr($Widths[$j - $FirstChar]) & " "
If Mod($j - $FirstChar + 1, 16) = 0 Or $j = $FirstChar + $LastChar Then


Before the modification, we were missing some characters. If someone can test it and confirm our modification, he will be very welcome.

Edited by fifish, 20 March 2012 - 03:59 PM.


#191 labichea

labichea

    Seeker

  • New Members
  • 1 posts

Posted 31 March 2012 - 07:07 AM

Hello

The modification of the code above (_LoadFontTT) is correct . It seems that you detected a bug in MPDF 1.3. All Western accents ( so French accents magically reappear ) are now correctly handled.

Thank you for this update.

Hope that the creator will update his code to MPDF 1.4

#192 adolfito121

adolfito121

    Adventurer

  • Active Members
  • PipPip
  • 106 posts

Posted 05 April 2012 - 10:35 PM

I love this UDF!! But...

is there anyway of getting better image quality when passing from jpg to pdf?
At the moment I got this result:
Posted Image

Notice that the image of the pdf is more pixelated than the original one (original one is a jpg).

Thanks in advance for any help.

#193 taietel

taietel

    I'm the third from the left...

  • Active Members
  • PipPipPipPipPipPip
  • 723 posts

Posted 06 April 2012 - 06:31 AM

Sorry for the (long) delay...
fifish, thanks for finding the bug. I will modify in the next release.
adolfito121, replace _LoadResImage function from the UDF with this one:
AutoIt         
; #FUNCTION# ==================================================================================================================== ; Name ..........: _LoadResImage ; Description ...: Load a image in the pdf (if you use it multiple times it decreases the size of the pdf) ; Syntax ........: _LoadResImage( $sImgAlias , $sImage [, $bInterpolate = True ]) ; Parameters ....: $sImgAlias          -  an alias to identify the image in the pdf (e.g. "Cheese"). ;                 $sImage             -  image path. ;                 $bInterpolate     -  interpolate image . ; Return values .: Success    - "True" ;                 Failure     - "False" ; Author(s) .....: Mihai Iancu (taietel at yahoo dot com) ; Modified ......: ; Remarks .......: Image types accepted: BMP, GIF, TIF, TIFF, PNG, JPG, JPEG (those are tested) ; Related .......: ; Link ..........: [url="http://www.autoitscript.com/forum/topic/118827-create-pdf-from-your-application/"]http://www.autoitscript.com/forum/topic/118827-create-pdf-from-your-application/[/url] ; Example .......: No ; =============================================================================================================================== Func _LoadResImage($sImgAlias, $sImage, $bInterpolate="True")  Local $iW, $iH, $ImgBuf, $hImage, $hImageExt, $newImg, $hClone, $hGraphics, $iObj  If $sImgAlias = "" Then __Error("You don't have an alias for the image", @ScriptLineNumber)  If $sImage = ""  Then   __Error("You don't have any images to insert or the path is invalid",@ScriptLineNumber)  Else   $hImageExt = StringUpper(StringRight($sImage, 3))   $newImg = _TempFile(@ScriptDir, "~", ".jpg")   Switch $hImageExt    Case "BMP", "GIF", "TIF", "TIFF", "PNG", "JPG", "JPEG", "ICO"     _GDIPlus_Startup()     $hImage = _GDIPlus_ImageLoadFromFile($sImage)     $iW = _GDIPlus_ImageGetWidth($hImage)     $iH = _GDIPlus_ImageGetHeight($hImage)     $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iW, $iH, $GDIP_PXF24RGB)     $hGraphics = _GDIPlus_ImageGetGraphicsContext($hClone)     _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)     _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)     _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)     _GDIPlus_ImageSaveToFile($hClone, $newImg)     $ImgBuf = __ToBinary($newImg)     $_iImageW = $iW     $_iImageH = $iH     $iObj = __InitObj()     __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & _     " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8 /Interpolate " & StringLower($bInterpolate) & " /Length " & $iObj + 1 & " 0 R" & ">>")     __ToBuffer("stream" & @CRLF & $ImgBuf & @CRLF & "endstream")     __EndObj()     $_Image &= "/" & $sImgAlias & " " & $iObj & " 0 R " & @CRLF     __InitObj()     __ToBuffer(StringLen($ImgBuf))     __EndObj()     _GDIPlus_ImageDispose($hImage)     _GDIPlus_GraphicsDispose($hGraphics)     _GDIPlus_BitmapDispose($hClone)     _GDIPlus_Shutdown()     FileDelete($newImg)    Case Else     __Error("The image is invalid",@ScriptLineNumber)     Exit   EndSwitch  EndIf  Return $_Image EndFunc   ;==>_LoadResImage


#194 adolfito121

adolfito121

    Adventurer

  • Active Members
  • PipPip
  • 106 posts

Posted 06 April 2012 - 08:22 AM

Thanks for your answer.

It gives me the same image with the new function.

It weird because when I convert a blue logo it gets a good image detail. The only one that gives me problems is that red one ;)

#195 engjcowi

engjcowi

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 06 June 2012 - 12:31 PM

Would anyone be willing to post some examples of what they have done with this? Im interested in creating a report and ive had a brief look at the current examples but was hoping more people woul dbe willing to showcase what they have done and how pls ;)

I have tried to create a simple table to show the software installed on my comp and so far not getting very far. I have 196 rows and its showing up very compressed as it doesnt spread over more than 1 page. If anyone has any examples with tables i would also be very grateful. Below is what i started playing with. I think i need ALOT more practice lol


AutoIt         
  #include "..MPDF_UDF.au3" #include<array.au3> ;set the properties for the pdf _SetTitle("Report") _SetSubject("Report ") _SetKeywords("PDF Report") _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 & "Report.pdf") _LoadResImage("logo", @ScriptDir & "Imageslogo.jpg") _LoadFontTT("_Arial", $PDF_FONT_ARIAL) _LoadFontTT("_TimesT", $PDF_FONT_TIMES) _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI) _LoadFontTT("_Garamond", $PDF_FONT_GARAMOND) ;start a page _BeginPage()  ;put some graphics, text etc (see the rest)  _InsertImage("logo", 2, 10, 7, 7)  _SetColourFill(0xFF0000)  _DrawText(3, 21, "Demo PDF Arial TT", "_Arial", 12, $PDF_ALIGN_LEFT, 0)  _SetColourFill(0xFFFF00)  _SetWordSpacing(50)  _DrawText(3, 20, "Demo PDF Times TT", "_Times", 18, $PDF_ALIGN_LEFT, 0)  _SetWordSpacing(0) _Insert3DPie(4, 18, 2.5, 200, 270, 0x996600)  _SetTextRenderingMode(5)  _InsertRenderedText(9, 23.5, "DEMO pdf", "_Times", 32, 100, $PDF_ALIGN_CENTER, 0xF00000, 0x202020)  _SetTextRenderingMode(0) _EndPage() _BeginPage()  _InsertTable(0, 0,0,15,5,15)  $sTit = "Sample pdf table generated with AutoIt"  _SetTextRenderingMode(5)  _InsertRenderedText((_GetPageWidth()/_GetUnit())/2, _GetPageHeight()/_GetUnit()-1.5, $sTit, "_CalibriB", 32, 100, $PDF_ALIGN_CENTER, 0xbbbbbb, 0x202020)  _SetTextRenderingMode(0) _EndPage() ;write the buffer to disk _ClosePDFFile() Func _InsertTable($iX, $iY, $iW=0, $iH=0, $iCols=0, $iRows=0,$lTxtColor = 0x000000, $lBorderColor = 0xdddddd)  Dim $repserv   _ComputerGetServices($repserv)   _ArrayDisplay($repserv)   Sleep(100)   _ArraySort($repserv, 0, 1)   Sleep(100)   $iRows = 10;$repserv[0][0]  Local $iPgW = Round(_GetPageWidth()/_GetUnit(),1)  Local $iPgH = Round(_GetPageHeight()/_GetUnit(),1)  If $iW = 0 Then $iW = $iPgW - $iX -2  If $iH = 0 Then $iH = $iPgH - $iY -2  _SetColourStroke($lBorderColor)  _Draw_Rectangle($iX, $iY, $iW, $iH, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01)  _SetColourStroke(0)  Local $iColW = $iW/$iCols  Local $iRowH = $iH/$iRows  Local $lRGB  For $i = 0 To $iRows-1   For $j = 0 To $iCols-1    If $i=0 Then     $lRGB = 0xefefef    Else     $lRGB = 0xfefefe    EndIf    _SetColourStroke($lBorderColor)    _Draw_Rectangle($iX+$j*$iColW, $iY+$iH-($i+1)*$iRowH, $iColW, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01)    _SetColourStroke(0)   if $i=0 Then    Local $sText = $repserv[$i][0]&": Col "&$j   Else    Local $sText = "Row "&$i&": Col "&$j   EndIf    Local $sLength = Round(_GetTextLength($sText, "_Calibri", 10),1)    $lScale = Ceiling(0.75*$iColW * 100/ $sLength)    _SetColourFill($lTxtColor)    _SetTextHorizontalScaling($lScale)    _DrawText($iX+$j*$iColW+$iColW/10, $iY+$iH-($i+1)*$iRowH + ($iRowH-10/_GetUnit())/2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0)    _SetTextHorizontalScaling(100)    _SetColourFill(0)   Next  Next EndFunc ;=============================================================================== ; Description:    Returns the services information in an array. ; Parameter(s):  $aServicesInfo - By Reference - Services Information array. ;    $sState - OPTIONAL - Accepted values 'All' or 'Stopped' or ;         'Running' ; Requirement(s):   None ; Return Value(s):  On Success - Returns array of Services Information. ;     $aServicesInfo[0][0]   = Number of Services ;     $aServicesInfo[$i][0]  = Name ($i starts at 1) ;     $aServicesInfo[$i][1]  = Accept Pause ;     $aServicesInfo[$i][2]  = Accept Stop ;     $aServicesInfo[$i][3]  = Check Point ;     $aServicesInfo[$i][4]  = Description ;     $aServicesInfo[$i][5]  = Creation Class Name ;     $aServicesInfo[$i][6]  = Desktop Interact ;     $aServicesInfo[$i][7]  = Display Name ;     $aServicesInfo[$i][8]  = Error Control ;     $aServicesInfo[$i][9]  = Exit Code ;     $aServicesInfo[$i][10] = Path Name ;     $aServicesInfo[$i][11] = Process ID ;     $aServicesInfo[$i][12] = Service Specific Exit Code ;     $aServicesInfo[$i][13] = Service Type ;     $aServicesInfo[$i][14] = Started ;     $aServicesInfo[$i][15] = Start Mode ;     $aServicesInfo[$i][16] = Start Name ;     $aServicesInfo[$i][17] = State ;     $aServicesInfo[$i][18] = Status ;     $aServicesInfo[$i][19] = System Creation Class Name ;     $aServicesInfo[$i][20] = System Name ;     $aServicesInfo[$i][21] = Tag ID ;     $aServicesInfo[$i][22] = Wait Hint ; ;                  On Failure - @error = 1 and Returns 0 ;       @extended = 1 - Array contains no information ;          2 - $colItems isnt an object ; Author(s):        Jarvis Stubblefield (support "at" vortexrevolutions "dot" com) ; Note(s): ;=============================================================================== Func _ComputerGetServices(ByRef $aServicesInfo, $sState = "All")  Local $cI_Compname = @ComputerName, $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20  Local $colItems, $objWMIService, $objItem  Dim $aServicesInfo[1][23], $i = 1  $objWMIService = ObjGet("winmgmts:" & $cI_Compname & "rootCIMV2")  $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)  If IsObj($colItems) Then   For $objItem In $colItems    If $sState <> "All" Then     If $sState = "Stopped" AND $objItem.State <> "Stopped" Then ContinueLoop     If $sState = "Running" AND $objItem.State <> "Running" Then ContinueLoop    EndIf    ReDim $aServicesInfo[UBound($aServicesInfo) + 1][23]    $aServicesInfo[$i][0]  = $objItem.Name    $aServicesInfo[$i][1]  = $objItem.AcceptPause    $aServicesInfo[$i][2]  = $objItem.AcceptStop    $aServicesInfo[$i][3]  = $objItem.CheckPoint    $aServicesInfo[$i][4]  = $objItem.Description    $aServicesInfo[$i][5]  = $objItem.CreationClassName    $aServicesInfo[$i][6]  = $objItem.DesktopInteract    $aServicesInfo[$i][7]  = $objItem.DisplayName    $aServicesInfo[$i][8]  = $objItem.ErrorControl    $aServicesInfo[$i][9]  = $objItem.ExitCode    $aServicesInfo[$i][10] = $objItem.PathName    $aServicesInfo[$i][11] = $objItem.ProcessId    $aServicesInfo[$i][12] = $objItem.ServiceSpecificExitCode    $aServicesInfo[$i][13] = $objItem.ServiceType    $aServicesInfo[$i][14] = $objItem.Started    $aServicesInfo[$i][15] = $objItem.StartMode    $aServicesInfo[$i][16] = $objItem.StartName    $aServicesInfo[$i][17] = $objItem.State    $aServicesInfo[$i][18] = $objItem.Status    $aServicesInfo[$i][19] = $objItem.SystemCreationClassName    $aServicesInfo[$i][20] = $objItem.SystemName    $aServicesInfo[$i][21] = $objItem.TagId    $aServicesInfo[$i][22] = $objItem.WaitHint    $i += 1   Next   $aServicesInfo[0][0] = UBound($aServicesInfo) - 1   If $aServicesInfo[0][0] < 1 Then    SetError(1, 1, 0)   EndIf  Else   SetError(1, 2, 0)  EndIf EndFunc ;_ComputerGetServices    

Drunken Frat-Boy Monkey Garbage

#196 funkey

funkey

    New Dad

  • Active Members
  • PipPipPipPipPipPip
  • 602 posts

Posted 06 June 2012 - 02:09 PM

I played with it a few month ago and made some simple CSV2PDF-Maker.
But I had to handle with quite big csv files, so this AutoIt-UDF was to slow for me and I made a C application with libHaru. But maybe someone can use this to make a more universal tool than it is for now.
And maybe this is useful for you engjcowi.

AutoIt         
#include "MPDF_UDF.au3" ;set the properties for the pdf _SetTitle("CSV2PDF in AutoIt") _SetSubject("CSV2PDF in AutoIt") _SetKeywords("pdf, csv, table, AutoIt") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_CM) _SetPaperSize("CUSTOM", 841.890, 595.276); A4 landscape _SetZoomMode($PDF_ZOOM_FULLPAGE) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) Global $sCSV = FileOpenDialog("Choose CSV File", @ScriptDir, "csv files (*.csv)", 3) If @error Then Exit Global $sPDF = StringTrimRight($sCSV, 3) & "pdf" Global $aCSV = _CSVReadToArray($sCSV, ';') _Array2DTransposeAU3($aCSV) ;initialize the pdf _InitPDF($sPDF) ;=== load used font(s) === ;fonts: Garamond _LoadFontTT("_CalibriB", $PDF_FONT_CALIBRI, $PDF_FONT_BOLD) _LoadFontTT("_CalibriI", $PDF_FONT_CALIBRI, $PDF_FONT_ITALIC) _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI) _InsertTable($aCSV, 30, 1.0, 1.5, 0, 0) _ClosePDFFile() Func _InsertTable($aCSV, $iRows, $iX, $iY, $iW = 0, $iH = 0, $lTitleCol = 0xaaaaaa, $lTxtColor = 0x000000, $lBorderColor = 0x000000)     Local $iCols = UBound($aCSV, 1)     Local $iPages = Ceiling(UBound($aCSV, 2) / $iRows)     Local $iRest = Mod(UBound($aCSV, 2), $iRows), $iSub = 1     Local $iPgW = Round(_GetPageWidth() / _GetUnit(), 1)     Local $iPgH = Round(_GetPageHeight() / _GetUnit(), 1)     If $iW = 0 Then $iW = $iPgW - 2 * $iX     If $iH = 0 Then $iH = $iPgH - 2 * $iY     Local $iColW = $iW / $iCols     Local $iRowH = $iH / $iRows     Local $lRGB     For $k = 0 To $iPages - 1         _BeginPage()         If $k = $iPages - 1 Then $iSub = $iRows - $iRest + 1 ;last page         For $i = 0 + $k * $iRows To ($k + 1) * $iRows - $iSub             For $j = 0 To $iCols - 1                 If $k = 0 Then                     If $i = 0 Then                         $lRGB = $lTitleCol                     Else                         $lRGB = 0xFFFFFF                     EndIf                 Else                     $lRGB = 0xFFFFFF                 EndIf                 _SetColourStroke($lBorderColor)                 _Draw_Rectangle($iX + $j * $iColW, $iY + $iH - ($i - $k * $iRows + 1) * $iRowH, $iColW, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01)                 _SetColourStroke(0)                 Local $sText = $aCSV[$j][$i]                 Local $sLength = Round(_GetTextLength($sText, "_Calibri", 10), 1)                 $lScale = Ceiling(0.75 * $iColW * 100 / $sLength)                 _SetColourFill($lTxtColor) ;~              _SetTextHorizontalScaling(80)                 _DrawText($iX + $j * $iColW + $iColW / 10, $iY + $iH - ($i - $k * $iRows + 1) * $iRowH + ($iRowH - 10 / _GetUnit()) / 2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) ;~              _SetTextHorizontalScaling(50)                 _SetColourFill(0)             Next         Next         _EndPage()     Next EndFunc   ;==>_InsertTable Func _CSVReadToArray($sFile, $sSeparator, $sQuote = '"')     Local $hFile = FileOpen($sFile, 0)     Local $sText = FileRead($hFile)     FileClose($hFile)     Local $aArray     If StringRight($sText, 1) = @LF Then $sText = StringTrimRight($sText, 1)     If StringRight($sText, 1) = @CR Then $sText = StringTrimRight($sText, 1)     If StringInStr($sText, @LF) Then         $aArray = StringSplit(StringStripCR($sText), @LF, 2)     ElseIf StringInStr($sText, @CR) Then ;; @LF does not exist so split on the @CR         $aArray = StringSplit($sText, @CR, 2)     Else ;; unable to split the file         If StringLen($sText) Then             Dim $aArray[1] = [$sText]         Else             Return SetError(2, 0, 0)         EndIf     EndIf     $aArray = _Array1DTo2D($aArray, $sSeparator)     ReDim $aArray[UBound($aArray, 1)][UBound($aArray, 2) - 1]     Return $aArray EndFunc   ;==>_CSVReadToArray Func _Array1DTo2D($a1D, $sDelim = ";", $iSeveral = 0)     ;funkey 17.02.2010     Local $iUbound = UBound($a1D) - 1     Local $iTemp = 0, $iColumn = 0     For $i = 0 To $iUbound         If $iSeveral Then             $iTemp = UBound(StringRegExp($a1D[$i], $sDelim & "+", 3))         Else             $iTemp = UBound(StringSplit($a1D[$i], $sDelim, 3))         EndIf         If $iTemp > $iColumn Then $iColumn = $iTemp     Next     Local $a2D[UBound($a1D)][$iColumn + 1]     Local $aTemp     For $i = 0 To $iUbound         If $iSeveral Then             $aTemp = StringSplit(StringRegExpReplace($a1D[$i], $sDelim & "+", $sDelim), $sDelim, 3)         Else             $aTemp = StringSplit($a1D[$i], $sDelim, 3)         EndIf         For $j = 0 To UBound($aTemp) - 1             $a2D[$i][$j] = $aTemp[$j]         Next     Next     Return SetExtended($iColumn, $a2D) EndFunc   ;==>_Array1DTo2D Func _Array2DTransposeAU3(ByRef $ar_Array)     If IsArray($ar_Array) Then         Local $ar_ExcelValueTrans[UBound($ar_Array, 2)][UBound($ar_Array, 1)] ;ubound($s_i_ExcelValue,2)-1, ubound($s_i_ExcelValue,1)-1)         For $j = 0 To UBound($ar_Array, 2) - 1             For $numb = 0 To UBound($ar_Array, 1) - 1                 $ar_ExcelValueTrans[$j][$numb] = $ar_Array[$numb][$j]             Next         Next         $ar_Array = $ar_ExcelValueTrans     Else         ;MsgBox(0, "", "No Array to transpose")     EndIf EndFunc   ;==>_Array2DTransposeAU3

Programming today is a race between software engineers striving to

build bigger and better idiot-proof programs, and the Universe

trying to produce bigger and better idiots.

So far, the Universe is winning.


#197 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 06 June 2012 - 03:23 PM

I have problems with Czech national characters too as previous posters.
I used fixes mentioned in this topic (in _LoadFontTT and in _ClosePDFFile) and I used also _LoadFontStandard()

_LoadFontStandard("_Cour", $PDF_FONT_STD_COURIER) _DrawText(10, 20, "ěščřžýáíé", "_Cour", 12, $PDF_ALIGN_LEFT)


Wrong result for Czech national characters is on attachment (copy/paste from PDF to Notepad for simple screenshot).

Unfortunately with this bug it¨s unusable for me completely :-(
Taietel tell us how to fix this or how to create our own fonts supporting national characters please.

Here is my fixed UDF

Attached Thumbnails

  • mpdf_czech_font_err.png

Attached Files


Edited by Zedna, 06 June 2012 - 03:49 PM.


#198 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 06 June 2012 - 03:48 PM

@funkey
Thanks for nice example (CSV2PDF) - works fine.

Edited by Zedna, 06 June 2012 - 03:49 PM.


#199 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 07 August 2012 - 11:43 AM

Taietel tell us how to fix this (problems with national characters as previous posters) or how to create our own fonts supporting national characters please.


Bump please.

#200 faustf

faustf

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 261 posts

Posted 13 October 2012 - 10:01 PM

hi guy i have little problem
i so i create simple gui whit one button , this button lunch Example_Mixed.au3 , if i lunch first time print perfect , if i lunch second time create in bottom of file strange rectangle and dont print correct i add strange result

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users