Showing posts with label addImageUrl. Show all posts
Showing posts with label addImageUrl. Show all posts

Thursday, 30 May 2019

How PDF Links works the same way of WebSite Links using ABCPDF Library?

Hi Readers,

Scenario: Read any web site/Page using AddImageUrl function in Abcpdf library but Page/Site has links. How in website links perform the same way in PDF also should work.

Solution: The below code performs the same.

Key Points:

1. If we are not using the below two lines then PDF Links are like normal Text.
  doc.HtmlOptions.AddLinks = true;
  doc.HtmlOptions.LinkPages();

2. An important point to remember is order and the place where to add,

   Either add before the following line like below,
   doc.HtmlOptions.AddLinks = true;
   doc.HtmlOptions.LinkPages();
   int theID = doc.AddImageUrl("https://techinuthan.blogspot.com/"); 
   
     Or the other option is the below sample code,

Sample Code:


using System;
using System.IO;
using WebSupergoo.ABCpdf11; namespace Demos_on_abcpdf {     class Program     {         static void Main(string[] args)         {             string theBasePath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string outputFolder = theBasePath + @"\Output\";

            // This Doc class is coming from WebSupergoo.ABCpdf11 namespace.
            Doc doc = new Doc(); 
  
            #region Demo 1 Starts -  Multiple Pages inside single PDF With Links action Perform
            doc.HtmlOptions.AddLinks = true;
            // Converts web page to multiple Images in PDF
            int theID = doc.AddImageUrl("https://techinuthan.blogspot.com/"); 
            while (true)
            {
                if (!doc.Chainable(theID))
                    break;
                doc.Page = doc.AddPage();
                doc.AddImageToChain(theID);
            }
 
            doc.HtmlOptions.LinkPages();
            doc.Save(outputFolder + "ConvertWebPageToMultiplePagesWithLinks.pdf");
            #endregion Demo 1 Ends - Multiple Pages inside single PDF With Links action Perform
 
 
            Console.WriteLine("PDF Generated Successfully");
            Console.ReadLine();
        }
    }
}

Output: 
Check output for this code from this GitHub URL : Multiple WebPages In Single PDF With Link Actions

Happy Coding:)

Wednesday, 29 May 2019

How to generate a pdf with multiple pages using AddImageUrl function in abcpdf library?

Hi Readers,

In this article, using abcpdf AddImageUrl function, generates a pdf with multiple pages.

If Url has multiple pages then PDF has multiple or else only single page PDF will create.

Sample Code:

using System;
using System.IO;
using WebSupergoo.ABCpdf11; namespace Demos_on_abcpdf {     class Program     {         static void Main(string[] args)         {
            string theBasePath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string outputFolder = theBasePath + @"\Output\";
           // This Doc class is coming from WebSupergoo.ABCpdf11 namespace.
            Doc doc = new Doc(); 
 
            #region Demo 1 Starts -  Multiple Pages inside single PDF
            // Converts web page to multiple Images in PDF
            int theID = doc.AddImageUrl("https://techinuthan.blogspot.com/"); 
            while(true)
            {
                if (!doc.Chainable(theID))
                    break;
                doc.Page = doc.AddPage();
                doc.AddImageToChain(theID);
            }
            doc.Save(outputFolder + "ConvertWebPageToMultiplePages.pdf");
            #endregion Demo 1 Ends - Multiple Pages inside single PDF
 
            Console.WriteLine("PDF Generated Successfully");
            Console.ReadLine();
        }
    }
}

Note: Chainable checks whether any page is associated with the currentID in document. 
If Yes then create a new page or else break it and comeout from the code.


Output:
Check output for this code from this GitHub URL : Multiple WebPages In Single PDF


Happy Coding:)