We are always enthusiastic about adding new features and excited to introduce the enhancements to our products. Furthermore, we have always tried our level best to fix the issues and bugs reported in earlier versions because it helps us gain customer’s confidence in our products. Keeping the tradition alive, we are very much excited to announce the release of Aspose.PDF for .NET 7.8.0. During the preparation of this release, we have introduced many new features and enhancement and also fixed many of the issues reported earlier.

Convert PDF to PostScript in C#

One of the salient features of Aspose.PDF for .NET 7.8.0 is support for rendering PDF document to PostScript (PS) format. Accomplishing this requirement has been made very easy by introducing support in the PdfViewer class. Now you simply need to install PostScript drivers on your system, use the PdfViewer class and you are good to go with the conversion.

Please check out the related article for further details on PDF to PostScript conversion.

Image Collection Support

As per the Document Object Model (DOM) approach, each object inside a PDF file can be individually accessed and manipulated. Therefore taking benefit of this mechanism, we have introduced Image Collection support. Please take a look over the following simple code to add images to a PDF file’s collection object.

// Instantiate Document object 
Document doc = new Document();
// Initialize collections object for Document object 
doc.Collection = new Collection();
// Load source Image file 
Aspose.Pdf.FileSpecification fs = new Aspose.Pdf.FileSpecification("AsposeDependency.PNG");
// Add description for loaded image file 
fs.Description = "PNG file1";
// Add image to collection of PDF file 
// Load another image file
fs = new FileSpecification("sampleImage.jpg");
fs.Description = "JPEG file1";
// Add image to collection of PDF file
// Load third image file
fs = new FileSpecification("1.png");
// Description for image file
fs.Description = "PNG file2";
// Save the document
Image Collection inside PDF document

The above snapshot shows the Image collection inside the PDF document

Recently we have worked on a requirement to remove headers and footers from PDF files. To fulfill this requirement, we’ve added the PdfFileStamp.StampId property. This property allows you to set an identifier for new stamps (including header, footer, page number). The added stamp may be removed using the PdfContentEditor: add header, footer and page number while assigning them arbitrary IDs, and later remove them with those IDs.

PdfFileStamp pfe = new PdfFileStamp("Input.pdf"," PDF_With_Header_Footer.pdf");
// 100 is the stampId for footer
pfe.StampId = 100;
pfe.AddFooter(new FormattedText("Footer"), 10);
// 200 is the stampId for header
pfe.StampId = 200;
pfe.AddHeader(new FormattedText("Header"), 10);
// 300 if  the stampId for page number
pfe.StampId = 300;
pfe.AddPageNumber(new FormattedText(" Page #", System.Drawing.Color.Red, System.Drawing.Color.Blue));

PdfContentEditor pce = new PdfContentEditor();
StampInfo[] stamps = pce.GetStamps(1);
Assert.AreEqual(3, stamps.Length);
// Show found stamps IDs
foreach (StampInfo info in stamps)

{ Console.WriteLine(info.StampId); }
// Remove header, footer and page number

Use CMYK Colorspace to Set ForegroundColor and BackgroundColor

Prior to the release of Aspose.PDF for .NET 7.8.0, we supported using the System.Drawing.Color object to set the foreground and background color of text, stamps, and similar objects. With the release of this version, we have enhanced the capabilities of our product so you can set the color from the CMYK, gray and RGB color spaces. The TextState and TextFragmentState objects have properties to set BackgroundColor and ForegroundColor. To set background or foreground color from the CMYK colorspace, please try using the following code snippet.

TextStamp stamp = new TextStamp("Test");
stamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromCmyk(0.1, 0.2, 0.3, 0.5);
stamp.TextState.BackgroundColor = Aspose.Pdf.Color.FromCmyk(0.3, 0.2, 0.1, 0.3);
// Save updated document

Code Migration Scenarios

Previously valid code:

  • TextState.BackgroundColor = System.Drawing.Color.Brown

Valid code from Aspose.Pdf for .NET 7.8.0:

  • TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Brown);

Besides the above stated enhancements, we have also made many improvements in terms of performance while converting TIFF to PDF, PDF to TIFF, HTML to PDF, XPS to PDF, PDF to XPS, PDF printing, image replacement, image extraction, text watermarking, image stamping and much more. Please visit the following link for further details on what’s new & fixed in Aspose.PDF for .NET 7.8.0.