Puppeteer download embedded PDF file - google-chrome-devtools

I am visiting a page which has a link for a pdf file. The link opens a new tab and its content look like this:
<html>
<head></head>
<body style="height: 100%; width: 100%; overflow: hidden; margin:0px; background-color: rgb(38, 38, 38);">
<embed name="B4133D167D3B030DC294D8CA8F6FC5FE" style="position:absolute; left: 0; top: 0;" width="100%" height="100%" src="about:blank" type="application/pdf" internalid="B4133D167D3B030DC294D8CA8F6FC5FE">
</body>
</html>
Embedded is the pdf I would like to download.
The only solution I have come up so far is manually changing the default behavior in chrome://settings/content/pdfDocuments to download the PDF, but every time I restart the browser, it resets. Plus, I can't test this solution on headless mode...
I tried launching chromium with the --print-to-pdf flag found in this list, with no luck.
Does anyone know, if puppeteer can launch chromium with the "download PDF" as the default behavior, without tying it to a profile?
Does anyone know if there is another solution for puppeteer to download embedded pdfs?
Thanks.

I got to a solution that does the job for now using a chrome profile.
I created a new profile in my browser. I set the downloads directory and the default behavior for PDFs to "download PDFs".
I created a new folder somewhere for chromium to use as its data directory.
I pasted the previously created profile folder named 'Profile 2' inside the newly created folder.
Then on puppeteer I launched chromium with the following flags:
--user-data-dir=newly_created_folder
--profile-directory=Profile 2
I had to set both because when chromium first starts, it populates the user dir with its own files.
Every time the browser restarts, the file SingletonLock that sits on the 'user-data-dir' foder has to be overwritten. I ended up deleting the file before every execution of puppeteer.launch(options).
For this to work on headless mode I set the parameter headless: 'chrome' and not true.
This works on puppeteer 17 and 18. I have tested it also in versions 14,15 and 16 with no luck.
Still, if anyone knows a better solution to download embedded PDFs, please share..
Thanks

Related

The origin server did not find a current representation for the target resource or is not ... error when running jsp page

I am trying to run this code in my Eclipse JSP dynamic web page. But on running it in the Tomcat Server Version 9.0, I am getting an error 404 message. Error Message-The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. I was trying to include a header page in my other jsp page in this code.
So far I have tried switching the location of the server via server properties. I have also checked the Use Tomcat installation checkbox in Server Locations. Still, I am getting this error.
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="http://localhost:8080/HelloJSP/HeaderPage.jsp" />
</body>
</html>
If the page is under WEB-INF folder, an 404 error message might appear. I had the similar problem.
I put the pages under the WebContent folder instead. In Eclipse, the location of files may look confusing. Sometimes right click the file and look at their properties for paths. Just like below :
As you can see, even though pages look like they are under WEB-INF, they are under WebContent. Then, you won't see 404. And you can put the url to see your page in your browser.
If this doesn't help, then check your Web Project Settings.
Right-click your project, go to Properties, and find Web Project Settings.
Can you see my Context root "/" ? If I want to run my jquery.html page, I just type
localhost:8080/jquery.html
If you change your context root to "test", then you type :
localhost:8080/test/jquery.html
Don't forget to clean your Tomcat after changing your context root. Otherwise, it won't apply changes.
Thank You for your help :)
Actually, this problem was solved once I removed all the server from eclipse and switched it off. Then I readded the sever once again and it started working. Still not able to find the reason this error was caused but it was fixed by using the above method.

assets images are not loading in ionic 3 in development mode Ionic Serve

I am using IONIC 3.20.1 and I am facing the issue, assets images are not rendering on the browser or device as well.
The folder structure is the same while creating the sample project inside the src folder then assets then imgs.
but images are not loading on the browser after the ionic serve. I tried all the paths like below.
<img float-right src="../assets/imgs/user.png" />
<img float-right src="../../assets/imgs/user.png" />
<img float-right src="/assets/imgs/user.png" />
<img float-right src="./assets/imgs/user.png" />
<img float-right src="assets/imgs/user.png" />
but nothing is working. Please help me out here.
Please check the link also.
I tried all the things like renaming name of the images, folder name change. but didn't work in case of "Ionic Serve".
After that, I Installed the Cordova Tools extension for Visual Studio
Code.
Added the configuration file. (launch.json)
And then added browser platform using the command 'ionic cordova platform add browser'
At last, debug the application with "RunBrowser" option
Now the images are rendered properly
Scrrenshot http://prntscr.com/nrw5fr

javascript library not loaded in ionic

Im including the google cast external javascript library. When I run with ionic serve it works good, but when I run the app in the phone, the library is not loaded. Debugging can see that :
https://cdn-enterprise.discourse.org/ionicframework/uploads/default/original/3X/a/d/ad4c985f45c1c538bdfbfbb02d10141b6929e1d5.png
The "http" is replaced by "file"!
I tried to include the libraries with that code:
script src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1">
and with type="text/javascript" added; but all codes replaces http by file, and the library is not loaded.
Any suggestions?
When you run the app do not add cdn files starting with "//:", add them like "http://".
If its possible download those files and keep them in directory, after that give directory path to file.
e.g. <script type="text/javascript" src="assets/js/library.js">

Using Eclipse/Aptana, points to wrong location when previewing in browser

I'm just starting out with Eclipse Luna with Aptana plugin installed.
I've just written a basic .html file, and when I run the page using the built-in web server, it opens Firefox with the following URL:
http://127.0.0.1:8020/RemoteSystemsTempFiles/opening_page.html
This is unsuccesful, with Firefox displaying the message: Unable to connect
Whereas I have the file stored elsewhere on my hard drive. how do I point it in the right direction?
Thanks.
I found you can find the html file in your file explorer and open it manually or just type in the location the file is stored at on your hard drive into the address box. This worked for me with a html file and a css that changed the color. I am not sure if there is a setting somewhere to change the path it enters into Firefox.

Symfony 2 without CSS in FF and images in IE on server

I deployed my site to a OVH server with filezilla following the steps in this tutorial http://pilvee.com/blog/deploiement-symfony2/
After deployment I find that my site works fine but without CSS content in FF and Chrome, so when I check in firebug I find all CSS styles are loaded correctly but empty without content,also JS file are loaded with content and all images too.In IE I have the style that works fine but no image is loaded ??I work on Ubuntu and I use a Virtual Machine to use IE...
I published my asset with assets:install web,I almost did everything, I cleared the cache and I changed the access rights of all files, I specify for files => 705, the CSS and JS => 604,finally I put everything to 777 but still no change ...
That get me crazy really,i dont know what i do to get my website work,i thinked about rebuild my website again,I liked symfony 2 before but now I hate it...
An idea?
Are you using assetic to manage your assets ?
$ app/console assetic:dump
Maybe
$ php app/check.php
can tell you more about your host configuration.