Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Mon Jan 22, 2018 5:16 am
Hi
I have bunch of URLs needed to be printed as PDF, so I'm using spire.
My question is how I can handle error if url indicates download page not typical web page.
if I type this url, download dialog is popped up automatically.
1. is there any way I can just download and save it using loadfromhtml?
2. if there is no way to do it, how I can handle this error?
-

af2580
-
- Posts: 2
- Joined: Thu Jan 18, 2018 5:52 am
Mon Jan 22, 2018 9:34 am
Hello,
Thanks for your inquiry. When using loadfromhtml, it is not allowed to load a download page. In this case, you could save the attachment like below. Hope it is helpful to you.
- Code: Select all
using (WebClient webClient = new WebClient())
{
byte[] data = webClient.DownloadData(download url);
//byte to file
FileStream fs = new FileStream(@"f:\test\result.pdf", FileMode.Create, FileAccess.Write);
fs.Write(data, 0, data.Length);
fs.Flush();
}
Best regards,
Simon
E-iceblue support team
-


Simon.yang
-
- Posts: 620
- Joined: Wed Jan 11, 2017 2:03 am
Wed Jan 24, 2018 10:00 am
Hello,
Greeting from E-iceblue.
Is the solution helpful to you?
Your feedback will be greatly appreciated.
Best regards,
Simon
E-iceblue support team
-


Simon.yang
-
- Posts: 620
- Joined: Wed Jan 11, 2017 2:03 am
Wed Jan 31, 2018 5:17 am
Hi
I have one more inquiry.
How can we know this url is whether webpage or download page?
is there any return value for loadfromHtml or DownloadData?
-

af2580
-
- Posts: 2
- Joined: Thu Jan 18, 2018 5:52 am
Wed Jan 31, 2018 6:35 am
Hello,
Thanks for your reply. You could first sort the URLs into two group by regex and then deal with them separately.
Best regards,
Simon
E-iceblue support team
-


Simon.yang
-
- Posts: 620
- Joined: Wed Jan 11, 2017 2:03 am
Fri Feb 02, 2018 9:38 am
Hello,
Greeting from E-iceblue.
How is the issue going?
Your feedback will be greatly appreciated.
Best regards,
Simon
E-iceblue support team
-


Simon.yang
-
- Posts: 620
- Joined: Wed Jan 11, 2017 2:03 am