taietel Posted August 10, 2011 Author Share Posted August 10, 2011 xavierh, thanks for the info regarding that space! Also I'm glad to have posted your tests. Strange that Adobe Reader X gave no errors, but I will fix this anyway and update the first post. Regards, taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
mesale0077 Posted August 10, 2011 Share Posted August 10, 2011 hi nice but consisting of an extra blank page comes in the form of two pages of a page Link to comment Share on other sites More sharing options...
taietel Posted August 10, 2011 Author Share Posted August 10, 2011 mesale0077, if you are referring to the example txt2pdf, if there are few pages of text there is one extra page at the end, but this is because of the rounding the numbers. You can modify the txt2pdf example to be more acurate. As I wrote in the first post, xavierh discovered that missing space that lead to a bad justification of text in Adobe Reader X, but not in Foxit Reader (this one I use mostly). A confirmation of the fact that small things make the difference. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
WeiHeXie Posted August 11, 2011 Share Posted August 11, 2011 WORD documents can be converted to PDF it? Link to comment Share on other sites More sharing options...
BrewManNH Posted August 11, 2011 Share Posted August 11, 2011 WORD documents can be converted to PDF it?Microsoft has an add on for Word 2007 and up, that will do that from inside the program. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
taietel Posted August 11, 2011 Author Share Posted August 11, 2011 WORD documents can be converted to PDF it?But with this UDF, no. MPDF was intended to be used inside the program to generate various reports, without installing a third-party pdf creator.BrewManNH is right, also for Office 2010. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
happytc Posted August 11, 2011 Share Posted August 11, 2011 But with this UDF, no. MPDF was intended to be used inside the program to generate various reports, without installing a third-party pdf creator.BrewManNH is right, also for Office 2010.taietel, uh, I'm waiting for you fix the bug of Image converting to PDF. Link to comment Share on other sites More sharing options...
taietel Posted August 11, 2011 Author Share Posted August 11, 2011 happytc, I don't really know how I can fix it to work with Chinese/Japanese systems.... Have you tried to run the examples with images on an English system (virtual machine or installed)? I've tested again and on these systems I have no problems. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
taietel Posted August 11, 2011 Author Share Posted August 11, 2011 (edited) hi nice but consisting of an extra blank page comes in the form of two pages of a page Here's a complete rewriten version of Text2PDF example, with explanations: expandcollapse popup#include "..\MPDF_UDF.au3" ;<<<< modify the path to the MPDF_UDF #include <File.au3> #include <Misc.au3> Global $sF = FileOpenDialog("Choose a text file", @ScriptDir & "\", "Text file (*.au3;*.txt;*.ini;*cfg;*.*)", 1) If @error Then MsgBox(4096, "", "No File chosen") Else $iStart = TimerInit() ;set the properties for the pdf _SetTitle("Txt2PDF") _SetSubject("Convert text file to pdf") _SetKeywords("pdf, 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 & "\Txt2Pdf.pdf") _LoadFontTT("F1", $PDF_FONT_CALIBRI, $PDF_FONT_ITALIC) _Txt2PDF($sF, "F1") ;write the buffer to disk _ClosePDFFile() __Test("!Done in "&Round(TimerDiff($iStart)/1000,3)&" sec.") EndIf ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Txt2PDF ; Description ...: Convert a text file to pdf ; Syntax ........: _Txt2PDF( $sText , $sFontAlias , [$iTextHeight=""] ) ; Parameters ....: $sText - file path. ; $sFontAlias - font alias. ; $iTextHeight - font size. ; Return values .: None ; Author(s) .....: Mihai Iancu (taietel at yahoo dot com) ; Modified ......: August 11, 2011 ; Remarks .......: If the string is very long, it will be scaled to paper width ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Txt2PDF($sFile, $sFontAlias, $iTextHeight="") Dim $iTotalRows ;get the rows of the text _FileReadToArray($sFile, $iTotalRows) ;check the text height If $iTextHeight="" Then $iTextHeight = 10 ;get the unit used Local $iUnit = _GetUnit() ;set the left margin of the page Local $iX = 2 ;set the top margin Local $iY = Round(_GetPageHeight() / $iUnit - 2) ;get the canvas width Local $iWidth = Round(_GetPageWidth() / $iUnit - 2 * $iX) ;initialize the scale factor and the counter Local $lScale, $counter = 1 ;set text row height Local $iRowHeight = 0.05 * $iTextHeight ;number of rows per page Local $iRowsPerPage = Floor(($iY -2)/ $iRowHeight) ;get the total pages Local $iTotalPages = Ceiling($iTotalRows[0] / $iRowsPerPage) ;initialize page number Local $iPgNumber For $j = 1 To $iTotalPages ;begin a new page $iPgNumber = _BeginPage() For $i = 1 To _Iif($iRowsPerPage < $iTotalRows[0], $iRowsPerPage, $iTotalRows[0]) ;start the counter If $counter <= $iTotalRows[0] Then ;get the lenght of the current row Local $iRowLength = Round(_GetTextLength($iTotalRows[$counter], $sFontAlias, $iTextHeight)) ;scale it if it is wider than the canvas width If $iRowLength > $iWidth Then $lScale = Ceiling($iWidth * 100 / $iRowLength) _SetTextHorizontalScaling($lScale) _DrawText($iX, $iY - $i * $iRowHeight, $iTotalRows[$counter], $sFontAlias, $iTextHeight, $PDF_ALIGN_LEFT, 0) _SetTextHorizontalScaling(100) Else ;if not, write it as it is _DrawText($iX, $iY - $i * $iRowHeight, $iTotalRows[$counter], $sFontAlias, $iTextHeight, $PDF_ALIGN_LEFT, 0) EndIf $counter += 1 EndIf Next ;write the page number _DrawText(_GetPageWidth() / _GetUnit() - 1, 1, $iPgNumber, "F1", $iTextHeight, $PDF_ALIGN_CENTER) ;and end the page _EndPage() Next EndFunc ;==>_Txt2PDF [EDIT] And here is an example of ListView to PDF: expandcollapse popup#include "..\MPDF_UDF.au3" ;modify the path to MPDF_UDF #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> _LV_Interface() Func _LV_Interface() Local $nMsg Local $hMainGUI = GUICreate("Example ListView2PDF", 600, 400) ;a listview with 10 columns and 30 rows Local $hLV = GUICtrlCreateListView("Col0|Col1|Col2|Col3|Col4|Col5|Col6|Col7|Col8|Col9", 5, 5, 590, 340, -1, $LVS_EX_GRIDLINES) For $i = 1 To 9 _GUICtrlListView_JustifyColumn(GUICtrlGetHandle($hLV), $i, 2) Next Local $hExpPDF = GUICtrlCreateButton("LV2PDF", 400, 360, 100, 30) GUISetState(@SW_SHOW) ;this is just for test Local $aItems[30][10] For $i = 0 To UBound($aItems) - 1 For $j = 0 To 9 $aItems[$i][$j] = Random(100, 1000) Next Next $iTimer = TimerInit() _GUICtrlListView_AddArray($hLV, $aItems) For $i = 0 To 9 _GUICtrlListView_SetColumnWidth($hLV, $i, $LVSCW_AUTOSIZE_USEHEADER) Next While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hExpPDF _LV2PDF($hLV) EndSwitch WEnd EndFunc ;==>_LV_Interface Func _LV2PDF($hLV, $sPDF = "") If $sPDF = "" Then $sPDF = @ScriptDir & "\Example_ListView2PDF.pdf" Local $aArray = _LV2Array($hLV) ;set the properties for the pdf _SetTitle("Demo LV2PDF PDF in AutoIt") _SetSubject("Demo LV2PDF PDF in AutoIt, with formating") _SetKeywords("pdf, demo, table, AutoIt") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_CM) _SetPaperSize("CUSTOM", 842, 595.3); A4 landscape _SetZoomMode($PDF_ZOOM_FULLPAGE) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) ;initialize the pdf _InitPDF($sPDF) ;=== load used font(s) === _LoadFontTT("_CalibriI", $PDF_FONT_CALIBRI, $PDF_FONT_ITALIC) _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI) ;begin page _BeginPage() _InsertLVTable($aArray, 2, 2) ;2cm from the bottom-left, width/height auto $sTitle = "Sample ListView2PDF generated with AutoIt" _SetTextRenderingMode(1) _InsertRenderedText((_GetPageWidth() / _GetUnit()) / 2, _GetPageHeight() / _GetUnit() - 1.5, $sTitle, "_CalibriI", 32, 100, $PDF_ALIGN_CENTER, 0x996600, 0x441100) _SetTextRenderingMode(0) _EndPage() ;write the buffer to disk _ClosePDFFile() EndFunc ;==>_LV2PDF Func _InsertLVTable($aArray, $iX, $iY, $iW = 0, $iH = 0, $lTxtColor = 0x000000, $lBorderColor = 0x888888) 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, $lBorderColor, 0.1) _SetColourStroke(0) $iRows = UBound($aArray) $iCols = UBound($aArray, 2) 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) Local $sText = $aArray[$i][$j] 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 ;==>_InsertLVTable Func _LV2Array($hLV) Local $iRows, $iCols $iRows = _GUICtrlListView_GetItemCount($hLV) $iCols = _GUICtrlListView_GetColumnCount($hLV) Local $aArray[$iRows][$iCols] For $i = 0 To $iRows - 1 Local $aItem = _GUICtrlListView_GetItemTextArray($hLV, $i) For $j = 1 To $aItem[0] $aArray[$i][$j - 1] = $aItem[$j] Next Next Return $aArray EndFunc ;==>_LV2Array Edited August 11, 2011 by taietel telmob 1 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
happytc Posted August 15, 2011 Share Posted August 15, 2011 happytc, I don't really know how I can fix it to work with Chinese/Japanese systems.... Have you tried to run the examples with images on an English system (virtual machine or installed)? I've tested again and on these systems I have no problems.It's very odd that there's no problem of TXT converted to PDF, instead of IMAGE converted to PDF.If the ERROR reason is system language, Of the two possibilities, the former is more likely than the latter. Link to comment Share on other sites More sharing options...
taietel Posted August 15, 2011 Author Share Posted August 15, 2011 (edited) happytc, I've compilled example Image2Pdf as a3x. Please test it and post the results: Example_Image2PDF.zip [EDIT] Modified to output a log file (post this log after the pdf is generated) Edited August 15, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
happytc Posted August 15, 2011 Share Posted August 15, 2011 (edited) happytc, I've compilled example Image2Pdf as a3x. Please test it and post the results: Example_Image2PDF.zip [EDIT] Modified to output a log file (post this log after the pdf is generated) here is the two files: "Used 1012.19K of your 1MB global upload quota (Max. single file size: 11.81K)" ----- so I compressed the two files BTW: how to get more space/quota? Or how to empty all files that I have uploaded for restoring space. could it be that deleted one by one by hand? Edited August 15, 2011 by happytc Link to comment Share on other sites More sharing options...
taietel Posted August 15, 2011 Author Share Posted August 15, 2011 happytc, from the log file it looks like the problem appears when pdf buffer is written to disk from memory. I'll take a look. Regarding deleting attachments: from the profile menu -> settings -> manage attachments you can select/delete them. Or, use full editor to edit the post and on the right side is a delete link. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
happytc Posted August 18, 2011 Share Posted August 18, 2011 (edited) happytc, I've compilled example Image2Pdf as a3x. Please test it and post the results: Example_Image2PDF.zip [EDIT] Modified to output a log file (post this log after the pdf is generated) Tried this EXE Under XP-SP3 of english language and Win7 of english language, generated PDF file all were corrupted. (No virtual machine) I could use following software to create images to PDF http://www.comicer.com/stronghorse/software/exe/FreePic2Pdf_eng.zip Edited August 19, 2011 by happytc Link to comment Share on other sites More sharing options...
xavierh Posted August 19, 2011 Share Posted August 19, 2011 (edited) Taietel, Thanks for this very useful UDF . I have a small possible update. I found that the MPDS_UDF function _Paragraph only works if $iRotate = 0, so I wrote a different version of the same function that would support a 90, 180 or 360 degree rotation. It would be possible to make it work with any angle by using trigonometry functions instead of the switch case section, but that was beyond what I needed, so here is my version of your code: Func _Paragraph($sText, $iX, $iY, $iWidth = 0, $sFontAlias = "", $iFontSize = 12, $iRotate = 0) Local $iLine = 0 Local $iUnit = Round(_GetUnit()) Local $LineSpacing = Round($iFontSize * 1.2 / $iUnit, 2) ;Local $ParagHeight = 0 Local $PageWidth = Round(_GetPageWidth() / $iUnit) If $iWidth = 0 Then $iWidth = Round($PageWidth - 1.75 * $iX, 2) ; valid $iRotate values are 0, 90. 180. 270 degrees. Any other value will be replaced with 0. if $iRotate <> 90 And $iRotate <> 180 Andr $iRotate <> 270 Then $iRotate = 0 _SetColorFill(0) _SetColorStroke(0) _SetTextRenderingMode(0) Local $lScale = 100 Local $sLine = "" Local $ParagWords = StringSplit($sText, " ", 3) For $i = 0 To UBound($ParagWords) - 1 $sLine &= $ParagWords[$i] & " " Local $LineSize = Round(_GetTextLength($sLine, $sFontAlias, $iFontSize) * $iUnit) Switch $LineSize Case 1 To Round($iWidth * $iUnit, 2) If $i = UBound($ParagWords) - 1 Then Switch ($iRotate) case 0 _DrawText($iX, $iY - $iLine * $LineSpacing, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 90 _DrawText($iX + $iLine * $LineSpacing, $iY * 1.07, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 180 _DrawText($iX, $iY + $iLine * $LineSpacing, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 270 _DrawText($iX - ( $iLine + 1 ) * $LineSpacing, $iY, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) EndSwitch EndIf ContinueLoop Case Else $lScale = Round($iWidth * 100 * $iUnit / $LineSize, 1) _SetTextHorizontalScaling($lScale) Switch ($iRotate) case 0 _DrawText($iX, $iY - $iLine * $LineSpacing, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 90 _DrawText($iX + $iLine * $LineSpacing, $iY * 1.07, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 180 _DrawText($iX, $iY + $iLine * $LineSpacing, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) case 270 _DrawText($iX - ( $iLine + 1 ) * $LineSpacing, $iY, $sLine, $sFontAlias, $iFontSize, $PDF_ALIGN_LEFT, $iRotate) EndSwitch _SetTextHorizontalScaling(100) EndSwitch $sLine = "" $iLine += 1 Next EndFunc Edited August 22, 2011 by xavierh Link to comment Share on other sites More sharing options...
bartekd Posted August 25, 2011 Share Posted August 25, 2011 Hello all, Is there a way that I can clear the buffer for this script? What I have is a gui that I have that launches a report based on what I tell it to look for (in the gui). But if I run a report that has 5 pages, it runs fine. But if I run a report that has 4 pages right after, it will leave the 5th page of the last report. Hope I am explaining it right. Let me know if you have any questions. Link to comment Share on other sites More sharing options...
taietel Posted August 26, 2011 Author Share Posted August 26, 2011 @xavierh, with the _Paragraph function from the UDF you can change the angle to let's say 27 degree (see the effect). @bartekd, as I said in the PM, if you don't post a reproducer, it's hard to guess. I already gave you some solutions based strictly on guessing. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
bartekd Posted August 28, 2011 Share Posted August 28, 2011 I have below what my script kindof looks like. Let me know if it is too long, or if something that is there that doesn't make sense. expandcollapse popup#include "MPDF_UDF.au3" #include <array.au3> ;====================================================================1st report Local $SySlogall[10][21] $SySlogall[1][0] = "Aug 28" $SySlogall[1][1] = "08" $SySlogall[1][2] = "28" $SySlogall[1][3] = "2011" $SySlogall[1][4] = "12:12:12" $SySlogall[1][5] = "asdf.asdf.com" $SySlogall[1][6] = "Security" $SySlogall[1][7] = "Security" $SySlogall[1][8] = "Account Management" $SySlogall[1][9] = "test" $SySlogall[1][10] = "630" $SySlogall[1][11] = "User Account Deleted" $SySlogall[1][12] = "test" $SySlogall[1][13] = "domain" $SySlogall[1][14] = "{S-123123123123123}" $SySlogall[1][15] = "creator" $SySlogall[1][16] = "Domain" $SySlogall[1][17] = "" $SySlogall[1][18] = "-" $SySlogall[1][19] = "camp" $SySlogall[1][20] = "Domain" $SySlogall[2][0] = "Aug 28" $SySlogall[2][1] = "08" $SySlogall[2][2] = "28" $SySlogall[2][3] = "2011" $SySlogall[2][4] = "12:12:12" $SySlogall[2][5] = "asdf.asdf.com" $SySlogall[2][6] = "Security" $SySlogall[2][7] = "Security" $SySlogall[2][8] = "Account Management" $SySlogall[2][9] = "test" $SySlogall[2][10] = "630" $SySlogall[2][11] = "User Account Deleted" $SySlogall[2][12] = "test" $SySlogall[2][13] = "domain" $SySlogall[2][14] = "{S-123123123123123}" $SySlogall[2][15] = "creator" $SySlogall[2][16] = "Domain" $SySlogall[2][17] = "" $SySlogall[2][18] = "-" $SySlogall[2][19] = "camp" $SySlogall[2][20] = "Domain" $SySlogall[3][0] = "Aug 28" $SySlogall[3][1] = "08" $SySlogall[3][2] = "28" $SySlogall[3][3] = "2011" $SySlogall[3][4] = "12:12:12" $SySlogall[3][5] = "asdf.asdf.com" $SySlogall[3][6] = "Security" $SySlogall[3][7] = "Security" $SySlogall[3][8] = "Account Management" $SySlogall[3][9] = "test" $SySlogall[3][10] = "630" $SySlogall[3][11] = "User Account Deleted" $SySlogall[3][12] = "test" $SySlogall[3][13] = "domain" $SySlogall[3][14] = "{S-123123123123123}" $SySlogall[3][15] = "creator" $SySlogall[3][16] = "Domain" $SySlogall[3][17] = "" $SySlogall[3][18] = "-" $SySlogall[3][19] = "camp" $SySlogall[3][20] = "Domain" _ArrayDisplay($SySlogall) ;================================================================== Creating the main array that it runs off of Local $SyslogArray[10][10] $SyslogArray[0][0] = "Type" $SyslogArray[0][1] = "Date" $SyslogArray[0][2] = "Time" $SyslogArray[0][3] = "Event" $SyslogArray[0][4] = "Source" $SyslogArray[0][5] = "Domain\User" $SyslogArray[0][6] = "Description" $SyslogArray[0][7] = "Computer" $SyslogArray[0][8] = "Category" ;=================================================================== Array end ;set the properties for the pdf _SetTitle("Gemma Communications Deletion report") _SetSubject("Gemma Deletes") _SetKeywords("Deletes, Report, Gemma, TD, Rogers") _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 & "\Example_mixed.pdf") ;=== load resources used in pdf === ;images: _LoadResImage("GemmaLogo", @ScriptDir & "\Images\Gemma.JPG") ;fonts: ;_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) ;=== create objects that are used in multiple pages === ;create a header on all pages, except the first: _StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE) _InsertImage("GemmaLogo", 0.5, 27, 4, 2) _SetColourFill(0x323232) _SetTextHorizontalScaling(50) _DrawText(5.2, 28.6, StringUpper("Gemma Communications Deletion Report"), "_Garamond", 15, $PDF_ALIGN_LEFT) _DrawText(5.2, 27.9, "Ran on ======> " & @MON & "/" & @MDAY & "/" & @YEAR, "_Garamond", 15, $PDF_ALIGN_LEFT) _SetTextHorizontalScaling(80) _SetTextHorizontalScaling(100) _SetColourFill(0) _EndObject() For $a = 1 to UBound($SySlogall)-1 _BeginPage() ;========================================================================= First deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 21.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 22, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Second deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 16,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 16.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Third deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 10.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 11, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Forth deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 5.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf _EndPage() next ;then, finally, write the buffer to disk _ClosePDFFile() MsgBox(1,"test","Hit ok to run the next report") ;==================================================================== 2nd report Local $SySlogall[10][21] $SySlogall[1][0] = "Aug 28" $SySlogall[1][1] = "08" $SySlogall[1][2] = "28" $SySlogall[1][3] = "2011" $SySlogall[1][4] = "12:12:12" $SySlogall[1][5] = "asdf.asdf.com" $SySlogall[1][6] = "Security" $SySlogall[1][7] = "Security" $SySlogall[1][8] = "Account Management" $SySlogall[1][9] = "test" $SySlogall[1][10] = "630" $SySlogall[1][11] = "User Account Deleted" $SySlogall[1][12] = "test" $SySlogall[1][13] = "domain" $SySlogall[1][14] = "{S-123123123123123}" $SySlogall[1][15] = "creator" $SySlogall[1][16] = "Domain" $SySlogall[1][17] = "" $SySlogall[1][18] = "-" $SySlogall[1][19] = "camp" $SySlogall[1][20] = "Domain" $SySlogall[2][0] = "Aug 28" $SySlogall[2][1] = "08" $SySlogall[2][2] = "28" $SySlogall[2][3] = "2011" $SySlogall[2][4] = "12:12:12" $SySlogall[2][5] = "asdf.asdf.com" $SySlogall[2][6] = "Security" $SySlogall[2][7] = "Security" $SySlogall[2][8] = "Account Management" $SySlogall[2][9] = "test" $SySlogall[2][10] = "630" $SySlogall[2][11] = "User Account Deleted" $SySlogall[2][12] = "test" $SySlogall[2][13] = "domain" $SySlogall[2][14] = "{S-123123123123123}" $SySlogall[2][15] = "creator" $SySlogall[2][16] = "Domain" $SySlogall[2][17] = "" $SySlogall[2][18] = "-" $SySlogall[2][19] = "camp" $SySlogall[2][20] = "Domain" $SySlogall[3][0] = "Aug 28" $SySlogall[3][1] = "08" $SySlogall[3][2] = "28" $SySlogall[3][3] = "2011" $SySlogall[3][4] = "12:12:12" $SySlogall[3][5] = "asdf.asdf.com" $SySlogall[3][6] = "Security" $SySlogall[3][7] = "Security" $SySlogall[3][8] = "Account Management" $SySlogall[3][9] = "test" $SySlogall[3][10] = "630" $SySlogall[3][11] = "User Account Deleted" $SySlogall[3][12] = "test" $SySlogall[3][13] = "domain" $SySlogall[3][14] = "{S-123123123123123}" $SySlogall[3][15] = "creator" $SySlogall[3][16] = "Domain" $SySlogall[3][17] = "" $SySlogall[3][18] = "-" $SySlogall[3][19] = "camp" $SySlogall[3][20] = "Domain" _ArrayDisplay($SySlogall) ;================================================================== Creating the main array that it runs off of Local $SyslogArray[10][10] $SyslogArray[0][0] = "Type" $SyslogArray[0][1] = "Date" $SyslogArray[0][2] = "Time" $SyslogArray[0][3] = "Event" $SyslogArray[0][4] = "Source" $SyslogArray[0][5] = "Domain\User" $SyslogArray[0][6] = "Description" $SyslogArray[0][7] = "Computer" $SyslogArray[0][8] = "Category" ;=================================================================== Array end ;set the properties for the pdf _SetTitle("Gemma Communications Deletion report") _SetSubject("Gemma Deletes") _SetKeywords("Deletes, Report, Gemma, TD, Rogers") _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 & "\Example_mixed.pdf") ;=== load resources used in pdf === ;images: _LoadResImage("GemmaLogo", @ScriptDir & "\Images\Gemma.JPG") ;fonts: ;_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) ;=== create objects that are used in multiple pages === ;create a header on all pages, except the first: _StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE) _InsertImage("GemmaLogo", 0.5, 27, 4, 2) _SetColourFill(0x323232) _SetTextHorizontalScaling(50) _DrawText(5.2, 28.6, StringUpper("Gemma Communications Deletion Report"), "_Garamond", 15, $PDF_ALIGN_LEFT) _DrawText(5.2, 27.9, "Ran on ======> " & @MON & "/" & @MDAY & "/" & @YEAR, "_Garamond", 15, $PDF_ALIGN_LEFT) _SetTextHorizontalScaling(80) _SetTextHorizontalScaling(100) _SetColourFill(0) _EndObject() For $a = 1 to UBound($SySlogall)-1 _BeginPage() ;========================================================================= First deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 21.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 22, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Second deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 16,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 16.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Third deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 10.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 11, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Forth deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 5.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf _EndPage() next ;then, finally, write the buffer to disk _ClosePDFFile() Func _InsertTable1($iX, $iY, $iW=0, $iH=0, $iCols=0, $iRows=0,$lTxtColor = 0x000000, $lBorderColor = 0xdddddd) Local $iPgW = 22.5;21 Local $iPgH = 10;29.7 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) $iColW = $iW/$iCols Local $iRowH = $iH/$iRows Local $lRGB For $i = 0 To $iRows-1 For $j = 0 To $iCols-1 If $j = "0" Then $iColW = 1.2 $icolw2 = 0 ELSEIf $j = "1" Then $iColW = 1.4 $icolw2 = 1.2 ElseIf $j = "2" Then $iColW = 1.3 $icolw2 = 2.6 ElseIf $j = "3" Then $iColW = 1 $icolw2 = 3.9 ElseIf $j = "4" Then $iColW = 1.5 $icolw2 = 4.9 ElseIf $j = "5" Then $iColW = 3 $icolw2 = 6.4 ElseIf $j = "6" Then $iColW = 4 $icolw2 = 9.4 ElseIf $j = "7" Then $iColW = 3.5 $icolw2 = 13.4 ElseIf $j = "8" Then $iColW = 3.35 $icolw2 = 16.9 Else $iColW = 2.08 EndIf ;~ $iColW = $iW/$iCols ConsoleWrite($iColW & @CRLF) If $i=0 Then ; if is the first row then colour it $lRGB = 0xefefef _SetTextHorizontalScaling(100) Else $lRGB = 0xfefefe _SetTextHorizontalScaling(60) EndIf _SetColourStroke($lBorderColor) If not $SyslogArray[$i][$j] = "" Then; If the field is blank, don't draw a box. If $j = "6" Then _Draw_Rectangle($iX+$iColW2, $iY+$iH-($i+1)*$iRowH, 10.85, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01) Else _Draw_Rectangle($iX+$iColW2, $iY+$iH-($i+1)*$iRowH, $iColW, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01) EndIf endif _SetColourStroke(0) Local $sText = "Row "&$i&": Col "&$j If $SyslogArray[$i][$j] = "" Then $SyslogArray[$i][$j] = "" EndIf Local $sText = $SyslogArray[$i][$j] Local $sLength = Round(_GetTextLength($sText, "_Calibri", 10),1) $lScale = Ceiling(0.75*$iColW * 100/ $sLength) _SetColourFill($lTxtColor) _DrawText($iX+$iColW2+$iColW/10, $iY+$iH-($i+1)*$iRowH + ($iRowH-10/_GetUnit())/2, $sText, "_TimesT", 10, $PDF_ALIGN_LEFT, 0) _SetTextHorizontalScaling(100) _SetColourFill(0) Next Next EndFunc Link to comment Share on other sites More sharing options...
taietel Posted August 29, 2011 Author Share Posted August 29, 2011 (edited) bartekd, at the end of the _ClosePDFFile function, put these lines (marked with <<<<<<<<<<<): ... $_Pages = "" ;<<<<<<<<<< clear the number of pages $_Buffer = "" ;<<<<<<<<<< clear the buffer If $_bOpen Then ShellExecute($PDF_NAME) EndFunc ;==>_ClosePDFFile [EDIT] scrambled Edited August 29, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
bartekd Posted August 29, 2011 Share Posted August 29, 2011 bartekd, at the end of the _ClosePDFFile function, put these lines (marked with <<<<<<<<<<<): ... $_Pages = "" ;<<<<<<<<<< clear the number of pages $_Buffer = "" ;<<<<<<<<<< clear the buffer If $_bOpen Then ShellExecute($PDF_NAME) EndFunc ;==>_ClosePDFFile [EDIT] scrambled Thanks allot Taietel for your suggestion, but it still shows that the report is longer than it is, and it has pages at the end that makes it corrupt. See this example, and let me know if you get the same thing. Or if there is anything else I can add, let me know. The issue for this example is on the 3rd page after I added it to the function itself. expandcollapse popup#include "MPDF_UDF.au3" #include <array.au3> ;====================================================================1st report Local $SySlogall[4][21] $SySlogall[1][0] = "Aug 28" $SySlogall[1][1] = "08" $SySlogall[1][2] = "28" $SySlogall[1][3] = "2011" $SySlogall[1][4] = "12:12:12" $SySlogall[1][5] = "asdf.asdf.com" $SySlogall[1][6] = "Security" $SySlogall[1][7] = "Security" $SySlogall[1][8] = "Account Management" $SySlogall[1][9] = "test" $SySlogall[1][10] = "630" $SySlogall[1][11] = "User Account Deleted" $SySlogall[1][12] = "test" $SySlogall[1][13] = "domain" $SySlogall[1][14] = "{S-123123123123123}" $SySlogall[1][15] = "creator" $SySlogall[1][16] = "Domain" $SySlogall[1][17] = "" $SySlogall[1][18] = "-" $SySlogall[1][19] = "camp" $SySlogall[1][20] = "Domain" $SySlogall[2][0] = "Aug 28" $SySlogall[2][1] = "08" $SySlogall[2][2] = "28" $SySlogall[2][3] = "2011" $SySlogall[2][4] = "12:12:12" $SySlogall[2][5] = "asdf.asdf.com" $SySlogall[2][6] = "Security" $SySlogall[2][7] = "Security" $SySlogall[2][8] = "Account Management" $SySlogall[2][9] = "test" $SySlogall[2][10] = "630" $SySlogall[2][11] = "User Account Deleted" $SySlogall[2][12] = "test" $SySlogall[2][13] = "domain" $SySlogall[2][14] = "{S-123123123123123}" $SySlogall[2][15] = "creator" $SySlogall[2][16] = "Domain" $SySlogall[2][17] = "" $SySlogall[2][18] = "-" $SySlogall[2][19] = "camp" $SySlogall[2][20] = "Domain" $SySlogall[3][0] = "Aug 28" $SySlogall[3][1] = "08" $SySlogall[3][2] = "28" $SySlogall[3][3] = "2011" $SySlogall[3][4] = "12:12:12" $SySlogall[3][5] = "asdf.asdf.com" $SySlogall[3][6] = "Security" $SySlogall[3][7] = "Security" $SySlogall[3][8] = "Account Management" $SySlogall[3][9] = "test" $SySlogall[3][10] = "630" $SySlogall[3][11] = "User Account Deleted" $SySlogall[3][12] = "test" $SySlogall[3][13] = "domain" $SySlogall[3][14] = "{S-123123123123123}" $SySlogall[3][15] = "creator" $SySlogall[3][16] = "Domain" $SySlogall[3][17] = "" $SySlogall[3][18] = "-" $SySlogall[3][19] = "camp" $SySlogall[3][20] = "Domain" _ArrayDisplay($SySlogall) ;================================================================== Creating the main array that it runs off of Local $SyslogArray[10][10] $SyslogArray[0][0] = "Type" $SyslogArray[0][1] = "Date" $SyslogArray[0][2] = "Time" $SyslogArray[0][3] = "Event" $SyslogArray[0][4] = "Source" $SyslogArray[0][5] = "Domain\User" $SyslogArray[0][6] = "Description" $SyslogArray[0][7] = "Computer" $SyslogArray[0][8] = "Category" ;=================================================================== Array end ;set the properties for the pdf _SetTitle("Gemma Communications Deletion report") _SetSubject("Gemma Deletes") _SetKeywords("Deletes, Report, Gemma, TD, Rogers") _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 & "\Example_mixed.pdf") ;=== load resources used in pdf === ;images: _LoadResImage("GemmaLogo", @ScriptDir & "\Images\Gemma.JPG") ;fonts: ;_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) ;=== create objects that are used in multiple pages === ;create a header on all pages, except the first: _StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE) _InsertImage("GemmaLogo", 0.5, 27, 4, 2) _SetColourFill(0x323232) _SetTextHorizontalScaling(50) _DrawText(5.2, 28.6, StringUpper("Gemma Communications Deletion Report"), "_Garamond", 15, $PDF_ALIGN_LEFT) _DrawText(5.2, 27.9, "Ran on ======> " & @MON & "/" & @MDAY & "/" & @YEAR, "_Garamond", 15, $PDF_ALIGN_LEFT) _SetTextHorizontalScaling(80) _SetTextHorizontalScaling(100) _SetColourFill(0) _EndObject() For $a = 1 to UBound($SySlogall)-1 _BeginPage() ;========================================================================= First deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 21.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 22, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Second deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 16,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 16.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Third deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 10.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 11, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Forth deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 5.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf _EndPage() next ;then, finally, write the buffer to disk _ClosePDFFile() MsgBox(1,"test","Hit ok to run the next report") ;==================================================================== 2nd report Local $SySlogall[4][21] $SySlogall[1][0] = "Aug 28" $SySlogall[1][1] = "08" $SySlogall[1][2] = "28" $SySlogall[1][3] = "2011" $SySlogall[1][4] = "12:12:12" $SySlogall[1][5] = "asdf.asdf.com" $SySlogall[1][6] = "Security" $SySlogall[1][7] = "Security" $SySlogall[1][8] = "Account Management" $SySlogall[1][9] = "test" $SySlogall[1][10] = "630" $SySlogall[1][11] = "User Account Deleted" $SySlogall[1][12] = "test" $SySlogall[1][13] = "domain" $SySlogall[1][14] = "{S-123123123123123}" $SySlogall[1][15] = "creator" $SySlogall[1][16] = "Domain" $SySlogall[1][17] = "" $SySlogall[1][18] = "-" $SySlogall[1][19] = "camp" $SySlogall[1][20] = "Domain" $SySlogall[2][0] = "Aug 28" $SySlogall[2][1] = "08" $SySlogall[2][2] = "28" $SySlogall[2][3] = "2011" $SySlogall[2][4] = "12:12:12" $SySlogall[2][5] = "asdf.asdf.com" $SySlogall[2][6] = "Security" $SySlogall[2][7] = "Security" $SySlogall[2][8] = "Account Management" $SySlogall[2][9] = "test" $SySlogall[2][10] = "630" $SySlogall[2][11] = "User Account Deleted" $SySlogall[2][12] = "test" $SySlogall[2][13] = "domain" $SySlogall[2][14] = "{S-123123123123123}" $SySlogall[2][15] = "creator" $SySlogall[2][16] = "Domain" $SySlogall[2][17] = "" $SySlogall[2][18] = "-" $SySlogall[2][19] = "camp" $SySlogall[2][20] = "Domain" $SySlogall[3][0] = "Aug 28" $SySlogall[3][1] = "08" $SySlogall[3][2] = "28" $SySlogall[3][3] = "2011" $SySlogall[3][4] = "12:12:12" $SySlogall[3][5] = "asdf.asdf.com" $SySlogall[3][6] = "Security" $SySlogall[3][7] = "Security" $SySlogall[3][8] = "Account Management" $SySlogall[3][9] = "test" $SySlogall[3][10] = "630" $SySlogall[3][11] = "User Account Deleted" $SySlogall[3][12] = "test" $SySlogall[3][13] = "domain" $SySlogall[3][14] = "{S-123123123123123}" $SySlogall[3][15] = "creator" $SySlogall[3][16] = "Domain" $SySlogall[3][17] = "" $SySlogall[3][18] = "-" $SySlogall[3][19] = "camp" $SySlogall[3][20] = "Domain" _ArrayDisplay($SySlogall) ;================================================================== Creating the main array that it runs off of Local $SyslogArray[10][10] $SyslogArray[0][0] = "Type" $SyslogArray[0][1] = "Date" $SyslogArray[0][2] = "Time" $SyslogArray[0][3] = "Event" $SyslogArray[0][4] = "Source" $SyslogArray[0][5] = "Domain\User" $SyslogArray[0][6] = "Description" $SyslogArray[0][7] = "Computer" $SyslogArray[0][8] = "Category" ;=================================================================== Array end ;set the properties for the pdf _SetTitle("Gemma Communications Deletion report") _SetSubject("Gemma Deletes") _SetKeywords("Deletes, Report, Gemma, TD, Rogers") _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 & "\Example_mixed.pdf") ;=== load resources used in pdf === ;images: _LoadResImage("GemmaLogo", @ScriptDir & "\Images\Gemma.JPG") ;fonts: ;_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) ;=== create objects that are used in multiple pages === ;create a header on all pages, except the first: _StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE) _InsertImage("GemmaLogo", 0.5, 27, 4, 2) _SetColourFill(0x323232) _SetTextHorizontalScaling(50) _DrawText(5.2, 28.6, StringUpper("Gemma Communications Deletion Report"), "_Garamond", 15, $PDF_ALIGN_LEFT) _DrawText(5.2, 27.9, "Ran on ======> " & @MON & "/" & @MDAY & "/" & @YEAR, "_Garamond", 15, $PDF_ALIGN_LEFT) _SetTextHorizontalScaling(80) _SetTextHorizontalScaling(100) _SetColourFill(0) _EndObject() For $a = 1 to UBound($SySlogall)-1 _BeginPage() ;========================================================================= First deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 21.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 22, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Second deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 16,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 16.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Third deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 10.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 11, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Forth deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 5.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf _EndPage() next ;then, finally, write the buffer to disk _ClosePDFFile() MsgBox(1,"test","Hit ok to run the next report") ;==================================================================== 3rd report Local $SySlogall[12][21] $SySlogall[1][0] = "Aug 28" $SySlogall[1][1] = "08" $SySlogall[1][2] = "28" $SySlogall[1][3] = "2011" $SySlogall[1][4] = "12:12:12" $SySlogall[1][5] = "asdf.asdf.com" $SySlogall[1][6] = "Security" $SySlogall[1][7] = "Security" $SySlogall[1][8] = "Account Management" $SySlogall[1][9] = "test" $SySlogall[1][10] = "630" $SySlogall[1][11] = "User Account Deleted" $SySlogall[1][12] = "test" $SySlogall[1][13] = "domain" $SySlogall[1][14] = "{S-123123123123123}" $SySlogall[1][15] = "creator" $SySlogall[1][16] = "Domain" $SySlogall[1][17] = "" $SySlogall[1][18] = "-" $SySlogall[1][19] = "camp" $SySlogall[1][20] = "Domain" $SySlogall[2][0] = "Aug 28" $SySlogall[2][1] = "08" $SySlogall[2][2] = "28" $SySlogall[2][3] = "2011" $SySlogall[2][4] = "12:12:12" $SySlogall[2][5] = "asdf.asdf.com" $SySlogall[2][6] = "Security" $SySlogall[2][7] = "Security" $SySlogall[2][8] = "Account Management" $SySlogall[2][9] = "test" $SySlogall[2][10] = "630" $SySlogall[2][11] = "User Account Deleted" $SySlogall[2][12] = "test" $SySlogall[2][13] = "domain" $SySlogall[2][14] = "{S-123123123123123}" $SySlogall[2][15] = "creator" $SySlogall[2][16] = "Domain" $SySlogall[2][17] = "" $SySlogall[2][18] = "-" $SySlogall[2][19] = "camp" $SySlogall[2][20] = "Domain" $SySlogall[3][0] = "Aug 28" $SySlogall[3][1] = "08" $SySlogall[3][2] = "28" $SySlogall[3][3] = "2011" $SySlogall[3][4] = "12:12:12" $SySlogall[3][5] = "asdf.asdf.com" $SySlogall[3][6] = "Security" $SySlogall[3][7] = "Security" $SySlogall[3][8] = "Account Management" $SySlogall[3][9] = "test" $SySlogall[3][10] = "630" $SySlogall[3][11] = "User Account Deleted" $SySlogall[3][12] = "test" $SySlogall[3][13] = "domain" $SySlogall[3][14] = "{S-123123123123123}" $SySlogall[3][15] = "creator" $SySlogall[3][16] = "Domain" $SySlogall[3][17] = "" $SySlogall[3][18] = "-" $SySlogall[3][19] = "camp" $SySlogall[3][20] = "Domain" _ArrayDisplay($SySlogall) ;================================================================== Creating the main array that it runs off of Local $SyslogArray[10][10] $SyslogArray[0][0] = "Type" $SyslogArray[0][1] = "Date" $SyslogArray[0][2] = "Time" $SyslogArray[0][3] = "Event" $SyslogArray[0][4] = "Source" $SyslogArray[0][5] = "Domain\User" $SyslogArray[0][6] = "Description" $SyslogArray[0][7] = "Computer" $SyslogArray[0][8] = "Category" ;=================================================================== Array end ;set the properties for the pdf _SetTitle("Gemma Communications Deletion report") _SetSubject("Gemma Deletes") _SetKeywords("Deletes, Report, Gemma, TD, Rogers") _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 & "\Example_mixed.pdf") ;=== load resources used in pdf === ;images: _LoadResImage("GemmaLogo", @ScriptDir & "\Images\Gemma.JPG") ;fonts: ;_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) ;=== create objects that are used in multiple pages === ;create a header on all pages, except the first: _StartObject("Antet", $PDF_OBJECT_ALLPAGES);NOTFIRSTPAGE) _InsertImage("GemmaLogo", 0.5, 27, 4, 2) _SetColourFill(0x323232) _SetTextHorizontalScaling(50) _DrawText(5.2, 28.6, StringUpper("Gemma Communications Deletion Report"), "_Garamond", 15, $PDF_ALIGN_LEFT) _DrawText(5.2, 27.9, "Ran on ======> " & @MON & "/" & @MDAY & "/" & @YEAR, "_Garamond", 15, $PDF_ALIGN_LEFT) _SetTextHorizontalScaling(80) _SetTextHorizontalScaling(100) _SetColourFill(0) _EndObject() For $a = 1 to UBound($SySlogall)-1 _BeginPage() ;========================================================================= First deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 21.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 22, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Second deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 16,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 16.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Third deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 10.5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 11, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) $a = $a + 1 If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf ;========================================================================= Forth deletion on the page $SyslogArray[1][0] = "Termination" $SyslogArray[1][1] = $SySlogall[$a][1] & "/" & $SySlogall[$a][2] & "/" & $SySlogall[$a][3] $SyslogArray[1][2] = $SySlogall[$a][4] $SyslogArray[1][3] = $SySlogall[$a][10] $SyslogArray[1][4] = $SySlogall[$a][6] $SyslogArray[1][5] = $SySlogall[$a][13] & "\" & $SySlogall[$a][12] $SyslogArray[1][7] = $SySlogall[$a][5] $SyslogArray[1][6] = $SySlogall[$a][11] $SyslogArray[2][6] = " Campaign: " & $SySlogall[$a][19] & " (" & $SySlogall[$a][20] & ")" $SyslogArray[3][6] = " Target Account Name: " & $SySlogall[$a][12] $SyslogArray[4][6] = " Target Domain: " & $SySlogall[$a][13] $SyslogArray[5][6] = " Target Account ID: %" & $SySlogall[$a][14] $SyslogArray[6][6] = " Caller User Name: " & $SySlogall[$a][15] $SyslogArray[7][6] = " Caller Domain: " & $SySlogall[$a][16] $SyslogArray[8][6] = " TermDate: " & $SySlogall[$a][0] $SyslogArray[9][6] = " Privileges: -" $SyslogArray[1][8] = $SySlogall[$a][8] _InsertTable1(0.25, 5,0,5,9,10);table with 8x5 cells, 2cm from the left,8cm from bottom, width/height auto _DrawText(0.4, 5.5, $a, "_Garamond", 15, $PDF_ALIGN_LEFT) If $a > ubound($SySlogall)-1 then _EndPage() ExitLoop EndIf _EndPage() next ;then, finally, write the buffer to disk _ClosePDFFile() Func _InsertTable1($iX, $iY, $iW=0, $iH=0, $iCols=0, $iRows=0,$lTxtColor = 0x000000, $lBorderColor = 0xdddddd) Local $iPgW = 22.5;21 Local $iPgH = 10;29.7 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) $iColW = $iW/$iCols Local $iRowH = $iH/$iRows Local $lRGB For $i = 0 To $iRows-1 For $j = 0 To $iCols-1 If $j = "0" Then $iColW = 1.2 $icolw2 = 0 ELSEIf $j = "1" Then $iColW = 1.4 $icolw2 = 1.2 ElseIf $j = "2" Then $iColW = 1.3 $icolw2 = 2.6 ElseIf $j = "3" Then $iColW = 1 $icolw2 = 3.9 ElseIf $j = "4" Then $iColW = 1.5 $icolw2 = 4.9 ElseIf $j = "5" Then $iColW = 3 $icolw2 = 6.4 ElseIf $j = "6" Then $iColW = 4 $icolw2 = 9.4 ElseIf $j = "7" Then $iColW = 3.5 $icolw2 = 13.4 ElseIf $j = "8" Then $iColW = 3.35 $icolw2 = 16.9 Else $iColW = 2.08 EndIf ;~ $iColW = $iW/$iCols ConsoleWrite($iColW & @CRLF) If $i=0 Then ; if is the first row then colour it $lRGB = 0xefefef _SetTextHorizontalScaling(100) Else $lRGB = 0xfefefe _SetTextHorizontalScaling(60) EndIf _SetColourStroke($lBorderColor) If not $SyslogArray[$i][$j] = "" Then; If the field is blank, don't draw a box. If $j = "6" Then _Draw_Rectangle($iX+$iColW2, $iY+$iH-($i+1)*$iRowH, 10.85, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01) Else _Draw_Rectangle($iX+$iColW2, $iY+$iH-($i+1)*$iRowH, $iColW, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01) EndIf endif _SetColourStroke(0) Local $sText = "Row "&$i&": Col "&$j If $SyslogArray[$i][$j] = "" Then $SyslogArray[$i][$j] = "" EndIf Local $sText = $SyslogArray[$i][$j] Local $sLength = Round(_GetTextLength($sText, "_Calibri", 10),1) $lScale = Ceiling(0.75*$iColW * 100/ $sLength) _SetColourFill($lTxtColor) _DrawText($iX+$iColW2+$iColW/10, $iY+$iH-($i+1)*$iRowH + ($iRowH-10/_GetUnit())/2, $sText, "_TimesT", 10, $PDF_ALIGN_LEFT, 0) _SetTextHorizontalScaling(100) _SetColourFill(0) Next Next EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now