Skip to content

Instantly share code, notes, and snippets.

@bondarewicz
Last active April 10, 2024 11:28
Show Gist options
  • Save bondarewicz/259a04240eb061b8a7b275a955da604c to your computer and use it in GitHub Desktop.
Save bondarewicz/259a04240eb061b8a7b275a955da604c to your computer and use it in GitHub Desktop.
IronPdf png rotate
[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