Jump to content

Issues with Saving PDF embedded on a Web Page


Recommended Posts

I am trying to save PDF which is embedded on a webpage, something similar to this "https://www.msu.edu/~urban/sme865/resources/embedded_pdf.html"

The code I am using as below, not sure whats wrong with the below script but its not working with Adobe reader versions greater than 9 and sometimes its not working even with Adobe Reader 9 as well and its random, sometimes it works and sometimes its do not.

For Adobe reader version greater than 9(10 or X) it never worked. Whats wrong here? How should I save the embedded PDF?

$pdfPath=$CmdLine[1]

$title=$CmdLine[2]

;$pdfPath="C:\TestSave\pdf\test.pdf"

;$title="Embedding a PDF File on a Web Page"

WinWait($title,"",100)

ControlFocus($title,"","")

if WinExists($title) Then

ControlSend($title,"","","^+s")

WinWait("Save a Copy...","",15)

ControlFocus("Save a Copy...","","")

if WinExists("Save a Copy...") Then

ControlSetText("Save a Copy...", "", "[CLASS:Edit; INSTANCE:1]", $pdfPath)

ControlClick("Save a Copy...", "","[CLASS:Button; INSTANCE:2]");

; Wait for overwrite dialog to appear

sleep(120)

; If overwrite message appears click Yes

ControlClick("Save As", "", "[CLASS:Button; TEXT:&Yes]");

sleep(80)

EndIf

EndIf

WinActivate("Message from webpage")

ControlClick("Message from webpage","","OK")

ConsoleWrite ("Done")

Link to comment
Share on other sites

At what point does it fail. I suggest doing a consolewrite stating the status of each step, and set a boolean. Only proceed to the next step if that bool is true.

example:

$pdfPath=$CmdLine[1]
$title=$CmdLine[2]
;$pdfPath="C:\TestSave\pdf\test.pdf"
;$title="Embedding a PDF File on a Web Page"
; Wait for window
$hPDF = WinWait($title,"",100)
If IsHWnd($hPDF) Then
 $bContinue = True
 ConsoleWrite ( "WinWait:Pass" & @CRLF )
Else
 $bContinue = False
 ConsoleWrite ( "WinWait:Fail" & @CRLF ) 
EndIf
; Activate Window
If $bContinue Then
 If WinActivate ($hPDF) Then
  ConsoleWrite ( "WinActivate:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "WinActivate:Fail" & @CRLF ) 
 EndIf
EndIf
; Send Save
If $bContinue Then
 If ControlSend($hPDF,"","","^+s") Then
  ConsoleWrite ( "ControlSend:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "ControlSend:Fail" & @CRLF ) 
 EndIf
EndIf
; Wait for save dialog
If $bContinue Then
 $hPDFSave = WinWait("Save a Copy...","",15)
 If IsHWnd($hPDFSave) Then
  ConsoleWrite ( "WinWait:$hPDFSave:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "WinWait:$hPDFSave:Fail" & @CRLF ) 
 EndIf
EndIf
; Activate Window
If $bContinue Then
 If WinActivate ($hPDFSave) Then
  ConsoleWrite ( "WinActivate:$hPDFSave:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "WinActivate:$hPDFSave:Fail" & @CRLF ) 
 EndIf
EndIf
; Set data
If $bContinue Then
 $bContinuea = ControlSetText($hPDFSave, "", "[CLASS:Edit; INSTANCE:1]", $pdfPath)
 $bContinueb = ControlClick($hPDFSave, "","[CLASS:Button; INSTANCE:2]")
 If $bContinuea And $bContinueb Then
  ConsoleWrite ( "ControlSetText/ControlClick:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "ControlSetText/ControlClick:Fail" & @CRLF ) 
 EndIf
EndIf
; Wait for save dialog
If $bContinue Then
 $hPDFSaveAs = WinWait("Save As","",15)
 If IsHWnd($hPDFSaveAs) Then
  ConsoleWrite ( "WinWait:$hPDFSaveAs:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "WinWait:$hPDFSaveAs:Fail" & @CRLF ) 
 EndIf
EndIf
; Activate Window
If $bContinue Then
 If WinActivate ($hPDFSaveAs) Then
  ConsoleWrite ( "WinActivate:$hPDFSaveAs:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "WinActivate:$hPDFSaveAs:Fail" & @CRLF ) 
 EndIf
EndIf
; Set data
If $bContinue Then
 $bContinuea = ControlFocus($hPDFSaveAs, "", "[CLASS:Button; TEXT:&Yes]")
 $bContinueb = ControlClick($hPDFSaveAs, "", "[CLASS:Button; TEXT:&Yes]")
 If $bContinuea And $bContinueb Then
  ConsoleWrite ( "ControlFocus/ControlClick:Pass" & @CRLF )
 Else
  $bContinue = False
  ConsoleWrite ( "ControlFocus/ControlClick:Fail" & @CRLF ) 
 EndIf
EndIf
WinActivate("Message from webpage")
ControlClick("Message from webpage","","OK")
ConsoleWrite ("Done")

now you can actually debug exactly what is wrong, and not just assume the prior step succeded.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks for the code jdelaney, My Script is failing when "; Wait for save dialog" after the successfully sending "ControlSend" (^+s) which is Ctrl+Shift+S, it looks like Save Dialog is not coming. I tried to do the same manually like Ctrl+Shift+S on the page and its not bringing the Save As Dialog, looks like when a PDF is embedded then Ctrl+Shift+S is not going to work to save the PDF unless the focus is on the embedded PDF. If I focus on Embedded PDF then Ctrl+Shift+S is working and its showing the Save As dialog. How to get the focus on the Embedded PDF through the script? Or is there any other way to Save a PDF which is embedded.

The output for the above from console is

WinWait:Pass

WinActivate:Pass

ControlSend:Pass

WinWait:$hPDFSave:Fail

Done>Exit code: 0 Time: 15.822

Just an FYI, if my web page is like http://michaelo.pl/test_pdf/test.pdf which is having only PDF rather than as an embedded element on a web page, I am able to get the Save As dialog by using Ctrl+Shift+S. My issue is only when PDF is Embedded on a web page like https://www.msu.edu/~urban/sme865/resources/embedded_pdf.html.

Link to comment
Share on other sites

Thanks jdelaney, I tried as below, but still it didnt worked. I have a question, if the handler I have is of the IE and if I use File and Save As, then I would end up saving HTML rather than embedded PDF right? So I am trying to find how can I get the handle for PDF or get focus on PDF.

If I focus(Click) manually on the PDF and execute the AutoIt Script, then its saving the PDF. I am trying to find on how to focus on the embedded PDF.

; Menu Select On Window
If $bContinue Then
If WinMenuSelectItem ($hPDF, "","&File", "Save &As...") Then
ConsoleWrite ( "WinMenuSelectItem:Pass" & @CRLF )
Else
$bContinue = False
ConsoleWrite ( "WinMenuSelectItem:Fail" & @CRLF )
EndIf
EndIf

;I tried WinMenuSelectItem ($title, "","&File", "Save &As...") as well, but in vain
Link to comment
Share on other sites

Is the PDF embedded in a <frame> or <iframe> node?

If so, you can use the _IE functions, to focus on that node (_IEFrameGetCollection and _IEAction($oFrame, "Focus")), and then send the "^+s"

Also, IE is slow to react, so i would up the key down delay: AutoItSetOption("SendKeyDownDelay", 40)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks jdelaney, Unfortunately its not a frame or iframe, we have used just plain embed tag as attached. Can I still make use of _IE functions? I am novice, thats why these many questions

<center><embed src="/intro.pdf" type="application/pdf" width="98%" height="450" /></center>
Link to comment
Share on other sites

You could append the 'SRC' data into the end of the url, that should get the pdf directly. Or, you can still use IE functions to focus on the <embed>, and do the same...you should go the src route though.

If you go the other route, then something like this will work (where only 1 <embed> node is present.

$oIE = _IEAttach("IFrameTest")
$hwnd = _IEPropertyGet ($oIE, "hwnd")
WinActivate($hwnd)
$oEmbed = _IEGetObjByName ($oIE, "embed")
_IEAction ($oEmbed, "Focus")
Send ("^+s")

Above is an example where IE is open to the following .htm file (sub in your own PDF file for testing):

<html>

<Title>IFrameTest</Title>

<head></head>

<body>

<form>

<center><embed src="LOCAL DIRECTORY AND PDF FILE" type="application/pdf" width="98%" height="450" /></center>

</form>

</body>

</html>

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks jdelaney, GMK, ivan.

jdelaney: I cannot use src route as in my scripts I need to make sure the PDF is embedded on Page or not, so I need to follow the other approach you suggested. When I tried your suggestion, I am getting error as below

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: embed, Index: 0)

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

; As per jdelaney
$oIE = _IEAttach($title)
$hwnd = _IEPropertyGet ($oIE, "hwnd")
WinActivate($hwnd)
$oEmbed = _IEGetObjByName ($oIE, "embed")
_IEAction ($oEmbed, "Focus")
Send ("^+s")

ivan: By using your approach, I am almost successful, but I have issue with finding the correct Instance Id, the pages I gave was just an example and in my webpage the elements are dynamic and I am not sure if I can hard code the Instance id or not. In my Case it worked only when I changed instance id to 16 as below, any suggestions on how to get the proper instance id?

WinActivate($hPDF)

if ControlClick($hPDF, "", "[CLASS:AVL_AVView;INSTANCE:16]") Then
  ConsoleWrite ( "ControlClick:Pass" & @CRLF )
else 
  ConsoleWrite ( "ControlClick:Fail" & @CRLF )
EndIf    
if WinActivate($hPDF) Then
  ConsoleWrite ( "WinActivate:Pass" & @CRLF )
else 
  ConsoleWrite ( "WinActivate:Pass" & @CRLF )
EndIf

if BlockInput($nDisable) Then
  ConsoleWrite ( "BlockInput:Pass" & @CRLF )
else 
  ConsoleWrite ( "BlockInput:Pass" & @CRLF )
endif

if SendKeepActive($hPDF) Then
  ConsoleWrite ( "SendKeepActive:Pass" & @CRLF )
Else
  ConsoleWrite ( "SendKeepActive:Pass" & @CRLF )
EndIf

if Send("^+S") Then
  ConsoleWrite ( "Send:Pass" & @CRLF )
else 
  ConsoleWrite ( "Send:Pass" & @CRLF )
EndIf

if SendKeepActive("") Then
  ConsoleWrite ( "SendKeepActive:Pass" & @CRLF )
Else
  ConsoleWrite ( "SendKeepActive:Pass" & @CRLF )
EndIf
if BlockInput($nEnable) Then
  ConsoleWrite ( "BlockInput:Pass" & @CRLF )
Else
  ConsoleWrite ( "BlockInput:Pass" & @CRLF )
EndIf
Link to comment
Share on other sites

The $title variable needs to be the IE tab text, if you use the default 2nd Param of the function.

Or, since you already have the hwnd of the browser, you can do:

$oIE = _IEAttach($whatevertheHWNDvariableis, "HWND")

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thanks jdelaney, I tried as per your suggestion as well but in vain, I am still getting errors as below

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: embed, Index: 0)

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

$hPDF = WinWait($title,"",100)
$oIE = _IEAttach($hPDF, "HWND")
;$oIE = _IEAttach($title) I tried this as well
$hwnd = _IEPropertyGet ($oIE, "hwnd")
WinActivate($hwnd)
$oEmbed = _IEGetObjByName ($oIE, "embed")
;$oEmbed = _IEGetObjByName ($hwnd, "embed") I tried this as well
_IEAction ($oEmbed, "Focus")
Send ("^+s")
Link to comment
Share on other sites

Seems that the function is unable to find the embed object. Is it wrapped in a <frame> or <iframe>?

You might need to post the html, make sure to wrap it.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

jdelaney its not wrapped in a frame or iframe. I have attached the HTML

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
 
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
 
<html>
 
<head>
 
 
<link rel="SHORTCUT ICON" href="/images/mycorpico/favicon.ico" />
 
<link rel="stylesheet" href="/scripts/mycorpstylesheet.css" type="text/css"/>
 
 
 
 
<title>mycorp Policy</title>
 
<script language="javascript" src="/scripts/focus.js"></script>
 
<script language="javascript" src="/scripts/customAlert.js"></script>
 
<script language="javascript" src="/scripts/pagetransition.js"></script>
 
<script language="javascript" src="/scripts/jquery-1.3.2.min.js"></script>
 
 
 
 
 
</head>
 
 
<body>
 
<div id="pageTransitionDiv"></div>
 
<a name="Top"></a>
 
 
<div id="container">
 
 
<div id="header">
 
 
 
 
 
 
 
 
 
 
 
 
 
<!-- IE and Firefox implement css float and clear so differently, we had to include a bit of
 
browser detection to prevent the header from disappearing completely in non-IE browsers -->
 
<script type="text/javascript">
 
function setTitle() {
 
document.title = "mycorp Policy";
 
}
 
if (navigator.appName == "Microsoft Internet Explorer") {
 
document.writeln('<style type="text/css"> .logoGraphic { clear: right; float: left; }</style>');
 
}
 
</script>
 
<div id="logo_menu_storm">
 
<div id="menu_storm" style="float: right;">
 
<div id="menu" class="topmostMenu" style="float: right; padding-bottom: 35px; ">
 
<table >
 
<tr valign="top" class="layoutText" width="100%">
 
</tr>
 
</table>
 
</div>
 
</div>
 
<div id="logo_mycorp"class="logoGraphic"></div>
 
</div>
 
<script>
 
var CounterX = 60*60; //60 minutes until timeout
 
var CounterY = 1; //second countdown
 
function startClock(){
 
CounterX = CounterX-CounterY;
 
setTimeout("startClock()", 1000);
 
if (CounterX % 60 == 0 && CounterX / 60 < 6) {
 
document.getElementById("iframe1").style.visibility = (CounterX == 0) ? "hidden" : "visible";
 
document.title = CounterX / 60 + " minute";
 
timeoutMessage = "<img src='/images/vic_pop_up.jpg' width='436' height='208'/>";
 
timeoutMessage += "<div id='timeoutMessage'>";
 
timeoutMessage += "Your session is about to expire due to lack of activity. As a security precaution your session will expire in ";
 
timeoutMessage += CounterX / 60+" minute";
 
if (CounterX > 60) {
 
timeoutMessage += "s";
 
document.title += "s";
 
}
 
timeoutMessage += ". Click OK to continue your session.";
 
timeoutMessage += "<br/><a href='#' onclick='javascript:document.location.reload()'><br/><img src='/images/vic_pop_up_button.gif' border='0'/></a>";
 
timeoutMessage += "</div>";
 
document.title += " until Logout";
 
tempId = document.getElementById("timeout");
 
tempId.innerHTML = timeoutMessage;
 
tempId.style.visibility = (CounterX == 0) ? "hidden" : "visible";
 
window.focus();
 
if (CounterX == 0) {
 
CounterX = 6000000;
 
setTitle();
 
alert("Due to lack of activity, you have been logged off.");
 
window.location="/Logout.do";
 
}
 
}
 
}
 
startClock();
 
</script>
 
<table border="0" cellspacing="0" cellpadding="0" width="100%">
 
<tr>
 
<td halign="left">
 
<div class="layoutText">
 
You are currently logged in as inquoting&nbsp;&nbsp;&nbsp;&nbsp;<a href="/NeedAPassword.do">(<u>Need a new password?</u>)</a>
 
</div>
 
</td>
 
<td halign="right">
 
</td>
 
</tr>
 
</table>
 
<div id="SpecialtyIcons" class="loginLink" style="float: right; height: 25px; width:600px; margin: -105px 0px 0px 0px; position: relative; text-align: center">
 
<div id="navcontainer">
 
<ul id="navlist">
 
<br/>
 
<li>
 
<a href="#" class="" onclick="window.open('http://MySpecialtyProducts.com','_blank','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=750,height=520,top=5,left=30');"><img src="/images/ps_mycorp_whiteorange.gif" border="0" width="183" height="62"/><br /></a>
 
</li>
 
</ul>
 
</div>
 
</div>
 
<script>
 
if (document.all) {
 
var picture=document.all.SpecialtyIcons.style;
 
picture.top=15;
 
}
 
</script>
 
 
</div>
 
<div id="tabs">
 
 
 
 
 
 
 
 
 
 
 
 
<script src="/scripts/dw_viewport.js" type="text/javascript"></script>
 
<script src="/scripts/menu.js" type="text/javascript"></script>
 
<table cellSpacing="0" cellPadding="0" width="100%" border="0" background="/images/top_bg.gif">
 
<tbody>
 
<tr>
 
<td background="/images/top_bg.gif" height="28">
 
<table cellSpacing="0" cellPadding="0" border="0">
 
<tbody>
 
<tr>
 
<td background="/images/top_bg.gif">&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/Home.do" onmouseout="menuLayers.hide()">Home</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/ecomm/AgentCenter.do" onmouseout="menuLayers.hide()">Agent Center</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/Home.do" onmouseover="menuLayers.show('menu.support', event)" onmouseout="menuLayers.hide()">Support</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/inquiry/Inquiry.do" onmouseover="menuLayers.show('menu.Inquiry', event)" onmouseout="menuLayers.hide()">Inquiry</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/payments/Payment.do" onmouseover="menuLayers.show('menu.Payments', event)" onmouseout="menuLayers.hide()">Payments</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/endorsements/ShowSelection.do?entry=init" onmouseout="menuLayers.hide()">Endorsements</a>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;</td>
 
<td background="/images/top_bg.gif" noWrap height="28">
 
<img alt="" hspace="0" src="/images/top_left.gif" align="middle" width="8" height="28" border="0"/>
 
</td>
 
<td align="center" background="/images/top_middle.gif" nowrap>
 
<a href="/pos/agent/NewBusiness.do" onmouseover="menuLayers.show('menu.Pos', event)" onmouseout="menuLayers.hide()">New Business</a>
 
</td>
 
<td background="/images/top_bg.gif" nowrap height="28">
 
<img alt="" hspace="0" src="/images/top_right.gif" align="middle" width="8" height="28" border="0"/>
 
</td>
 
<td background="/images/top_bg.gif">&nbsp;</td>
 
<td background="/images/top_bg.gif" nowrap>
 
<a href="/ContactInfo.do" onmouseover="menuLayers.show('menu.ContactInfo', event)" onmouseout="menuLayers.hide()">Contact</a>
 
</td>
 
<td align="right" background="/images/top_bg.gif" height="28">&nbsp;</td>
 
</tr>
 
</tbody>
 
</table>
 
</td>
 
<td align="RIGHT" background="/images/top_bg.gif">
 
<table border="0" cellspacing="0" cellpadding="0" background="/images/top_bg.gif">
 
<tr>
 
<td height="28" >&nbsp;</td>
 
<td><a href="/Logout.do">Logout</a></td>
 
<td>&nbsp;<b>&#183;</b>&nbsp;</td>
 
<td noWrap><a href="/SiteMap.do">Site Map</a></td>
 
<td>&nbsp;<b>&#183;</b>&nbsp;</td>
 
<td><a href="/Help.do">Help</a></td>
 
<td>&nbsp;</td>
 
</tr>
 
</table>
 
</td>
 
</tr>
 
</tbody>
 
</table>
 
<div class="menu" id="menu.support" >
 
<a href="/admin/ListReq.do?dispatch=searchRequest">Request Admin</a>
 
<a href="/admin/ListUsers.do?dispatch=clear">User Name Admin</a>
 
<a href="/admin/ListAgencies.do?dispatch=clear">Agency Admin</a>
 
<a href="/support/agencyTransfer/initialize.do">Agency Transfer</a>
 
<a href="/admin/TIPSGroup.do">TIPS Agent Group</a>
 
<a href="/support/cache.do">Cache Admin</a>
 
<a href="/support/datamover.do">Data Admin</a>
 
<a href="/support/masterDate.do">Master Date</a>
 
<a href="/pay/ModifyTab.do?">OCP Admin</a>
 
<a href="/support/queueAdmin.do">Queue Admin</a>
 
<a href="/support/mvrhold.do">MVR Hold Admin</a>
 
<a href="/support/policyTransfer.do">AS400 Policy Transfer</a>
 
<a href="/support/reports/clueccrreportgenerator.do">CLUE CCR Report Generator</a>
 
<a href="/support/reports/mvrreportgenerator.do">MVR Report Generator</a>
 
</div>
 
<div class="menu" id="menu.Inquiry" >
 
<a href="/inquiry/Inquiry.do?isFindAPolicy=true">Find a Policy</a>
 
<a href="/inquiry/Inquiry.do?isFindAPolicy=false">View Policy</a>
 
</div>
 
<div class="menu" id="menu.Payments" >
 
<a href="/payments/Payment.do?isFindAPolicy=true">Find a Policy</a>
 
<a href="/payments/Payment.do?isFindAPolicy=false">Make a Payment</a>
 
<a href="/payments/PolicySearchFromEFT.do">Customer EFT</a>
 
</div>
 
<div class="menu" id="menu.Pos" >
 
<a href="/pos/agent/new.do">New Quote</a>
 
<a href="/pos/agent/find.do">Find Quote</a>
 
<a href="/pos/agent/defaults.do">Defaults</a>
 
<a href="/pos/agent/ComparativeRaterSupport.do">Comparative Rater Support</a>
 
</div>
 
<div class="menu" id="menu.ContactInfo" >
 
<a href="/ContactInfo.do">Contact</a>
 
<a href="/FindAgency.do">Find a mycorp Agency</a>
 
<a href="/BecomeAgent.do">Become an Agent</a>
 
<a href="/Feedback.do">Feedback</a>
 
</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
<script src="/scripts/dw_viewport.js" type="text/javascript"></script>
 
<script src="/scripts/menu.js" type="text/javascript"></script>
 
<table cellSpacing="0" cellPadding="0" width="100%" border="0" background="/images/bottom_bg.gif">
 
<tbody>
 
<tr>
 
<td background="/images/bottom_bg.gif" height="28">
 
<table cellSpacing="0" cellPadding="0" border="0">
 
<tbody>
 
<tr>
 
<td background="/images/bottom_bg.gif">&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosPolicy()" onmouseout="menuLayers.hide()">Policy</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosDrivers()" onmouseout="menuLayers.hide()">Drivers</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosVehicles()" onmouseout="menuLayers.hide()">Vehicles</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosRegOwner()" onmouseout="menuLayers.hide()">Registered Owner</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosPriorCoverage()" onmouseout="menuLayers.hide()">Prior Coverage</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosQuestionnaire()" onmouseout="menuLayers.hide()">Questionnaire</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosReports()" onmouseout="menuLayers.hide()">Reports</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosSummary()" onmouseout="menuLayers.hide()">Summary</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td background="/images/bottom_bg.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosPayment()" onmouseout="menuLayers.hide()">Payment</a>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;</td>
 
<td background="/images/bottom_bg.gif" noWrap height="28">
 
<img alt="" hspace="0" src="/images/bottom_left.gif" align="middle" width="8" height="28" border="0"/>
 
</td>
 
<td align="center" background="/images/bottom_middle.gif" nowrap>
 
<a href="javascript:void()" onclick="return onclickPosForms()" onmouseout="menuLayers.hide()">Forms</a>
 
</td>
 
<td background="/images/bottom_bg.gif" nowrap height="28">
 
<img alt="" hspace="0" src="/images/bottom_right.gif" align="middle" width="8" height="28" border="0"/>
 
</td>
 
<td background="/images/bottom_bg.gif">&nbsp;</td>
 
<td align="right" background="/images/bottom_bg.gif" height="28">&nbsp;</td>
 
</tr>
 
</tbody>
 
</table>
 
</td>
 
<td align="right" background="/images/bottom_bg.gif" height="28">
 
<table cellSpacing="0" cellPadding="0" border="0">
 
<tbody>
 
<tr>
 
<td>&nbsp;</td>
 
<td nowrap>
 
<a href="\pos\agent\new.do" onclick="return onclickPosNew()" onmouseout="menuLayers.hide()">New</a>
 
</td>
 
<td>&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td nowrap>
 
<a href="\pos\agent\find.do" onclick="return onclickPosFind()" onmouseout="menuLayers.hide()">Find</a>
 
</td>
 
<td>&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td nowrap>
 
<a href="\pos\agent\defaults.do" onclick="return onclickPosDefaults()" onmouseout="menuLayers.hide()">Defaults</a>
 
</td>
 
<td>&nbsp;<B>&#183;</B>&nbsp;</td>
 
<td nowrap>
 
<a href="javascript:void()" onclick="return onclickPosSaveExit()" onmouseout="menuLayers.hide()">Save &amp; Exit</a>
 
</td>
 
<td align="right" background="/images/bottom_bg.gif" height="28">&nbsp;</td>
 
</tr>
 
</tbody>
 
</table>
 
</td>
 
</tr>
 
</tbody>
 
</table>
 
 
</div>
 
<div id="timeout">
 
<a href='#' onclick='javascript:document.location.reload()'><img src='/images/vic_pop_up_button.jpg' border='0'/></a>
 
</div>
 
<IFRAME id="iframe1" name="iframe1" src="/images/plusInvisible.gif"
 
scroll=none style="width:455px;height:225px;position:absolute;
 
left:51%;top:250px;border:none;margin-left:-225px; margin-top:-104px;z-index:1;filer:mask();visibility:hidden;"></iframe>
 
<div id="content">
 
 
 
 
 
 
<div id="displaybody">
 
 
 
 
<SCRIPT LANGUAGE="Javascript" SRC="/scripts/pos/nav.js"></SCRIPT>
 
<form name="posQuoteForm" method="POST" action="/pos/ny/ppa/agent/pos.do" onsubmit="return onPageTransition();">
 
<input type="hidden" name="posPage" value="forms">
 
<input type="hidden" name="posNext" value="forms">
 
<input type="hidden" name="posAction" value="">
 
<input type="hidden" name="posFocus" value="">
 
<input type="hidden" name="posMode" value="A">
 
<SCRIPT LANGUAGE="Javascript" SRC="/scripts/pos/nav.js"></SCRIPT>
 
<SCRIPT LANGUAGE="Javascript" SRC="/scripts/pos/agent/standard/ppa/header.js"></SCRIPT>
 
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
 
<TR>
 
<TD WIDTH="100">State/Product:</TD>
 
<TD WIDTH="250">
 
<A HREF="http://mycorpPolicy-com-test01.rags.net/docs/ny/ny38geuwgd0612.pdf" target="new">NY Raaga General Agent's Guide</A>
 
</TD>
 
<TD WIDTH="90">Applicant:</TD>
 
<TD WIDTH="200">
 
<input type="hidden" name="applicantFirstName" value="PHILIP">
 
<input type="hidden" name="applicantMiddleName" value="">
 
<input type="hidden" name="applicantLastName" value="CUNNINGHAM">
 
<input type="hidden" name="applicantSuffixName" value="">
 
<input type="hidden" name="firstName" value="PHILIP">
 
<input type="hidden" name="middleName" value="">
 
<input type="hidden" name="lastName" value="CUNNINGHAM">
 
<span id="applicantName">
 
PHILIP&nbsp;
 
CUNNINGHAM&nbsp;
 
</span>
 
</TD>
 
<TD WIDTH="75">Quote #:</TD>
 
<TD WIDTH="75">
 
144NY75411
 
</TD>
 
</TR>
 
<TR>
 
<TD>Agency Code:</TD>
 
<TD>
 
9319986
 
</TD>
 
<TD>Quote Name:</TD>
 
<TD>
 
NB10035
 
</TD>
 
<TD align="center" COLSPAN="2">
 
<SCRIPT LANGUAGE="Javascript"><!--
 
function onSwitchToQuote()
 
{
 
if (confirm("Switch back to the quote?"))
 
{
 
enablePolkLockedFields();
 
posQuoteForm.posAction.value = "GotoQuote";
 
onPageTransition();
 
posQuoteForm.submit();
 
}
 
return false;
 
}
 
--></SCRIPT>
 
<a href="javascript:void()" onclick="return onSwitchToQuote()">Switch to Quote</a>
 
&nbsp;
 
<a href="/pos/agent/notes.do" target="new">Notes</a>
 
</TD>
 
</TR>
 
</TABLE>
 
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
 
<TR CLASS="tableHeader">
 
<TD width="33%">
 
Forms - Application
 
</TD>
 
<TD align="center" width="34%">
 
APPLICATION MODE
 
</TD>
 
<TD width="33%" align="right">
 
&nbsp;
 
</TD>
 
</TR>
 
</TABLE>
 
<br/>
 
<TABLE ALIGN="CENTER" cellpadding="0" cellspacing="0">
 
<TR class='tableRow1' >
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<INPUT TYPE="checkbox" NAME="form" VALUE="application" checked="checked" />
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<B>Application</B>
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
</TR>
 
<TR >
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<INPUT TYPE="checkbox" NAME="form" VALUE="idcard" checked="checked" />
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<B>Temporary ID Card(s)</B>
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
</TR>
 
<TR class='tableRow1' >
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<INPUT TYPE="checkbox" NAME="form" VALUE="receipt" checked="checked" />
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<B>Receipt</B>
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
</TR>
 
<TR >
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<INPUT TYPE="checkbox" NAME="form" VALUE="ccpa" />
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<B>Card Payment Authorization</B>
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
</TR>
 
<TR class='tableRow1' >
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<INPUT TYPE="checkbox" NAME="form" VALUE="efta" />
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
<TD>
 
<B>Customer EFT Authorization</B>
 
</TD>
 
<TD>
 
&nbsp;
 
</TD>
 
</TR>
 
</TABLE>
 
<BR>
 
<CENTER>
 
<input type="submit" name="continueButton" tabindex="1" value="Display Selected Forms" class="buttonbold">
 
<input type="button" name="saveExitButton" tabindex="2" value="Save &amp; Exit" onclick="onclickPosSaveExit()">
 
</CENTER>
 
</form>
 
<BR>
 
<center><embed src="/pos/forms.pospdf?form=application&form=idcard&form=receipt&overrideActiveIdCard=true" type="application/pdf" width="98%" height="450" /></center>
 
<BR>
 
<br>
 
 
</div>
 
 
<div id="footer">
 
 
 
 
 
 
 
 
 
<style>
 
.centerNoMargin {
 
text-align:center;
 
margin-top: 0px;
 
margin-bottom: 0px;
 
}
 
</style>
 
 
<br />
 
&nbsp;&nbsp;
 
<a href="/Home.do"><u>Home</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/ecomm/AgentCenter.do"><u>Agent Center</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/Home.do"><u>Support</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/inquiry/Inquiry.do"><u>Inquiry</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/payments/Payment.do"><u>Payments</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/endorsements/ShowSelection.do?entry=init"><u>Endorsements</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/pos/agent/NewBusiness.do"><u>New Business</u></a>
 
&nbsp;&nbsp;
 
<strong>&#183;</strong>&nbsp;&nbsp;
 
<a href="/ContactInfo.do"><u>Contact</u></a>
 
<br />
 
Copyright© 2008
 
<br />mycorp Policy,
 
 
<a href="/Privacy.do">Internet Privacy</a>&nbsp;&nbsp;
 
<a href="/Terms.do">Terms &amp; Conditions</a>&nbsp;&nbsp;
 
<a href="/Copyright.do">Copyright Notice</a>
 
 
</div>
 
 
 
 
 
 
 
</div>
 
 
</div>
 
 
</body>
 
</html>

Link to comment
Share on other sites

Using the WinHttp UDF, I came up with this as an example:

#include <WinHttp.au3>
$sURL = "https://www.msu.edu/~urban/sme865/resources/embedded_pdf.html"
$aSplit = StringSplit($sURL, "/")
$sPath = StringReplace($sURL, $aSplit[UBound($aSplit) - 1], "")
$avCracked = _WinHttpCrackUrl($sURL)
$hOpen = _WinHttpOpen() ; Initialize and get session handle
$hConnect = _WinHttpConnect($hOpen, $avCracked[2]) ; Get connection handle
$hRequest = _WinHttpOpenRequest($hConnect, "GET", $avCracked[6] & $avCracked[7]) ;Open HTTP request
_WinHttpSendRequest($hRequest) ;Send HTTP request
_WinHttpReceiveResponse($hRequest) ;Receive HTTP response
$sHTML = ""
Do
$sHTML &= _WinHttpReadData($hRequest) ;Read HTTP data (source code)
Until @error
_WinHttpCloseHandle($hRequest)
$aEmbed = StringRegExp($sHTML, '<embed src="(.*?)".*?>', 3)
For $iCounter = 0 To UBound($aEmbed) - 1
If Not StringInStr($aEmbed[$iCounter], "//") Then $aEmbed[$iCounter] = $sPath & $aEmbed[$iCounter]
$avCracked = _WinHttpCrackUrl($aEmbed[$iCounter])
$hRequest = _WinHttpOpenRequest($hConnect, Default, $avCracked[6] & $avCracked[7])
_WinHttpSendRequest($hRequest)
_WinHttpReceiveResponse($hRequest)
If _WinHttpQueryDataAvailable($hRequest) Then
$bData = ""
While 1
$bChunk = _WinHttpReadData($hRequest, 2) ; read binary
If @error Then ExitLoop
$bData = _WinHttpBinaryConcat($bData, $bChunk) ; concat two binary data
WEnd
$sDestination = @ScriptDir & "/" & StringFormat("%05d", Random(1, 999999)) & ".pdf"
$hFile = FileOpen($sDestination, 26)
FileWrite($hFile, $bData)
FileClose($hFile)
_WinHttpCloseHandle($hRequest)
ShellExecute($sDestination)
Else
MsgBox(48, "Error occurred", "No data available. " & @CRLF)
EndIf
Next
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...