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 5991373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:22:38+00:00 2026-05-22T23:22:38+00:00

So I got a problem with saving my pdf. I want to create an

  • 0

So I got a problem with saving my pdf.
I want to create an inventory based on a template, a template with no acrofields.
The template contains the companies logo and some data like the address.
What I am trying to do is copy the page from the template, paste it in a new document and then add a table to it (the table with the inventory).

The main problem I have is that i don’t manage to save or show the result. In all my previouse projects I used the memorystream but now this method doesn’t seem to work when using the pdfCopy instead of the pdfWriter.

Could anybody help me? this is my code.

public void PrintInventory(string path, MemoryStream ms) 
{ 
        VoorraadService vService = new VoorraadService(); 

        PdfReader reader; 
        Document document; 
        PdfCopy copy; 

        try 
        { 
            var stock = vService.GetInventaris(); 
            reader = new PdfReader(path + "Images/Inventaris_Template.pdf"); 
            document = new Document(reader.GetPageSizeWithRotation(1)); 
            copy = new PdfCopy(document, ms); 

            document.Open(); 

            while(stock.Count >0) 
            { 
                copy.AddPage(copy.GetImportedPage(reader, 1)); 

                PdfPTable table = new PdfPTable(6); 
                table.WidthPercentage = 100; 
                for (int i = 0; i < 15 && stock.Count > 0; i++) 
                { 
                    table.AddCell(new Phrase(stock[0].ArtikelID)); 
                    table.AddCell(new Phrase(stock[0].ExternArtikelID)); 
                    table.AddCell(new Phrase(stock[0].Naam)); 
                    table.AddCell(new Phrase(stock[0].Aankoopprijs.ToString())); 
                    table.AddCell(new Phrase(stock[0].Aantal.ToString())); 
                    table.AddCell(new Phrase(stock[0].Totaal.ToString())); 
                    stock.Remove(stock[0]); 
                } 
                table.CompleteRow(); 
                copy.Add(table);         
            } 
            document.Close(); 
            reader.Close(); 
        } 
        catch (Exception e) 
        { return; }
}             

And the event on the print button:

 protected void btnPrinten_Click(object sender, EventArgs e)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            ms.Position = 0;
            PdfGenerator pdf = new PdfGenerator();
            pdf.PrintInventory(Request.Url.OriginalString.Replace("Applicatie/Voorraad/Inventory.aspx", ""), ms);

            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
        }
    }
  • 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-22T23:22:39+00:00Added an answer on May 22, 2026 at 11:22 pm

    The problem is solved now.
    My main problem was my Updatepanel, Because the printbutton wasn’t causing a real postback the saving of the file couldn’t be completed.
    That’s why I didn’t get any result when i pressed the button.
    Now that i used it as a postback trigger in my updatepanel all is solved.

    You guys were also right about the pdfcopy I changed it to a writer and now everything works out like it should.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some backgroundworker threads that are working on calculations or saving data. Every
I've got a problem at saving my entity. MApping: ?xml version=1.0 encoding=utf-8 ?> <hibernate-mapping
I've got a links array that I'm saving to a database. The problem is
I got a linq based windows project.There is a form thats saving personel's departmant
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
I got a problem like this (this is html/css menu): Eshop | Another eshop
I've got a problem here with an MSI deployment that I'm working on (using
I've got a problem with inheritance and generics. This is the code that illustrates
I've got a problem where I have a .co.uk domain of which I am
I've got a problem similar to,but subtly different from, that described here (Loading assemblies

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.