Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:06:10+00:00 2026-05-26T22:06:10+00:00

I am using ItextSharp Library to generate pdf files on a button click on

  • 0

I am using ItextSharp Library to generate pdf files on a button click on my SharePoint Site. I want to use a logo on the pdf whose image resides on the Images Folder of Sharepoint. I am unable to do that.

Can someone help me with it.

Below is the code that I am using which is getting the instance from window32 which I dont want.

 protected void button1_OnClick(object sender, EventArgs e)
  {
      Font Arial = FontFactory.GetFont("Arial", 12, BaseColor.GREEN);
      Font Verdana = FontFactory.GetFont("Verdana", 16, Font.BOLDITALIC, new BaseColor(125, 88, 15));
      string imagepath = SPContext.Current.Web + "/_layouts/Images/Image1.png";
      using (var ms = new MemoryStream())
      {
          using (var document = new Document(PageSize.A4,50,50,15,15))
          {
              PdfWriter.GetInstance(document, ms); 
              document.Open();
              Paragraph img = new Paragraph();
              Image jpg = Image.GetInstance(imagepath); --- Getting an error here stating "Could not find a part of the path 'c:\windows\system32\inetsrv\CustomSystem\_layouts\Images\Image1.png'"
              img.Add(jpg );
          }
       }
      }

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:06:10+00:00Added an answer on May 26, 2026 at 10:06 pm

    I’m not too familiar with SharePoint development but you’re problem is with this line:

    string imagepath = SPContext.Current.Web + "/_layouts/Images/Image1.png";
    

    This string must be an absolute path path such as c:\www\sites\image.png, not a relative one which it is right now. I can tell its relative because when you ask ASP.Net to get something for you but you don’t specify a path it looks in %WINDOWS%.

    I don’t know how you’re using SPContext.Current.Web but according to the docs calling .ToString() on it returns the title of the website which is what would happen if you concatenated it with a string like you are. My guess is that you don’t need that but could be wrong.

    If the layouts folder is a subfolder of the folder that the file you are working on is in then you should be able to use Server.MapPath to get the absolute path:

    string imagepath = Server.MapPath("_layouts/Images/Image1.png");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using iTextsharp library to create PDF files. I can declare for A4 Landscape
I want to export gridview to pdf by using the itextsharp library. The problem
I am using iTextSharp to generate pdf in my .net application. Now I want
I'm using iTextSharp to generate some PDF files. I have two tables which have
I am using iTextSharp to add text to PDF files. The Text Color is
I've recently started using iTextSharp to generate PDF reports from data. It works quite
Is it possible to convert a xps document to PDF using iTextSharp library?
Im using ITextSharp to generate a PDF, and have a situation where a need
I am using iTextsharp to generate a PDF document from C# application. I am
I'm using iTextSharp to generate a large document. In this document I want some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.