Created
July 8, 2020 08:57
-
-
Save umerfaruk/911b42506d7b427178899e4b04a9a9b0 to your computer and use it in GitHub Desktop.
PDF Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PageSize documentSize; | |
using (var firstImage = new Bitmap(firstPagePath)) | |
{ | |
documentSize = new PageSize(firstImage.Width, firstImage.Height); | |
} | |
using (var pdf = new PdfDocument(new PdfWriter(pdfPath))) | |
{ | |
using (var writer = pdf.GetWriter()) | |
{ | |
writer.SetCompressionLevel(9); | |
using (var document = new Document(pdf, documentSize)) | |
{ | |
document.SetMargins(0, 0, 0, 0); | |
foreach (var page in book.Pages) | |
{ | |
var imageData = ImageDataFactory.Create(page.PageImagePath); | |
var image = new Image(imageData).SetHeight(imageData.GetHeight()).SetWidth(imageData.GetWidth()); | |
document.Add(image); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment