DICOM image to PDF conversion and Print Dialog Presets properties with Aspose.Pdf for .NET 17.10

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Aspose.Pdf for .NET logoWe are very much excited to announce the release of Aspose.Pdf for .NET 17.10 which offers various enhancements and fixes related to issues reported in previous release versions. We are always striving to make the API robust enough to cater wide variety of input documents and with every new release, the API is becoming more stable, as new enhancements and bug fixes are being introduced.

DICOM image to PDF conversion

Digital Imaging and Communications in Medicine (DICOM) is a standard for storing and transmitting medical images enabling the integration of medical imaging devices such as scanners, servers, workstations, printers etc. Aspose.Pdf for .NET is capable of converting various image formats to PDF and other supported formats. Recently we received a requirement to convert DICOM images to PDF format, so in order to cater this scenario, we are pleased to announce the support of this format. In order to accomplish this requirement, please try using following code snippet

string outputFile = @"c:\mr-shoulder.pdf";
using (Document pdfDocument = new Document())
{
     pdfDocument.Pages.Add();
     Aspose.Pdf.Image image = new Aspose.Pdf.Image();
     image.FileType = ImageFileType.Dicom;
     image.File = @"c:\mr-shoulder.dcm";
     pdfDocument.Pages[1].Paragraphs.Add(image);
     // Save output as PDF format
     pdfDocument.Save(outputFile);
}

Set Print Dialog Presets properties

Recently one of the customers shared a requirement to change DuplexMode property to duplex of Print Dialog Presets(In Adobe Acrobat choose File > Properties -> Advanced tab). Whereas in the Print Dialog (Presets section) of PDF document, the default value is set to simplex. We can set Duplex property of PrinterSettings object while printing through PdfViewer class but the API lacked the feature to set PDF document property. Therefore in order to accomplish this requirement, support is provided in API and following code snippet can be used.

string outputFile = @"c:\35297.pdf";
using (Document doc = new Document())
{
       doc.Pages.Add();
       doc.Duplex = PrintDuplex.DuplexFlipLongEdge;
       doc.Save(outputFile);
}

PdfContentEditor approach

string outputFile = @"c:\old_file.pdf";
string outputFile1 = @"c:\new_file.pdf";
using (PdfContentEditor ed = new PdfContentEditor())
{
       ed.BindPdf(outputFile);
       if ((ed.GetViewerPreference() & ViewerPreference.DuplexFlipShortEdge) > 0)
       {
           Console.WriteLine("The file has duplex flip short edge");  
       }    
       ed.ChangeViewerPreference(ViewerPreference.DuplexFlipShortEdge);
       ed.Save(outputFile1);
}

Vertical Alignment property for Row instance

In legacy Aspose.Pdf.Generator, we had a VerticalAlign property on row objects and in order to provide similar feature in new Document Object Model of Aspose.Pdf namespace, we have added similar property for Aspose.Pdf.Row instance.

// Load source PDF document
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// create a loop to add 10 rows
for (int row_count = 1; row_count < 10; row_count++)
{
    // add row to table
    Aspose.Pdf.Row row = table.Rows.Add();
    // set vertical alignment for Row instance
    row.VerticalAlignment = VerticalAlignment.Center;
    // add table cells
    row.Cells.Add("Column (" + row_count + ", 1)");
    row.Cells.Add("Column (" + row_count + ", 2)");
    row.Cells.Add("Column (" + row_count + ", 3)");
}
// Add table object to first page of input document
doc.Pages[1].Paragraphs.Add(table);
// Save updated document containing table object
doc.Save("document_with_table.pdf");

Miscellaneous fixes

Apart from above mentioned improvements, the API is improved to generate better results for PDF to SVG or SVG to PDF conversion and it has also been improved to accept password in foreign language when encrypting or decrypting PDF files. The PDF to PDF/A compliance conversion is improved to cater more scenarios and for other inter file format conversion scenarios, there has been significant efforts towards the stability of PDF to HTML conversion feature.

As it is always recommended to use latest release of our API’s, so we suggest you to please download the latest release of Aspose.Pdf for .NET 17.10 and check Release Notes section for list of issues fixed in Aspose.Pdf for .NET 17.10


To keep up with our news, you can follow us on Twitter or follow our Facebook page.

Leave a Reply