I'm trying to read PDF' page size eg.height X weight. Page size can be found in
File -> Properties -> Page Size
I used the code below to fetch the property value:
$path = FileOpenDialog("Select a file to read attributes",#ScriptDir,"All (*.*)")
$prop = _GetExtProperty($path,-1)
_ArrayDisplay($prop,"Property Array")
Func _GetExtProperty($sPath, $iProp)
Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
$iExist = FileExists($sPath)
If $iExist = 0 Then
SetError(1)
Return 0
Else
$sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
$sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
$oShellApp = ObjCreate ("shell.application")
$oDir = $oShellApp.NameSpace ($sDir)
$oFile = $oDir.Parsename ($sFile)
If $iProp = -1 Then
Local $aProperty[35]
For $i = 0 To 34
$aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
Next
Return $aProperty
Else
$sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
If $sProperty = "" Then
Return 0
Else
Return $sProperty
EndIf
EndIf
EndIf
EndFunc ;==>_GetExtProperty
By using above code i managed to get file size in MB, Created date , Modified date, Location and so on, but not Page Size. Appreciated, if anyone could advice how I can get page size. Any reference, advice or sample code is highly appreciated.
Nearly the same, but maybe it helps.
#include <Array.au3>
;===============================================================================
; Function Name.....: _FileGetProperty
; Description.......: Returns a property or all properties for a file.
; Version...........: 1.0.2
; Change Date.......: 2008-07-28
; AutoIt Version....: 3.2.12.1
;
; Parameter(s)......: $S_PATH - String containing the file path to return the property from.
; $S_PROPERTY - [optional] String containing the name of the property to return. (default = "")
; Requirements(s)...: None
; Return Value(s)...: Success: Returns a string containing the property value.
; If $S_PROPERTY is empty, an two-dimensional array is returned:
; $av_array[0][0] = Number of properties.
; $av_array[1][0] = 1st property name.
; $as_array[1][1] = 1st property value.
; $av_array[n][0] = nth property name.
; $as_array[n][1] = nth property value.
; Failure: Returns 0 and sets #error to:
; 1 = The folder $S_PATH does not exist.
; 2 = The property $S_PROPERTY does not exist or the array could not be created.
; 3 = Unable to create the "Shell.Application" object $objShell.
;
; Author(s).........: - Simucal <Simucal#gmail.com>
; - Modified by: Sean Hart <autoit#hartmail.ca>
; - Modified by: teh_hahn <sPiTsHiT#gmx.de>
; Company...........: None
; URL...............: None
; Note(s)...........: None
;===============================================================================
Global $re = _FileGetProperty(#ScriptDir & '\1Tutorial - AutoItWiki1.pdf')
If #error Then MsgBox(16, 'ERROR', 'Error: ' & #error & #CRLF & '1 = The folder $S_PATH does not exist.' & #CRLF & _
'2 = The property $S_PROPERTY does not exist or the array could not be created.' & #CRLF & _
'3 = Unable to create the "Shell.Application" object $objShell.')
_ArrayDisplay($re)
Func _FileGetProperty(Const $S_PATH, Const $S_PROPERTY = "")
If Not FileExists($S_PATH) Then Return SetError(1, 0, 0)
Local Const $S_FILE = StringTrimLeft($S_PATH, StringInStr($S_PATH, "\", 0, -1))
Local Const $S_DIR = StringTrimRight($S_PATH, StringLen($S_FILE) + 1)
Local Const $objShell = ObjCreate("Shell.Application")
If #error Then Return SetError(3, 0, 0)
Local Const $objFolder = $objShell.NameSpace($S_DIR)
Local Const $objFolderItem = $objFolder.Parsename($S_FILE)
If $S_PROPERTY Then
For $i = 0 To 99
If $objFolder.GetDetailsOf($objFolder.Items, $i) = $S_PROPERTY Then Return $objFolder.GetDetailsOf($objFolderItem, $i)
Next
Return SetError(2, 0, 0)
EndIf
Local $av_ret[1][2] = [[1]]
For $i = 0 To 99
If $objFolder.GetDetailsOf($objFolder.Items, $i) Then
ReDim $av_ret[$av_ret[0][0] + 1][2]
$av_ret[$av_ret[0][0]][0] = $objFolder.GetDetailsOf($objFolder.Items, $i)
$av_ret[$av_ret[0][0]][1] = $objFolder.GetDetailsOf($objFolderItem, $i)
$av_ret[0][0] += 1
EndIf
Next
If Not $av_ret[1][0] Then Return SetError(2, 0, 0)
$av_ret[0][0] -= 1
Return $av_ret
EndFunc ;==>_FileGetProperty
Related
I got Index was outside the bounds of the array error when use debug mode in asp net core mvc, but its ok when run in non-debug mode (Shift+F5).
Here details of error description :
An unhandled exception occurred while processing the request.
IndexOutOfRangeException: Index was outside the bounds of the array.
AspNetCore.ReportingServices.RdlExpressions.ExpressionHostObjectModel.RemoteArrayWrapper.get_Item(int
index)
ReportProcessingException: An unexpected error occurred in Report
Processing. Index was outside the bounds of the array.
AspNetCore.ReportingServices.ReportProcessing.Execution.RenderReport.Execute(IRenderingExtension
newRenderer)
LocalProcessingException: An error occurred during local report
processing.;An unexpected error occurred in Report Processing. Index
was outside the bounds of the array.
AspNetCore.Reporting.InternalLocalReport.InternalRender(string format,
bool allowInternalRenderers, string deviceInfo, PageCountMode
pageCountMode, CreateAndRegisterStream createStreamCallback, out
Warning[] warnings)
Here my export to pdf code :
int extension = 1;
var path = $"{this._webHostEnvironment.WebRootPath}\\Report\\RptDO2.rdlc";
Dictionary<string, string> parameters = new Dictionary<string, string>();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Encoding.GetEncoding("windows-1252");
parameters.Add("txtto", inv.Quotation.CustomerContact.Customer.CompanyName);
parameters.Add("txtaddress_detail", inv.Quotation.CustomerContact.Customer.Address1 + "\r\n"
+ inv.Quotation.CustomerContact.Customer.Address2 + "- "
+ inv.Quotation.CustomerContact.Customer.City + "- "
+ inv.Quotation.CustomerContact.Customer.State + " ("
+ inv.Quotation.CustomerContact.Customer.Zip + ")\r\n"
+ "Phone : " + inv.Quotation.CustomerContact.Customer.PhoneNumber
+ ", Email : " + inv.Quotation.CustomerContact.Customer.Email);
parameters.Add("txtdo_no", inv.Id.Replace("INV", "DO"));
parameters.Add("txtdate", inv.Quotation.CreatedAt.ToShortDateString());
parameters.Add("txtrefnum", inv.QuotationId);
parameters.Add("txtfrom", us.FirstName + " " + us.LastName);
parameters.Add("txtUP", TextUp);
parameters.Add("kop_nama", c.CpName);
parameters.Add("kop_alamat", c.CpStreetAddress);
parameters.Add("kop_alamat2", c.CpCity + " " + c.CpState + " (" + c.CpZip + ")");
parameters.Add("kop_contact", c.CpPhone);
parameters.Add("kop_email", c.CpEmail);
parameters.Add("kop_logo", Convert.ToBase64String(c.CpFoto));
parameters.Add("txtjabatan", us.Designation);
parameters.Add("txtPrintedBy", lgnuser.FirstName + " " + lgnuser.LastName);
List<vwQuotationDetail> vwQuotationDetails = new List<vwQuotationDetail>();
foreach (TblquotationDetail quos in inv.Quotation.TblquotationDetail.OrderBy(o => o.Id))
{
vwQuotationDetail quotationDetail = new vwQuotationDetail
{
id = quos.Id,
quotation_id = quos.QuotationId,
order_number = quos.OrderNumber,
product_name = quos.Product.ProductName,
product_id = quos.ProductId,
product_comments = string.IsNullOrEmpty(quos.ProductComments) ? "" : quos.ProductComments,
quantity = quos.Quantity,
unit_price = quos.UnitPrice,
unit_name = quos.Product.Unit.UnitName,
sub_total = quos.SubTotal,
product_desc = quos.Product.ProductDesc,
category_name = quos.Product.Category.CategoryName
};
vwQuotationDetails.Add(quotationDetail);
}
LocalReport localReport = new LocalReport(path);
localReport.AddDataSource("dsDO", vwQuotationDetails.ToArray());
//var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimtype);
var result = localReport.Execute(RenderType.Pdf, extension, parameters);
return File(result.MainStream, "application/pdf");
Any suggestion will appreciated, thanks in advance.
Just Dont Pass extension as 1 in:
var result = localReport.Execute(RenderType.Pdf, extension, parameters);
The Solution is:
int ext = (int)(DateTime.Now.Ticks >> 10);
var result = localReport.Execute(RenderType.Pdf, ext, param);
In other words, Extension should not be same for every report.
I am trying to automate drag and drop between two File Explorers on windows OS. I could find online help to drag and drop implementation for Browsers.
But no help for drag and drop for file to another File Explorer.
Use for this the Shell.Application object. To get the selection from the explorer you can use the following function:
;===============================================================================
; Function Name....: _ActiveExplorer_GetSelected
; Description......: Creates an array with
; - Count of selected files/folder
; - Path of active Explorer window and
; - the path/es of selected file/s /folder
; Requirement(s)...: Opened Explorer window
; Return Value(s)..: Array with data, $a[0] = Count, $a[1] = Folderpath, $a[2..] = File/Foldername
; .................: ATTENTION! Last index $a[0]+1 !!
; Author(s)........: BugFix ( AutoIt#bug-fix.info )
;===============================================================================
Func _ActiveExplorer_GetSelected()
Local $oShell = ObjCreate("Shell.Application")
Local $oExplorer, $sPath, $oFolderView, $iCount = 0, $sSelectedFiles = '', $n = 2
Local $oShellWindows = $oShell.Windows
For $i = 0 To $oShellWindows.Count -1
$oExplorer = $oShellWindows($i)
$sPath = StringReplace(StringReplace(StringTrimLeft($oExplorer.LocationURL, 8), '%20', ' '), '/', '\')
If WinGetTitle('[ACTIVE]') = $sPath Then ExitLoop
Next
$oFolderView = $oExplorer.Document.SelectedItems()
$iCount = $oFolderView.Count
Local $aOut[$iCount +2]
$aOut[0] = $iCount
$aOut[1] = $sPath
If $iCount = 0 Then
Return ''
Else
For $oFolderItem In $oFolderView
$aOut[$n] = $oFolderItem.Name
$n += 1
Next
Return $aOut
EndIf
EndFunc ; ==>_ActiveExplorer_GetSelected
One can create text annotations on image displays via the function NewTextAnnotation and then change the font via the method ComponentSetFontFaceName. However to do so successfully, one must provide the full name of the desired font as a string and one must already know that it is available on the current system. If one specifies an unavailable font, some default font seems to be chosen and no exception or error message is posted.
Is there any way to get a list of available fonts within a DM script or to determine whether a specific named font is actually available?
Interesting task!
There is no actual script command to do this, and the list of installed font-names is populated by the OS.
However, using Powershell and the script command LaunchExternal() one can construct a workaround.
After some trial and error, I think I got it working by the following script:
void WriteFontListToDisk( string fileName )
{
String PSscript
PSscript += "[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing');"
PSscript += "(New-Object System.Drawing.Text.InstalledFontCollection).Families "
PSscript += " | out-file -encoding ASCII " + fileName // Need to specify ASCII here!
String callString
callString += "powershell"
//callString += " -NoExit" // Keep Powershell open
callString += " -Command &{ "
callString += PSscript
callString += " }"
LaunchExternalProcess( callString, 5 )
}
TagGroup ReadFontListFromFile( string fileName )
{
TagGroup tg = NewTagList()
if ( !DoesFileExist( fileName ) ) Throw( "Font list file not found:\n" + fileName )
number fileID = OpenFileForReading( fileName )
object fileStream = NewStreamFromFileReference( fileID, 1 )
result("\n SIZE:" + fileStream.StreamGetSize() )
// Output format is
// #1:(empty)
// #2: Name
// #3: ----
// #4+: FontNames
string line
for( number i=0;i<3;i++) fileStream.StreamReadTextLine( 0, line )
number inc = 0
while( fileStream.StreamGetPos() != fileStream.StreamGetSize() )
{
if ( !fileStream.StreamReadTextLine( 0, line ) ) break;
tg.TagGroupInsertTagAsString( Infinity(), line )
if ( ShiftDown() ) exit(0)
}
return tg
}
TagGroup GetFontList()
{
TagGroup tg = NewTagGroup()
string fileName = "C:\\FontNamesList.txt"
if ( DoesFileExist( fileName ) ) DeleteFile( fileName )
WriteFontListToDisk( fileName )
tg = ReadFontListFromFile( fileName )
if ( DoesFileExist( fileName ) ) DeleteFile( fileName )
return tg
}
GetFontList().TagGroupOpenBrowserWindow( "Fonts" , 0 )
It is worthwhile to note that PowerShell by default streams text output as UNICODE and that does not work well with text-import in DM. However, this question was helpful, and the script above sets the output to ASCII. One issue though is, that in doing so some characters might be lost and it might be needed to carefully check the output font-list.
Hi a friend of mine asked me to recover a password of a program written in clipper back in 1994. I got myself a decompiler (Valkyrie 5) and decompiled the EXE-file. I located a procedure called USERLOGIN. The problem is that i dont know how to program in clipper. I would be very thankfull if someone could edit the procedure so it won't ask for authentication anymore.
#include "common.ch"
#include "inkey.ch"
********************************
Function USERLOGON
Local Local1:= -1, Local2:= .F., Local3, Local4, Local5:= 3, ;
Local6:= 3, Local7:= 7, Local8:= 41, Local9, Local10, Local11, ;
Local12, Local13, Local14, Local15
Local3:= 1
Local9:= {}
Local13:= setcursor()
If (!netuse(diskname() + ":" + dirname() + "\" + "sinusr.dbf", ;
"users"))
Return Local1
EndIf
dbSetFilter({ || users->valid })
Local14:= box(Local5, Local6, Local7, Local8, Nil, ;
coltonum("GR+/B"))
Do While (!Local2)
Local10:= Space(12)
Local11:= Space(10)
setcursor(1)
If (!Empty(n_shellver()))
Local10:= padr(nnetwhoami(), 12)
EndIf
wininfo(Local14, #Local5, #Local6, #Local7, #Local8)
# Local5 + 1, Local6 + 5 Say "User............." Color "GR+/B"
SetPos(Row(), Col() + 1)
AAdd(Local9, __Get({ |_1| IIf(ISNIL(_1), Local10, Local10:= ;
_1) }, "cUName", "#K!", Nil, Nil):display())
# Local5 + 2, Local6 + 5 Say "Password........." Color "GR+/B"
SetPos(Row(), Col() + 1)
AAdd(Local9, __Get({ |_1| IIf(ISNIL(_1), Local11, Local11:= ;
_1) }, "cUPass", "#K!", Nil, Nil):display())
Local9[2]:reader({ |_1| gt_grpassw(_1) })
wreadmodal(Local9, 0)
Local11:= Local9[2]:cargo()
Local9:= {}
If (LastKey() == K_ESC .OR. !winisinuse(Local14))
If (winisinuse(Local14))
winclose(Local14)
EndIf
Return Local1
EndIf
Local10:= alltrim(Local10)
Local12:= {}
Locate For Local10 == alltrim(users->emri)
Do While (Found())
AAdd(Local12, users->id)
Continue
EndDo
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
If (alltrim(Local11) == Local15)
Local2:= .T.
Exit
EndIf
EndIf
Next
EndDo
If (users->id != Local12[Local4])
users->(dbGoTop())
Locate For Local12[Local4] == users->id
If (!Found())
msg("Fatal error in user's file !", 3)
Return -1
EndIf
EndIf
For Local4:= 1 To MaxCol()
winchgpos(0, 3)
Next
boxc(Local14)
setcursor(Local13)
If (users->in)
tone(500, 10)
Local4:= al_box("User " + Trim(users->emri) + ;
" is already IN;" + "Do You Want to Jump In ?", 2, ;
{" Yes ", " No "}, 2, "WARNING")
If (Local4 == 1)
msg("More than One User with the same Name might cause Trouble !", ;
3)
Else
Close
Return -1
EndIf
ElseIf (netrlock())
Replace users->in With .T.
Unlock
dbcommit()
Else
Close
Return -1
EndIf
Static148[1]:= users->id
Static148[2]:= alltrim(users->emri)
Static148[3]:= alltrim(users->dirpriv)
Static148[4]:= users->gjuha1
Static148[5]:= users->gjuha2
Static148[6]:= alltrim(users->emriiplote)
Local1:= Static148[1]
Close
Return Local1
* EOF
This is partially guesswork, but here's my interpretation:
Read the user's password from the console into Local9[2]:
# Local5 + 2, Local6 + 5 Say "Password........." Color "GR+/B"
...
Local9[2]:reader({ |_1| gt_grpassw(_1) })
wreadmodal(Local9, 0)
Put the password into Local11:
Local11:= Local9[2]:cargo()
Fetch all user ids into Local12 via Local10:
Locate For Local10 == alltrim(users->emri)
Do While (Found())
AAdd(Local12, users->id)
Continue
EndDo
Get each user's password into Local15, and if the password's present and matches the password in Local11, verify the user:
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
If (alltrim(Local11) == Local15)
Local2:= .T.
Exit
EndIf
EndIf
Next
The fix
Just remove the password check code. Not being certain about the purpose of all the rest of the code, I'd recommend leaving it alone. I've preserved the retrieval of the user's password, as maybe there's a good reason not to log in a user who has no password at all (perhaps that's how an account is disabled. The last block above could be changed to this:
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
Local2:= .T.
EndIf
Next
I'm writing an automation script with autoit: http://www.autoitscript.com/autoit3/index.shtml. In the process I need to take a screenshot of a user selected area.
How can I recognize the mouse-drag select operation with Autoit 3? I basically need some way to get the coordinates of the selected rectangle...
rasim from the Autoit forums was kind enough to answer this question of mine with a working example: http://www.autoitscript.com/forum/index.php?showtopic=86894&st=0&gopid=623824&#entry623824
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ScreenCapture.au3>
Global Const $WM_LBUTTONDOWN = 0x0201
Global $hDLL = DllOpen("User32.dll")
Global $Drag = False
Global $aCoord_Start
Global $aCoord_End
Global $iLeft, $iTop, $iRight, $iBottom
Global $sCapture = False
HotKeySet("{Esc}", "_Exit")
Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr")
Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0)
While 1
If $sCapture Then
$sCapture = False
_ScreenCapture_Capture(#ScriptDir & "\Capture.jpg", $iLeft, $iTop, $iRight, $iBottom)
EndIf
Sleep(100)
WEnd
Func _Mouse_Handler($nCode, $wParam, $lParam)
If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
Switch $wParam
Case $WM_LBUTTONDOWN
$aCoord_Start = MouseGetPos()
Case $WM_MOUSEMOVE
If _IsPressed("01", $hDLL) Then $Drag = True
Case $WM_LBUTTONUP
$aCoord_End = MouseGetPos()
If $Drag = True Then
$Drag = False
If $aCoord_Start[0] < $aCoord_End[0] Then
$iLeft = $aCoord_Start[0]
$iRight = $aCoord_End[0]
Else
$iLeft = $aCoord_End[0]
$iRight = $aCoord_Start[0]
EndIf
If $aCoord_Start[1] < $aCoord_End[1] Then
$iTop = $aCoord_Start[1]
$iBottom = $aCoord_End[1]
Else
$iTop = $aCoord_End[1]
$iBottom = $aCoord_Start[1]
EndIf
$sCapture = True
Return 0
EndIf
EndSwitch
Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
EndFunc
Func _Exit()
DllCallbackFree($pStub_MouseProc)
_WinAPI_UnhookWindowsHookEx($hHookMouse)
DllClose($hDLL)
Exit
EndFunc