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

  • Home
  • SEARCH
  • 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 8143857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:13:28+00:00 2026-06-06T13:13:28+00:00

I create a PDF file using iTextSharp and it’s stored in my system desktop

  • 0

I create a PDF file using iTextSharp and it’s stored in my system desktop and opens successfully in my local system. Now if I upload the same code to a server, no error occurs and the PDF file isn’t created. This is my partial code to create and open pdf.

PdfWriter.GetInstance(doc, new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Out.pdf", FileMode.Create));

doc.Open();
DataView DView = (DataView)Session["data_value"];
dtData = DView.ToTable();
dr = dtData.Select("fldemp_no='" + Session["EmployeeID"].ToString() + "'");
doc.NewPage();
iTextSharp.text.Image ObjImg = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Bin/Head.png"));
ObjImg.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
ObjImg.ScaleToFit(220f, 150f);
ObjImg.SpacingBefore = 13f;
ObjImg.SpacingAfter = 1f;
doc.Add(ObjImg);

maintable = new PdfPTable(1);
cell = new PdfPCell(new Phrase("Pay Slip for the month of " + dr[0]["fldmonth"].ToString(), fnt1));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.Border = 0;
maintable.AddCell(cell);
doc.Add(maintable);

maintable = new PdfPTable(2);
empdetright = new PdfPTable(2);

empdetleft = new PdfPTable(2);
cell = new PdfPCell(new Phrase("Emp No", fnt1));
cell.Border = 0;
empdetright.AddCell(cell);

cell = new PdfPCell(new Phrase(": " + dr[0]["fldemp_no"].ToString(), fnt1));
cell.Border = 0;
empdetright.AddCell(cell);

cell = new PdfPCell(new Phrase("Emp Name", fnt1));
cell.Border = 0;
empdetright.AddCell(cell);
cell = new PdfPCell(new Phrase(": " + dr[0]["fldempname"].ToString(), fnt1));
cell.Border = 0;
empdetright.AddCell(cell);

doc.Close();
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/out.pdf"); 
  • 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-06-06T13:13:29+00:00Added an answer on June 6, 2026 at 1:13 pm

    In a web application you need to return the PDF document in the response stream. Here is a simple example:

    var response = HttpContext.Current.Response;
    response.Clear();
    response.ContentType = "application/pdf";
    
    MemoryStream mem = new MemoryStream(); // PDF data will be written here
    PdfWriter writer = PdfWriter.GetInstance(doc, mem);  // tie a PdfWriter instance to the stream
    
    doc.Open();
    
    // ... Doing the pdf generation
    
    doc.Close();
    
    // write the document data to response stream
    writer.Flush();
    response.OutputStream.Write(mem.GetBuffer(), 0, mem.GetBuffer().Length);
    response.OutputStream.Flush();
    response.OutputStream.Close();
    response.End();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a PDF file using itextsharp. It's created successfully and open with adobe
I'm using AlivePDF to create a PDF file, then save it to the desktop.
How do one create PDF in memorystream instead of physical file using itextsharp. The
I am using iTextSharp to create a PDF document in C#. I would like
I am working in LaTeX, and when I create a pdf file (using LaTeX
am using ghostscript to create pdf file from postscript file. My PS file, doesn't
I'm using code to create a PDF File. Works. But: I want my whole
Is it possible to create a thumbnail image from a PDF file using Coldfusion
All I am inserting text in existing PDF file using iTextSharp Library, some times
I am trying to create a PDF file using struts 2.Action class location is

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.