# Unable to download pdf from blob url

**URL:** <https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243>\
**Category:** Miscellaneous\
**Created:** [March 1, 2024, 10:40pm UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243 "2024-03-01T22:40:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![renuka.srivastav](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/renuka.srivastav/32/23870_2.png) [@renuka.srivastav](https://forum.katalon.com/u/renuka.srivastav)\
**Post date:** [March 1, 2024, 10:40pm UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243/1 "2024-03-01T22:40:38Z")

</div>

Hi All,

Need urgent help to download a pdf file from blob url.  
When i click on the button to access the file,a new tab is opened for the pdf with blob url. something like this:  
blob:[https://uncd215.duckcreekondemand.com/7c3bc4d2-74a4-4289-a645-6241c622f200](https://uncd215.duckcreekondemand.com/7c3bc4d2-74a4-4289-a645-6241c622f200)

I’m unable to save the file using keyword simulation also, Katalon is not recognizing the keystrokes.  
Have tried many solutions, but nothing helped.  
Please help.

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [March 4, 2024, 10:45am UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243/2 "2024-03-04T10:45:53Z")

</div>

Hi,

I found this similar discussion: [Read PDF having URL starting with blob - #13 by kazurayam](http://forum.katalon.com/t/read-pdf-having-url-starting-with-blob/24095/13). Can you please take a look?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 4, 2024, 11:35pm UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243/3 "2024-03-04T23:35:40Z")

</div>

> [@Elly\_Tran](#):
>
> I found this similar discussion: [Read PDF having URL starting with blob - #13 by kazurayam](http://forum.katalon.com/t/read-pdf-having-url-starting-with-blob/24095/13).

I don’t think @renuka.srivastav need to dig into my previous post about `"data:"` URL. No need to work on `java.net.URL` class for `"blob:"` URL.

* * *

@renuka.srivastav has a string somewhere in the target web page something like:

```auto
blob:https://uncd215.duckcreekondemand.com/7c3bc4d2-74a4-4289-a645-6241c622f200

```

Then her/his test script should be able to extract the string to save it into a Groovy variable. The script wants to **strip the prefix “`blob:`” off**. Then it will get a string as https URL:

```auto
https://uncd215.duckcreekondemand.com/7c3bc4d2-74a4-4289-a645-6241c622f200

```

With this `https:` URL, the test script should be able to get access to the resource easily.

I would recommend Apache HttpClient API to download and save a binary file like PDF and PNG. Katalon’s built-in keywords `WS.*` can not save binary files properly. See [Download the image file via Rest API - #3 by kazurayam](http://forum.katalon.com/t/download-the-image-file-via-rest-api/120898/3) for a sample code.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 5, 2024, 1:14am UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243/4 "2024-03-05T01:14:22Z")

</div>

How to download PDF files in Katalon Studio? — this seems to be a FAQ that has never been resolved. I would propose a solution here. I have made a GitHub repository that demonstrates it

> **[GitHub - kazurayam/ks\_reading\_pdf\_from\_blob\_url: https://forum.katalon.com/t/unable-to-download-pdf...](https://github.com/kazurayam/ks_reading_pdf_from_blob_url)**
>
> https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243

* * *

## Problem to solve

On the Internet, some web resources are distributed via URL prefixed with `blob:` scheme. The [original poster](http://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243) found an example `blob:https://uncd215.duckcreekondemand.com/7c3bc4d2-74a4-4289-a645-6241c622f200`. She/he wanted to develop a Katalon Test Case which downloads the PDF file to save into local disk, but the PO experienced a difficulty. The `blob:` URL requires a special treatment.

What is `blob` URL, why is it used? — There is a nice Stackoverflow thread that explain it:

> <https://stackoverflow.com/questions/30864573/what-is-a-blob-url-and-why-it-is-used>

## Solution

Extract the string as blob URL out of web page, trim off the prepended `blob:` string. Out of the blob URL, you can extract an URL string that starts with `https://` string. Once you can grasp an ordinary `https:` URL, you can easily consume it.

## Description

I have setup a web path for demonstration:

- [index.html](https://kazurayam.github.io/ks_reading_pdf_from_blob_url/index.html)

This page contains an HTML fragment as this:

```auto
    ...
    <li id="blobURL">blob:https://kazurayam.github.io/ks_reading_pdf_from_blob_url/nisa_guidebook_202307.pdf</li>
    ...

```

Please find that this fragment contains a `blob` URL as a content text of the `<li id="blobURL">` element.

I wrote a Katalon Test Case `TC1`

- [Test Cases/TC1](https://github.com/kazurayam/ks_reading_pdf_from_blob_url/blob/master/Scripts/TC1/Script1709597890074.groovy)

Read the source code for detail.

Some comments about the tricks in it:

1. The script gets a string of “`blob:https://host/resource`” out of an HTML element, and extract a string “`https://host/resource`”. This string manipulation requires fair amount of Groovy programming using the `java.util.regex` package.
2. The script download the PDF using the [Apache HttpClient](https://www.baeldung.com/apache-httpclient-cookbook) API.
3. The script does not use Katalon’s built-in `WS` keywords, as it has some bugs to deal with binary files. See [http://forum.katalon.com/t/download-the-image-file-via-rest-api/120898/2](http://forum.katalon.com/t/download-the-image-file-via-rest-api/120898/2)

By running the `Test Case/TC1`, I could get the PDF file downloaded and saved into a directory `./output/downloded.pdf`, as this

 ![success](https://europe1.discourse-cdn.com/katalon/original/3X/7/9/79592980d80d47b96728c5aa595ecc69f9af5f73.jpeg)

---

<div class="post-metadata">

**Author:** ![renuka.srivastav](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/renuka.srivastav/32/23870_2.png) [@renuka.srivastav](https://forum.katalon.com/u/renuka.srivastav)\
**Post date:** [March 6, 2024, 7:00am UTC](https://forum.katalon.com/t/unable-to-download-pdf-from-blob-url/122243/5 "2024-03-06T07:00:03Z")

</div>

Hi everyone,

Thanks for all your time and effort towards solving this issue, I was able to download the pdf successfully by making some changes in the browser preference as per the below thread:

> [@Chrome- pdf file opening in new tab instead of being downloaded](http://forum.katalon.com/t/chrome-pdf-file-opening-in-new-tab-instead-of-being-downloaded/45070/2):
>
> Hi Gurleen… Did you get a solution to this question? Even I am looking for a way around this. Thanks!

Thanks again.
