Showing posts with label ABCPDF11. Show all posts
Showing posts with label ABCPDF11. Show all posts

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:)

How to add a reference of abcpdf library in a project using Visual Studio 2017 IDE?

Hi Readers,

In this article, We will get to know how to add a reference of abcpdf library in a project using visual studio 2017 IDE.

Step 1. First, create a new project as for this example I am creating a C# Console Application

Step 2: Right click on Reference folder, Browse the library from installed location, Select it

Step 3: Click on OK and it adds into Reference folder.

Step 4: In Code, add the following references

using WebSupergoo.ABCpdf11;
using WebSupergoo.ABCpdf11.Objects;
using WebSupergoo.ABCpdf11.Atoms;
using WebSupergoo.ABCpdf11.Operations;

As in the above namespaces, Objects namespace is mostly used one to manipulate the PDF

Sample Code:
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\";
            // Create a basic PDF             Doc mainDoc = new Doc(); // This Doc class is coming from WebSupergoo.ABCpdf11 namespace.             mainDoc.AddText("Hello!!! My First PDF Demo using abcpdf library");             mainDoc.Save(outputFolder + "PDFWithSimpleText.pdf");         }     } }


Output:

All these sample codes are available in this Github repository: https://github.com/nuthanm/abcpdf-demos

Happy Coding:)