YGAddImgNTextToPDF 2.2.0

dotnet add package YGAddImgNTextToPDF --version 2.2.0                
NuGet\Install-Package YGAddImgNTextToPDF -Version 2.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YGAddImgNTextToPDF" Version="2.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YGAddImgNTextToPDF --version 2.2.0                
#r "nuget: YGAddImgNTextToPDF, 2.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install YGAddImgNTextToPDF as a Cake Addin
#addin nuget:?package=YGAddImgNTextToPDF&version=2.2.0

// Install YGAddImgNTextToPDF as a Cake Tool
#tool nuget:?package=YGAddImgNTextToPDF&version=2.2.0                

YGAddImgNTextToPdf

A simple class to add images and texts to existing PDF document

Installation

Include this package in the project file

Usage

string sourcePdfPath = @"c:\temp\Contract.pdf";        // Path to the existing PDF
string destPdfPath = @"c:\temp\Contract_Signed.pdf";   // Path to save the new PDF
string signatureImageName = @"c:\temp\signature.jpg";  // Path to the signature image
string waterMarkFileName = @"C:\Temp\sheep.png";       // WaterMark
string filename = @"c:\temp\name.png";
string date = @"c:\temp\date.png";

// This is to add images and texts to sourcePdfPath, and produce the resulting pdf in destPdfPath.
// The images and texts are added in page 2
using (PDFSign pdf = new PDFSign(sourcePdfPath, destPdfPath))
{
    if (pdf.ErrorMsg != null)
    {
        Console.WriteLine(pdf.ErrorMsg);
        return;
    }
    int pageNbr = 1;
    string result0 = pdf.AddBackGroundImage(new int[] { 1, 2 }, waterMarkFileName, 0.3f, 30, 50, 200);
    string result1 = pdf.AddImage(pageNbr, signatureImageName, 30, 50, 260);
    string result2 = pdf.AddImage(pageNbr, filename, 72, 168, 359);
    string result3 = pdf.AddImage(pageNbr, date, 72, 400, 363);
    string result4 = pdf.AddText(pageNbr, "(888) 555 - 1212", 500, 365, new XFont("Verdana", 8, XFontStyle.Regular), XBrushes.Red);
    double y1 = pdf.AddLongTextToWrap(pageNbr, myLongText, 50.0, 460.0, 500.0, 12.0, new XFont("Verdana", 12, XFontStyle.Regular), XBrushes.DarkBlue);
    pdf.AddLine(pageNbr, new XPen(XColors.Red, 0.5), 50.0, 650.0, 500.0, 650.0);
    string result5 = pdf.WriteOutPDF();
}

Examples

Test project is provided in the solution to illustrate how instantiate and invoke the pdf functionality

Output:

The output is a modified pdf with the images and texts added to it

Dependencies

PdfSharpCore

Contributing

Any new ideas on how to enhance this class without adding much complexity, please adhere to SOLID principle

License

This project is licensed under the MIT License(LICENSE).

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.0 65 11/6/2024
2.1.0 103 9/2/2024
2.0.3 104 7/23/2024
2.0.2 98 7/23/2024
2.0.1 97 7/23/2024
2.0.0 102 7/23/2024
1.1.2 105 6/28/2024
1.1.1 103 5/31/2024
1.1.0 106 5/30/2024
1.0.0 112 5/23/2024

Added functionality to add watermark in select pages