Last active
April 10, 2024 11:28
-
-
Save bondarewicz/259a04240eb061b8a7b275a955da604c to your computer and use it in GitHub Desktop.
IronPdf png rotate
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
[Fact] | |
public async Task Pdf_WithValidPdf_WillReturnPng() | |
{ | |
License.LicenseKey = | |
"lincence here"; | |
Installation.LinuxAndDockerDependenciesAutoConfig = false; | |
Installation.Initialize(); | |
var base64Pdf = await File.ReadAllTextAsync(@"./_ParcelForceLabel.txt"); | |
using var pdf = new PdfDocument(Convert.FromBase64String(base64Pdf)); | |
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90); | |
pdf.SaveAs("_PdfToPngLandscape.pdf"); | |
var images = pdf.ExtractAllImages(); | |
#if DEBUG | |
var png = images.First(); | |
png.RotateFlip(AnyBitmap.RotateMode.Rotate180, AnyBitmap.FlipMode.Horizontal); | |
await File.WriteAllBytesAsync( | |
"./_PdfToPng.png", | |
png.ExportBytes(AnyBitmap.ImageFormat.Png) | |
); | |
#endif | |
images.Count.Should().Be(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment