PDF Helper [Convert from HTML, Word, Images(.BMP, .GIF, .JPG, .PNG) and Merge into one Single PDF file]
Announcement made by Administrator - November 15, 2018 at 6:51 PM
Employee Post
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;

<html xmlns="http://www.w3.org/1999/xhtml">;
<head runat="server">
    <title>PDF Helper</title>
    <form id="form1" runat="server">
        <asp:Button ID="btnSubmit" Text="Generate" OnClick="btnSubmit_Click" runat="server" />
Code behind
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading.Tasks;
using System.Diagnostics;
using ncPDFHelper;

public partial class Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void btnSubmit_Click(object sender, EventArgs e)

        PDFHelper oPDF = new PDFHelper();

        String previewPDFs = "~/files/SamplePageFile.html";

        oPDF.HtmlToPdf(previewPDFs, "~/css/htmlstyle.css", 
        //-oPDF.WordToPDF(previewPDFs, Server.MapPath("files/htmlpdf.pdf"),true);



        String ImgPreview1 = Server.MapPath("files/family-2.jpg");
        String ImgPreview2 = Server.MapPath("files/Retired.gif");

        String[] aImgFiles = new String[2];
        aImgFiles[0] = ImgPreview1;
        aImgFiles[1] = ImgPreview2;

        //- Convert from BMP, JPG, GIF, PNG to PDF
        oPDF.ImagesToPdf(aImgFiles, Server.MapPath("files/"), "ExportImg.pdf");

        //- Convert from MS-Word to PDF (MS-Office must be installed on Server)
            Server.MapPath("files/WordToPDF.pdf"), false);
        catch (Exception erm)

        String eventTemplate = Server.MapPath("files/Sample1.pdf"); //-Already Exists in folder
        String SinglePreview = Server.MapPath("files/Sample2.pdf");
        String PDFPreview = Server.MapPath("files/Sample3.pdf");
        String PDFPreview1 = Server.MapPath("files/htmlpdf.pdf");  //- Created-NEW
        String PDFPreview2 = Server.MapPath("files/ExportImg.pdf"); //- Created-NEW
        String PDFPreview3 = Server.MapPath("files/WordToPDF.pdf"); //- Created-NEW


        String[] aFiles = new String[6];
        aFiles[0] = eventTemplate;
        aFiles[1] = SinglePreview;
        aFiles[2] = PDFPreview;        
        aFiles[3] = PDFPreview1;
        aFiles[4] = PDFPreview2;
        aFiles[5] = PDFPreview3;

        if (System.IO.File.Exists((String)eventTemplate))
            //- Merge all PDF Created into one single PDF.
            if (oPDF.MergePDFs(aFiles, Server.MapPath("export/Export.pdf")))
        //- SHow the single merged pdf here.
        if (System.IO.File.Exists(Server.MapPath("export/Export.pdf")))
            //- Display it.
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", "attachment; filename=Export.pdf");
For Word to PDF MS-Office must be installed on server.
Download .NET (ncPDFHlelper.dll) Assembly here ncPDFHelperVer1.0.zip
After download and unzipped all assenblies(.DLLs) must be copied to your project BIN folder.

Reply to Thread