Felicitas Posted July 18 Share Posted July 18 Hello dear forum, I would like to extract an attached .xml from a .pdf. Is there a possibility? Thanks for ideas. Greetings Link to comment Share on other sites More sharing options...
Solution bdr529 Posted July 18 Solution Share Posted July 18 https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-attach To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
Felicitas Posted July 19 Author Share Posted July 19 Thank you. But is there an "on Board solution" only with autoit possible? Greets Link to comment Share on other sites More sharing options...
bdr529 Posted August 21 Share Posted August 21 expandcollapse popup#include <String.au3> #include <array.au3> #Include "ZLIB.au3" ; https://www.autoitscript.com/forum/topic/128962-zlib-deflateinflategzip-udf/page/2/#comments Extract_Embedded_Files_from_PDF_Documents() func Extract_Embedded_Files_from_PDF_Documents() dim $fileopendialog = FileOpenDialog("","", "Pdf(*.pdf)") if @error then return seterror (1,"","") dim $file = FileOpen($fileopendialog,16) dim $chars_binary=fileread($file) FileClose($file) dim $chars_string=BinaryToString($chars_binary) dim $array_0[0][2] dim $array_1[0][2] dim $stringsplit=stringsplit($chars_string,"endobj",1+2) for $a=0 to ubound($stringsplit)-1 $stringsplit[$a]=stringreplace($stringsplit[$a],chr(10),"",1) if stringleft($stringsplit[$a],2)="3 " then dim $_StringBetween_obj=_StringBetween($stringsplit[$a],"3 0 obj","") if not @error Then dim $_StringBetween_stream=_StringBetween($_StringBetween_obj[0],"stream"&@lf,@lf&"endstream") Dim $Decompressed = _ZLIB_Uncompress($_StringBetween_stream[0]) $chars_string=BinaryToString($Decompressed) dim $_StringBetween=_StringBetween($chars_string,"<<",">>") for $b=0 to ubound($_StringBetween)-1 dim $cell_0,$cell_1 $_StringBetween[$b]=stringreplace($_StringBetween[$b],chr(10),"") if stringleft($_StringBetween[$b],4)="/F (" then dim $_StringBetween_1=_StringBetween($_StringBetween[$b],"(",")") if not @error then $cell_1=$_StringBetween_1[0] dim $_StringBetween_0=_StringBetween($_StringBetween[$b],"<</F "," 0 R") if not @error then $cell_0=$_StringBetween_0[0] dim $aFill[1][2] = [[$cell_0, $cell_1]] _arrayadd($array_1,$aFill) endif next endif endif dim $_StringBetween_obj=_StringBetween($stringsplit[$a]," 0 obj"&chr(10)&"<<"&chr(10)&"/DL ","") if not @error Then dim $checksum=_StringBetween($stringsplit[$a],"/CheckSum (",")"&@lf) dim $_StringBetween_stream=_StringBetween($_StringBetween_obj[0],"stream"&@lf,@lf&"endstream") if not @error Then dim $StringToBinary=StringToBinary ($_StringBetween_stream[0]) Dim $Decompressed = _ZLIB_Uncompress($StringToBinary) $chars_string=BinaryToString($Decompressed) dim $StringInStr=StringInStr($stringsplit[$a]," ") dim $stringleft=stringleft($stringsplit[$a],$StringInStr-1) $stringleft=StringStripWS($stringleft,8) dim $aFill[1][2] = [[$stringleft, $chars_string]] _arrayadd($array_0,$aFill) endif endif next dim $dircreate=$fileopendialog&".Extract_Embedded_Files" dim $filecreate=false for $i=0 to ubound($array_0)-1 for $a=0 to ubound($array_1)-1 if $array_0[$i][0]=$array_1[$a][0] then if not FileExists($dircreate) then dircreate($dircreate) dim $filewrite = FileOpen($dircreate&"\"&$array_1[$a][1],2+16) filewrite($filewrite,$array_0[$i][1]) fileclose($filewrite) $filecreate=true continueloop endif next next if $filecreate=true then shellexecute($dircreate) endfunc mLipok and Zedna 1 1 To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
bdr529 Posted August 23 Share Posted August 23 @Felicitas have you tried the function? To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
Felicitas Posted August 28 Author Share Posted August 28 at first: thank you for work. second: no, it didnt work. one document returned ==> Subscript used on non-accessible variable.: Dim $Decompressed = _ZLIB_Uncompress($_StringBetween_stream[0]) Dim $Decompressed = _ZLIB_Uncompress($_StringBetween_stream^ ERROR and the other document seems to be ok but nothing happend. greets Link to comment Share on other sites More sharing options...
bdr529 Posted August 28 Share Posted August 28 @Felicitas Hi, pls can you attach the pdf file in this chat or, if you prefer, in private room? Thks p.s. : pardon for my very poor english To community goes all my regards and thanks 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