We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf is not conveting

Hi Team,

Can you please see the attached PDF file?
I am not able to convert the attached PDF file to muti-page TIFF image.

Can you please help me is this problem with the PDF?

Regards
Anish

Hi Anish,

Thanks for using our API.

Can you please share some details regarding the format in which you are trying to convert this document, so that we can test the scenario accordingly.

Hello Nayyer,

I have already attached the PDF file in the previous post. What else information you need from us, please let us know.

Thanks
Anish

Hi Anish,

Thanks for the acknowledgment.

Yes I have found the source PDF file in earlier post. However I am not certain about the issue which you are facing i.e. facing an issue while converting PDF to DOC, DOCX, HTML, Image etc. Or please share the C# code snippet which you are using so that we can test the conversion in our environment.

Nayyer,
Please find the below C# code snippet,

public static System.Drawing.Image[] ConvertPDFtoMultiPageTiff(string OutputFolder, string FullInputFileName)
{
    System.Drawing.Image[] sourceImages = null;

    try
    {
        Document pdfDocument = new Document(FullInputFileName);
        //create Resolution object
        Resolution resolution = new Resolution(300);
        //create TiffSettings object
        TiffSettings tiffSettings = new TiffSettings();

        tiffSettings.Compression = CompressionType.CCITT4;
        tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format8bpp;

        if (tiffSettings.Shape == Aspose.Pdf.Devices.ShapeType.Landscape)
            tiffSettings.Shape = Aspose.Pdf.Devices.ShapeType.Portrait;
        tiffSettings.SkipBlankPages = false;
        //tiffSettings.Brightness = .40f;

        Stream output = null;
        sourceImages = new System.Drawing.Image[pdfDocument.Pages.Count];
        //create TIFF device
        TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

        for (int page = 1; page <= pdfDocument.Pages.Count; page++)
        {
            Aspose.Pdf.ColorType pageColorType = pdfDocument.Pages[page].ColorType;
            if (pageColorType == ColorType.Rgb)
            {
                tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
            }
            else
            {
                tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp;
            }

            output = new MemoryStream();
            //tiffDevice.Process(pdfDocument, page, page, Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".",page.ToString().PadLeft(3, '0'))));

            tiffDevice.Process(pdfDocument, page, page, output);

            sourceImages[page - 1] = System.Drawing.Image.FromStream(output);
            sourceImages[page - 1].Save(Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".", page.ToString().PadLeft(3, '0'))));
            output = null;
        }
    }
    catch (Exception ex)
    {
        sourceImages = null;
        throw new Exception(String.Format("Error in splitTiffPages: {0}", ex.Message));
    }

    return sourceImages;
}

Hello,

I got the actual issue.
I am trying to save all the
attachments from a .msg file by checking the attachment extension. But
all the extension is showing null except one.
Can you please help me in this.

Here i am attaching the original .msg file
And please see the code with i am using to get the extension of the attachment.

MapiMessage msg = MapiMessage.FromFile(Path.Combine("msgTempPath", "msgFileName"));
int count = 0;
string fileName = "";

foreach (MapiAttachment att in msg.Attachments)
{
    if (att.LongFileName != null)
    {
        fileName = RemoveInvaldFileNameChars(att.LongFileName);

        if (!string.IsNullOrEmpty(att.Extension))
        {
            att.Save(Path.Combine("tempPath", fileName));
        }
    }
}

att.Extension is showing null for some files…

Can you please help me on this urgently?

Regards
Anish

Hi Anish,

Thanks for sharing the details and sorry for the delayed response.

I have tested the scenario using above stated C# code snippet and as per my observations, the PDF pages are properly being converted to TIFF format. For your reference, I have also attached the TIFF images generated over my end.

Now concerning to issue related to attachments extraction from .msg file, my fellow workers from Aspose.Email team is further investigating this scenario and will keep you posted with their findings.

Hi Shahbaz,

Shall i get the replay about my attachment extension issue in same post?
Regards
Anish

Hi Anish,


As shared earlier, my fellow workers from Aspose.Email team will shortly be replying within this thread.

Hi ,

Can you please give at least a reply whether it is the problem with the attached files? Or is is it a problem with the Aspose.Email.dll

Regards
Anish

anishvj:
Hi ,

Can you please give at least a reply whether it is the problem with the attached files? Or is is it a problem with the Aspose.Email.dll
Hi Anish,

In my earlier attempt, I have tried converting Scanned+from+a+Xerox+Multifunction+Device.pdf document shared in first post of this thread and did not notice any issue while rendering it to TIFF format. However in one of your previous posts, you have stated that you are facing issue while extracting attachments from .msg file. In case you are facing any other issue, please share some further details.

Hi Anish,

I have tested the issue of missing file extension and have found that the attachments of this message are having the File Name properties absent. This can be identified by checking for the PR_ATTACH_FILENAME property of the attachment. The attachment samples, though, have the long file names that can be used to save the attachments to disc. Please have a look at the following code smaple for your kind reference.

Sample Code:


string dir = “593675\”;


MapiMessage msg = MapiMessage.FromFile(dir + “E20141201002585.msg”);


foreach (MapiAttachment att in msg.Attachments)

{

if (att.Properties[MapiPropertyTag.PR_ATTACH_FILENAME] == null)

Console.WriteLine(“File name doesn’t exist!”);


Console.WriteLine(att.LongFileName);

att.Save(dir + att.LongFileName);

}

Hi,

Actually i need to skip the invalid attachment from the msg file.
That is the reason i am checking the extension and if the extension is not there i am skipping that file.

In this case , actually it is showing 7 attachment and one we not required from this code
foreach (MapiAttachment att in msg.Attachments)

So how can i skip the invalid file in my case ?

Regards
Anish

Hi Anish,

There are six regular attachments and one inline image of size 1x1 pixel (while color) in this message file due to which it is showing a total of seven attachments. The PR_ATTACH_FILENAME and PR_ATTACH_EXTENSION both are NULL for all these attachments. However, the Long file name exists for all these as shown in the attached screenshot and you can exclude the unnecessary attachment based on the extension from this long file name. Please let us know if we can be of any additional help to you in this regard.

Hi Kashif Iqbal,

Let me explain my requirement.

In the msg file it may contains lots of attachment. And i need to save only the files which is attached with the msg file.

So i was using a logic to check the extension of the file name and if extension is null then i am skipping that particular file.


png files also can come as valid attachment.

As per your suggestion by checking the long file name i can’t exclude the file, because we are getting daily more than 1000 of emails and it has valid attachments.

I think now you got my problem

Regards
Anish

Hi Anish,

I understand your query. However, in this particular case, all the extensions are null which can not be of help. There is no other way to identify other than the properties available for the attachments such as File name, extension and long file name.

Hi Anish,

You can also try using FileFormatUtil.DetectFileFormat method from Aspose.Word and Aspose.Cells etc. to detect file format if this helps. In fact Aspose.Cells method can detect more file formats as compared to Aspose.Words as you can see at http://www.aspose.com/docs/display/cellsnet/Aspose.Cells.FileFormatType+Enumeration

Unknown format will be returned if file is not recognized by any API.

Best Regards,

I have noticed one more thing.

If i am downloading the attachment from the .msg file and then i attach the same file with another mail from my outlook , then it is showing the extension.

So is this finding help you to identify why the propery is missing at first time ?

Regards
Anish

Hi Anish,

The behavior is nothing to do with Aspose.Email API as it reads the respective properties for determining if the extension is available or not. While attaching the same file again from Outlook, the properties might have get added and, hence, Aspose.Email also reads those. Please feel free to share if you have further inquiries in this regard.

Hi,

Is there any way i can explaine to my custommer that this particular files doesn't have Property?

Because if i right click in the file , then i can see the property of the file.

So in this which property is missing , so that i can explain to my custommer about this and they will not send such kind of files.

Regards

Anish