Hallo Hingo,
wenn Du die Umwandlung der PDF (Dein Beitrag Nr. 3) noch nicht oder noch nicht fehlerfrei hinbekommen haben solltest, kannst Du nach dieser Anleitung vorgehen. Ist nicht kompliziert
Das wäre jetzt auch die Antwort auf Deine gestrige PN.
1. MPDF_UDF.au3 (siehe Anhang) in Dein Script-Verzeichnis abspeichern. Das ist nichts weiter als die modifizierte UDF von taietel mit folgender ergänzter Funktion am Ende der UDF.
AutoIt
Func _Iif($fTest, $vTrueVal, $vFalseVal)
If $fTest Then
Return $vTrueVal
Else
Return $vFalseVal
EndIf
EndFunc
2. Führe folgenden Code für Dein Vorhaben aus (siehe Anhang).
AutoIt
#include <Date.au3>
#include <MPDF_UDF.au3>
#include <File.au3>
$file1 = @ScriptDir & "\getmac__.txt"
$file2 = @ScriptDir & "\getmac_.txt"
$getmac =@ScriptDir & "\getmac.txt"
$sF = @ScriptDir & "\getmac.txt"
FileOpen($file1, 2)
FileWrite($file1," BPCS Checkliste "&@CRLF)
FileWrite($file1,"====================================================="&@CRLF)
FileWrite($file1,""&@CRLF)
FileWrite($file1, "Current Date: " & _NowDate()&@CRLF)
FileWrite($file1, "Current Time: " & _NowTime()&@CRLF)
FileWrite($file1, ""&@CRLF)
FileWrite($file1, "********************Computer Data********************"&@CRLF)
FileWrite($file1, ""&@CRLF)
;~ FileWrite($file1, "Serial number:"&@CRLF)
FileClose($file1)
RunWait(@ComSpec & ' /c ' & 'getmac /V > getmac_.txt' & '"', "", @ScriptDir, @SW_HIDE)
FileOpen($getmac, 2)
FileWrite($getmac, FileRead($file1) & @CRLF & FileRead($file2))
FileClose($file2)
FileClose($getmac)
;Einstellungen für die PDF Erstellung
_SetTitle("getmac")
_SetSubject("getmac to pdf")
_SetKeywords("pdf, AutoIt")
_OpenAfter(True);PDF nach erstellung öffnen
_SetUnit($PDF_UNIT_CM)
_SetPaperSize("A4")
_SetZoomMode($PDF_ZOOM_CUSTOM, 90)
_SetOrientation($PDF_ORIENTATION_PORTRAIT)
_SetLayoutMode($PDF_LAYOUT_CONTINOUS)
;initialize the pdf
_InitPDF(@ScriptDir & "\getmac.pdf")
_LoadFontTT("F1", $PDF_FONT_CALIBRI,$PDF_FONT_ITALIC)
_Txt2PDF($sF, "F1")
;write the buffer to disk
_ClosePDFFile()
; #FUNCTION# ====================================================================================================================
; Name ..........: _Txt2PDF
; Description ...: Convert a text file to pdf
; Syntax ........: _Txt2PDF( $sText , $sFontAlias )
; Parameters ....: $sText - file path.
; $sFontAlias - font alias.
; Return values .: None
; Author(s) .....: Mihai Iancu (taietel at yahoo dot com)
; Modified ......:
; Remarks .......: If the string is very long, it will be scaled to paper width
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _Txt2PDF($sFile, $sFontAlias)
Local $hFile = FileOpen($sFile)
Local $sText = FileRead($hFile)
FileClose($hFile)
Local $iUnit = Ceiling(_GetUnit())
Local $iX = 2
Local $iY = Ceiling(_GetPageHeight() / _GetUnit()) - 1.5
Local $iPagina = Ceiling(_GetPageWidth() / $iUnit) - $iX
Local $iWidth = Ceiling($iPagina - $iX);, 1)
Local $lScale
Local $iRanduri = StringSplit($sText & @CRLF & @CRLF & @CRLF & @CRLF, @CRLF, 3)
Local $iHR = 0.5 * Ceiling($iY / (10 * $iUnit))
Local $iPages = Ceiling((UBound($iRanduri)) * $iHR / $iY)
Local $iNrRanduri = Ceiling(UBound($iRanduri) / $iPages-2)
Local $nrp
For $j = 0 To $iPages + 2
$nrp = _BeginPage()
_DrawText(_GetPageWidth()/_GetUnit()-1, 1, $nrp, "F1", 10, $PDF_ALIGN_CENTER)
For $i = 0 To $iNrRanduri - 1
Local $sLength = Round(_GetTextLength($iRanduri[$i + $j * $iNrRanduri], $sFontAlias, 10))
Local $iH = $iY - $iHR * ($i + 1)
Select
Case $iH < 1
_EndPage()
Case $i + $j * $iNrRanduri = UBound($iRanduri) - 1
_EndPage()
Return
Case $sLength > $iWidth - 1
$lScale = Ceiling($iWidth * 100 / $sLength)
_SetTextHorizontalScaling($lScale)
_DrawText($iX, $iH, $iRanduri[$i + $j * $iNrRanduri], $sFontAlias, 10, $PDF_ALIGN_LEFT, 0)
_SetTextHorizontalScaling(100)
Case Else
_DrawText($iX, $iH, $iRanduri[$i + $j * $iNrRanduri], $sFontAlias, 10, $PDF_ALIGN_LEFT, 0)
EndSelect
Next
_EndPage()
Next
EndFunc ;==>_Txt2PDF
FileDelete($file1)
FileDelete($file2)
Alles anzeigen
In deinem RegExp-Pattern ist noch ein Fehler drin...
Das ist nicht mein RegExp-Pattern aber dennoch vielen Dank für das korrigierte Anwendungsbeispiel. ![]()