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.

Thu Jun 14, 2018 4:15 pm

Hello, what are the supported image formats for PdfImage.FromFile?

netgenium
 
Posts: 1
Joined: Wed Oct 21, 2015 11:22 am

Fri Jun 15, 2018 3:33 am

Dear netgenium,

Thanks for your inquiry.
In general, the method supports loading the image format as same as in System.Drawing.Image , such as ".jpg", ".png", ".bmp", ".gif" and so on. If you encounter any issue, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Jun 20, 2018 3:57 am

Dear netgenium,

Greetings from E-iceblue.
Has your issue been resolved ? Could you please give us some feedback at your convenience ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Sep 21, 2022 12:07 pm

Hi,
I am trying to get image from other website link (for example: https://wesitename.com/API/Images/logo.jpg) using
this code PdfImage image=PdfImage.FromFile(https://wesitename.com/API/Images/logo.jpg) .

This line throw exception {"The given path's format is not supported."}
While I hit this image url in browser then image shows in browser.
Please provide solution for this if I am using similar as above path.

But if I used my machine image path(like "D:\\images\logo.jpg") then it is working fine.

Thanks
Syed Masoom

syed.masoom
 
Posts: 8
Joined: Wed Aug 31, 2022 10:14 am

Thu Sep 22, 2022 8:41 am

Hello,

Thanks for your inquiry.
Our product does not support directly adding images form the web address.You can use the .NET class WebClient to download the file data first and then use our product to load. Please refer to my code below. If there are any problems after the test, please feel free to contact us.
Code: Select all
using (WebClient webClient = new WebClient())
            {
                byte[] data = webClient.DownloadData("YourPath");
                using (MemoryStream mem = new MemoryStream(data))
                {
                    PdfDocument doc = new PdfDocument();
                    doc.LoadFromFile("test.pdf");
                    PdfPageBase page = doc.Pages.Add();
                    PdfImage image = PdfImage.FromStream(mem);
                    float width = image.Width * 0.75f;
                    float height = image.Height * 0.75f;
                    float x = (page.Canvas.ClientSize.Width - width) / 2;
                    //Draw the image
                    page.Canvas.DrawImage(image, x, 60, width, height);
                    doc.SaveToFile("Sample.pdf");
                    doc.Close();
                }
            }


Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Sep 29, 2022 12:27 pm

Hi Simple,
Image issue now resolved. Thanks!
I am facing one more issue when this convert function (html to pdf using plugins) put in thread then exception occurred. This thread required due to I need to send this generated pdf file in email with attachment. If I removed thread then pdf is generated but email not sent.

Please do the needful.

Thanks
Syed Masoom

syed.masoom
 
Posts: 8
Joined: Wed Aug 31, 2022 10:14 am

Fri Sep 30, 2022 10:01 am

Hello,

Thanks for your inquiry.
This is Abel from E-iceblue. To help us reproduce your issue and work out a solution for you, please offer the following messages, thanks for your assistance in advance.

1) Your full test code that can reproduce your issue.
2) Your input document(if any).
3) Application type, such as Console App, .NET Framework 4.8.
4) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 927
Joined: Tue Mar 08, 2022 2:02 am

Mon Oct 10, 2022 6:12 am

Hello,

Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.PDF