DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub Test2()
' Haluk 18/09/2021
' sa4truss@gmail.com
' https://excelhaluk.blogspot.com/
Dim FileNum As Long
Dim strRetVal As String
Dim RegExp As Object, temp As String
Set RegExp = CreateObject("VBscript.RegExp")
RegExp.Global = False
RegExp.Pattern = "MediaBox\[([^\]\[]+)\]"
strRetVal = "1 0 obj" & vbCrLf & _
"<</Type/Page/MediaBox[ 0 0 595.276 841.89]/Resources<</ColorSpace<</Cs1 1157 0 R >>" & _
"/ExtGState<</Gs1 1155 0 R /Gs2 1061 0 R >>/Font<</Tc1.0" & _
"1159 0 R /Tc4.1 1062 0 R >>>>/Contents 2 0 R /Parent 1145 0 R " & _
"/Rotate 0/CropBox[ 0 0 595.276 841.89]>>" & vbCrLf & _
"endobj"
temp = Trim(RegExp.Execute(strRetVal)(0).SubMatches(0))
MsgBox Round(Val(Split(temp, " ")(2)) / 72 * 2.54, 0) & " cm X " & Round(Val(Split(temp, " ")(3)) / 72 * 2.54, 0) & " cm"
End Sub
FileNum = FreeFile
Open PDF_File For Binary As #FileNum
strRetVal = Space(LOF(FileNum))
uzunluk = Len(strRetVal)
part1=Mid(strRetVal,1,100)
Get #FileNum, , strRetVal
Close #FileNum
Function GetPageSize(PDF_File As String)
' Haluk 18/09/2021
' sa4truss@gmail.com
' https://excelhaluk.blogspot.com/
Dim FSO As Object, objFile As Object
Dim strRetVal As String
Dim RegExp As Object, temp As String
Const ForReading = 1
Set RegExp = CreateObject("VBscript.RegExp")
RegExp.Global = False
RegExp.Pattern = "MediaBox\[([^\]\[]+)\]"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile(PDF_File, ForReading, False, True)
strRetVal = StrConv(objFile.ReadAll, vbUnicode)
temp = Trim(RegExp.Execute(strRetVal)(0).SubMatches(0))
GetPageSize = Round(Val(Split(temp, " ")(2)) / 72 * 2.54, 0) & " cm X " & Round(Val(Split(temp, " ")(3)) / 72 * 2.54, 0) & " cm"
Set objFile = Nothing
Set FSO = Nothing
Set RegExp = Nothing
End Function
Function GetPageSize(PDF_File As String)
' Haluk 19/09/2021
' sa4truss@gmail.com
' https://excelhaluk.blogspot.com/
Dim FSO As Object, objFile As Object
Dim strRetVal As String
Dim temp As String
Const ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile(PDF_File, ForReading, False, True)
strRetVal = StrConv(objFile.ReadAll, vbUnicode)
temp = Trim(Replace(Split(Split(strRetVal, "MediaBox")(1), "]")(0), "[", ""))
GetPageSize = Round(Val(Split(temp, " ")(2)) / 72 * 2.54, 0) & " cm X " & Round(Val(Split(temp, " ")(3)) / 72 * 2.54, 0) & " cm"
Set objFile = Nothing
Set FSO = Nothing
End Function