Free Support Forum - aspose.com

Dicom to PDF conversion issue


#1

Hi Team,
I am from PHILIPS India Ltd. and evaluating Aspose products for my project.
I am trying to convert a DICOM file (.dcm) to PDF. But its working with simple Dicom file. Dicom file with multiple frames and Dicom file with annotation giving errors.
below code snippet:

                      using (DicomImage image = (DicomImage)Aspose.Imaging.Image.Load(TempFileName))
                    {
                      

                        Aspose.Imaging.ImageOptions.PdfOptions exportOptions = new 
                          Aspose.Imaging.ImageOptions.PdfOptions();
                        exportOptions.PdfDocumentInfo = new Aspose.Imaging.FileFormats.Pdf.PdfDocumentInfo();
                        image.Save(Destination, exportOptions);
                        //DicomImage.Save
                 }

I tried this also:

                   using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document())
                    {
                        pdfDocument.Pages.Add();
                        Aspose.Pdf.Image image = new Aspose.Pdf.Image();
                        image.FileType = ImageFileType.Dicom;
                        image.File = TempFileName;
                        
                        pdfDocument.Pages[1].Paragraphs.Add(image);
                        // Save output as PDF format
                        pdfDocument.Save(Destination);
                    }

Please let me know, Is it possible to convert all types of Dicom files to pdf via using the Aspose family product. If yes then how? C# code would be very useful.


#2

@rajesh.svim11,

I have observed your comments. Can you please share source file so that we may further investigate to help you out.


#3

PFA sample multi-frame dicom, while converting to pdf. only one-page pdf is generating.
(I tried uploading but it’s not showing , even I tried ZIP file and PDF file.) help me out on this if you also not able to see attachment


#4

@rajesh.svim11,

I have observed your comments. Can you please share source files via dropbox or google drive if you are unable to attach files to this thread.


#5

Please download one sample file (multiframe Dicom file) from below link. this link is valid for 1 day.


#6

@rajesh.svim11,

I have tried to download file from link that you shared but the linked expired. Can you please share again so that i may download file.


#7

file is here


#8

@rajesh.svim11,

I have worked with source file shared by you using Aspose.Imaging for .NET 18.11 and unable to observe any issue. I have also shared my generated result with you for your kind reference. Please check attachment. Can you please share environment details along with which Aspose.Imaging version you are using on your end and screenshot pointing towards issue so that we may further investigate to help you out.bmode.pdf (118.8 KB)


#9

Thank you for your reply. But I have observed that I have shared you multi frame DICOM file which has 37 frames in it. But Output is only a single frame.
As per my understanding It should generate all 37 frames in PDF.

Please correct me if I am wrong.


#10

@rajesh.svim11,

I have observed your comments. I have shared sample code with you. This will help you to achieve your requirements.bmode37.zip (3.7 MB)

string path = “bmode.dcm”;
using (DicomImage image = (DicomImage)Image.Load(path))
{
PdfOptions options = new PdfOptions();
options.PdfDocumentInfo = new PdfDocumentInfo();
for (int i = 0; i < image.DicomPages.Length; i++)
{
image.DicomPages[i].Save(Path.GetFileNameWithoutExtension(path) + i + “.pdf”, options);
}
}


#11

Thank you…
But is it possible to generate in a single PDF file?


#12

@rajesh.svim11,

Can you please provide the desired output PDF that you want to generate using API. Please also provide the information about error that you observe on your end while using the sample code given your following post.


#13

Provided code is working and generation multipleple pdf files. as in our given dicom 37 frames are there so 37 pdf files got generated.
What i was asking is that: Is it possible to generated single pdf file for all the frames means 37 frames so 37 pages in a single pdf file. instead of giving 37 pdf file with single page.

I do not have any sample file to show you. I hope you would understand my requirement.

let me know if any concern.


#14

@rajesh.svim11,

I have observed your following comments.

I request you to please use Aspose.PDF for merging of generated PDF files into a single documents. Aspose.Imaging generates separate PDF for frames. I hope the suggested solution will work.