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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:07:40+00:00 2026-05-18T10:07:40+00:00

I’m using abcpdf and I’m curious if we can we recursively call AddImageUrl() function

  • 0

I’m using abcpdf and I’m curious if we can we recursively call AddImageUrl() function to assemble pdf document that compile multiple urls?

something like:

     int pageCount = 0;
     int theId = theDoc.AddImageUrl("http://stackoverflow.com/search?q=abcpdf+footer+page+x+out+of+", true, 0, true);
     //assemble document
     while (theDoc.Chainable(theId))
     {
        theDoc.Page = theDoc.AddPage();
        theId = theDoc.AddImageToChain(theId);
     }
     pageCount = theDoc.PageCount;
     Console.WriteLine("1 document page count:" + pageCount);
     //Flatten document
     for (int i = 1; i <= pageCount; i++)
     {
        theDoc.PageNumber = i;
        theDoc.Flatten();
     }

     //now try again
     theId = theDoc.AddImageUrl("http://stackoverflow.com/questions/1980890/pdf-report-generation", true, 0, true);
     //assemble document
     while (theDoc.Chainable(theId))
     {
        theDoc.Page = theDoc.AddPage();
        theId = theDoc.AddImageToChain(theId);
     }
     Console.WriteLine("2 document page count:" + theDoc.PageCount);
     //Flatten document
     for (int i = pageCount + 1; i <= theDoc.PageCount; i++)
     {
        theDoc.PageNumber = i;
        theDoc.Flatten();
     }
     pageCount = theDoc.PageCount;

edit:
code that seems to work based on ‘hunter’ solution:

      static void Main(string[] args)
  {
     Test2();
  }

  static void Test2()
  {

     Doc theDoc = new Doc();
     // Set minimum number of items a page of HTML should contain. 
     theDoc.HtmlOptions.ContentCount = 10;// Otherwise the page will be assumed to be invalid.
     theDoc.HtmlOptions.RetryCount = 10; // Try to obtain html page 10 times
     theDoc.HtmlOptions.Timeout = 180000;// The page must be obtained in less then 10 seconds

     theDoc.Rect.Inset(0, 10);  // set up document
     theDoc.Rect.Position(5, 15);
     theDoc.Rect.Width = 602;
     theDoc.Rect.Height = 767;
     theDoc.HtmlOptions.PageCacheEnabled = false;

     IList<string> urls = new List<string>();
     urls.Add("http://stackoverflow.com/search?q=abcpdf+footer+page+x+out+of+");
     urls.Add("http://stackoverflow.com/questions/1980890/pdf-report-generation");
     urls.Add("http://yahoo.com");
     urls.Add("http://stackoverflow.com/questions/4338364/recursively-call-addimageurlurl-to-assemble-pdf-document");

     foreach (string url in urls)
        AddImage(ref theDoc, url);

     //Flatten document
     for (int i = 1; i <= theDoc.PageCount; i++)
     {
        theDoc.PageNumber = i;
        theDoc.Flatten();
     }

     theDoc.Save("batchReport.pdf");
     theDoc.Clear();
     Console.Read();

  }


  static void AddImage(ref Doc theDoc, string url)
  {
     int theId = theDoc.AddImageUrl(url, true, 0, true);
     while (theDoc.Chainable(theId))
     {
        theDoc.Page = theDoc.AddPage();
        theId = theDoc.AddImageToChain(theId); // is this right?
     }
     Console.WriteLine(string.Format("document page count: {0}", theDoc.PageCount.ToString()));
  }

edit 2:unfortunately calling AddImageUrl multiple times when generating pdf documents doesn’t seem to work…

  • 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-18T10:07:41+00:00Added an answer on May 18, 2026 at 10:07 am

    Finally found reliable solution.
    Instead of executing AddImageUrl() function on the same underlying document, we should execute AddImageUrl() function on it’s own Doc document and build collection of documents that at the end we will assemble into one document using Append() method.
    Here is the code:

          static void Main(string[] args)
      {
         Test2();
      }
    
      static void Test2()
      {
         Doc theDoc = new Doc();
         var urls = new Dictionary<int, string>();
         urls.Add(1, "http://www.asp101.com/samples/server_execute_aspx.asp");
         urls.Add(2, "http://stackoverflow.com/questions/4338364/repeatedly-call-addimageurlurl-to-assemble-pdf-document");
         urls.Add(3, "http://www.google.ca/");
         urls.Add(4, "http://ca.yahoo.com/?p=us");
        var theDocs = new List<Doc>();
    
         foreach (int key in urls.Keys)
            theDocs.Add(GetReport(urls[key]));
    
         foreach (var doc in theDocs)
         {
            if (theDocs.IndexOf(doc) == 0)
               theDoc = doc;
            else
               theDoc.Append(doc);
         }
    
         theDoc.Save("batchReport.pdf");
         theDoc.Clear();
         Console.Read();
    
      }
    
    
      static Doc GetReport(string url)
      {
    
         Doc theDoc = new Doc();
         // Set minimum number of items a page of HTML should contain. 
         theDoc.HtmlOptions.ContentCount = 10;// Otherwise the page will be assumed to be invalid.
         theDoc.HtmlOptions.RetryCount = 10; // Try to obtain html page 10 times
         theDoc.HtmlOptions.Timeout = 180000;// The page must be obtained in less then 10 seconds
    
         theDoc.Rect.Inset(0, 10);  // set up document
         theDoc.Rect.Position(5, 15);
         theDoc.Rect.Width = 602;
         theDoc.Rect.Height = 767;
         theDoc.HtmlOptions.PageCacheEnabled = false;
    
         int theId = theDoc.AddImageUrl(url, true, 0, true);
         while (theDoc.Chainable(theId))
         {
            theDoc.Page = theDoc.AddPage();
            theId = theDoc.AddImageToChain(theId);
         }
    
         //Flatten document
         for (int i = 1; i <= theDoc.PageCount; i++)
         {
            theDoc.PageNumber = i;
            theDoc.Flatten();
         }
    
         return theDoc;
      }
    
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.