Ich müsste für ein kleines Projekt RTF-Dateien in TIFF konvertieren, könnt ihr mir was empfehlen? Ich habe es inzwischen mit ImageMagick versucht, aber ohne Erfolg.
RTF in TIFF konvertieren
-
r0m -
19. Februar 2016 um 12:43 -
Erledigt
-
-
Wie, bzw. wofür möchtest du eine Textdatei (RTF->Rich Text Format) in eine Bilddatei umwandeln (TIFF->Tagged Image File Format)?
Willst du einfach ein Bild mit Text? -
Stell mal einen Download-Link zur Convert.exe und deren Dokumentation ein. Ich teste danach, solche Tools haben ja üblicherweise Aufrufparameter sollte dadurch möglich sein.
-
Zum Hintergrund, ich schreibe mit Autoit eine RTF incl. Barcode (als Font) und möchte nun daraus eine TIFF bauen. JPG geht natürlich auch, das kann ich mit ImageMagick auch problemlos nach TIFF konvertieren.
Ich benutze diese Version:
-
Die Zip-Datei lade ich mir heute abend herunter. Falls dies die Online Doku zu deinem Tool ist läßt es sich aber nicht für deinen Zweck einsetzen. Es konvertiert nur zwischen verschiedenen Imageformaten, RTF ist aber ein Textformat.
-
Scheinbar ist das TIF-Deligate nicht installiert. IM_MOD_RL_RTF_.dll wird dafür benötigt, aber wo findet man es und wie bindet man die Datei ein?
-
Schau dir mal https://www.coolutils.com/Convert-RTF-TIFF an.
-
Funktioniert, ist aber langsam und vor allem kostenpflichtig.
-
Funktioniert, ist aber langsam und vor allem kostenpflichtig.
seltsam wurde bei Tante Google angezeigt bei Suche nach "convert rtf tiff kostenlos Download" und auf dem Downloadknopf auf der Seite steht auch free.
Wie gesagt laut http://www.imagemagick.org/script/convert.php kann es mit deiner convert.exe nicht funktionieren.
-
RTF kann man mit RichEdit direkt rendern:
AutoIt
Alles anzeigen#include <GuiRichEdit.au3> #include <GDIPlus.au3> ;Opt("MustDeclareVars", 1) _GDIPlus_Startup() Global $aBitmap = _RTFtoIMAGE(@ScriptDir & "\Test.rtf") For $i = 1 To $aBitmap[0] _GDIPlus_ImageSaveToFile($aBitmap[$i], @ScriptDir & "\Out_" & StringFormat("%02s", $i) & ".png") _GDIPlus_BitmapDispose($aBitmap[$i]) Next _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\Out_01.png") Func _RTFtoIMAGE($sRTFFile, $fPageW = 210, $fPageH = 297, $fBorderLeft = 31.8, $fBorderTop = 31.8, $fBorderRight = 25.4, $fBorderBottom = 25.4, $fDPI = 300, $iBKColor = 0xFFFFFF) ;by Eukalyptus (autoit.de) Local $hFile = FileOpen($sRTFFile, 512) Local $sRTFString = FileRead($hFile) FileClose($hFile) Local $hGui = GUICreate("RTF->TIFF", 100, 80) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 0, 0, 100, 80, $ES_MULTILINE) GUISetState(@SW_HIDE, $hGui) _GUICtrlRichEdit_SetText($hRichEdit, $sRTFString) _GUICtrlRichEdit_SetBkColor($hRichEdit, BitOR(BitShift(BitAND($iBKColor, 0xFF), -16), BitAND($iBKColor, 0x0000FF00), BitAND(BitShift($iBKColor, 16), 0xFF))) Local $iBMP_W = Ceiling($fPageW / 25.4 * $fDPI) Local $iBMP_H = Ceiling($fPageH / 25.4 * $fDPI) Local $hDC = _WinAPI_GetDC($hRichEdit) Local $hCDC = _WinAPI_CreateCompatibleDC($hDC) Local $tFormat = DllStructCreate("hwnd DC; hwnd DCTarget; int Left; int Top; int Right; int Bottom; int PageLeft; int PageTop; int PageRight; int PageBottom; int Min; int Max;") $tFormat.DC = $hCDC Local $fMM = 1440 / 25.4 $tFormat.Left = $fBorderLeft * $fMM $tFormat.Top = $fBorderTop * $fMM $tFormat.Right = ($fPageW - $fBorderRight) * $fMM $tFormat.Bottom = ($fPageH - $fBorderBottom) * $fMM $tFormat.PageRight = $fPageW * $fMM $tFormat.PageBottom = $fPageH * $fMM Local $iHRes = _WinAPI_GetDeviceCaps($hCDC, 88) Local $iVRes = _WinAPI_GetDeviceCaps($hCDC, 90) _WinAPI_SetMapMode($hCDC, 8) _WinAPI_SetWindowExt($hCDC, $iHRes, $iVRes) DllCall("gdi32.dll", "bool", "SetViewportExtEx", "handle", $hCDC, "int", $fDPI, "int", $fDPI, "struct*", Null) Local $hBMP = _WinAPI_CreateBitmap($iBMP_W, $iBMP_H, 1, 32) Local $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP) Local $hBRSH = _WinAPI_CreateSolidBrush($iBKColor) _SendMessage($hRichEdit, $EM_SETSEL, 0, -1) _SendMessage($hRichEdit, $EM_EXGETSEL, 0, DllStructGetPtr($tFormat, "Min"), 0, "wparam", "struct*") Local $aBitmap[1] Local $iIndex, $iCnt = 0 While $tFormat.Min < $tFormat.Max _WinAPI_FillRect($hCDC, DllStructGetPtr($tFormat, "PageLeft"), $hBRSH) $iIndex = _SendMessage($hRichEdit, $EM_FORMATRANGE, True, $tFormat, 0, "wparam", "struct*", "int") If $iIndex <= $tFormat.Min Then ExitLoop $tFormat.Min = $iIndex $iCnt += 1 ReDim $aBitmap[$iCnt + 1] $aBitmap[$iCnt] = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) DllCall("gdiplus.dll", "int", "GdipBitmapSetResolution", "handle", $aBitmap[$iCnt], "float", $fDPI, "float", $fDPI) WEnd $aBitmap[0] = $iCnt _WinAPI_SelectObject($hCDC, $hOBJ) _WinAPI_DeleteObject($hBMP) _WinAPI_DeleteDC($hCDC) _WinAPI_ReleaseDC($hRichEdit, $hDC) _WinAPI_DeleteObject($hBRSH) _GUICtrlRichEdit_Destroy($hRichEdit) GUIDelete($hGui) Return $aBitmap EndFunc ;==>_RTFtoIMAGE
Die Bilder kannst du dann in dem gewünschten Format abspeichern, welches von GDI+ unterstützt wird (bmp, jpg, png, gif, tif)(Zum Laden einer .rtf Datei sollte man eigentlich _GUICtrlRichEdit_StreamFromFile verwenden, diese Funktion hat aber leider noch einen Bug. (erst ab nächster Stable behoben))
E
-
Danke! Es ist wirklich genial, genau das was ich brauche.
Herzlichen Dank.