This commit is contained in:
Zeeshaun
2026-04-27 10:50:07 -05:00
parent 8b528fa00b
commit b5edd55420
141 changed files with 9602 additions and 0 deletions
@@ -0,0 +1,38 @@
using System;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using LCU.Library.Internal.FileOperationsModels.Models;
namespace LCU.Api.Internal.FileOperations.Validations;
public static class PdfValidations
{
private const string PdfPageDoesntExist = "PDF Page Doesn't Exist.";
private const string PdfPageCantBeLessThanOne = "PDF Page Can't Be Less Than 1.";
public static RequestResponse ValidatePdfPageExists(RequestResponse requestResponse, string pdfName, int pageNumber)
{
try
{
PdfDocument inputDocument = PdfReader.Open(pdfName, PdfDocumentOpenMode.Import);
if(pageNumber <= 0)
{
requestResponse.IsSuccessful = false;
requestResponse.MessageStack.Add(PdfPageCantBeLessThanOne);
}
if (pageNumber > inputDocument.PageCount)
{
requestResponse.IsSuccessful = false;
requestResponse.MessageStack.Add(PdfPageDoesntExist);
}
}
catch (Exception exception)
{
requestResponse.IsSuccessful = false;
requestResponse.MessageStack.Add(exception.Message);
}
return requestResponse;
}
}