Sign In  Sign Up Live-Chat

Error: Insert 2 tiffs to one pdf

Last post 09-04-2007, 12:19 AM by Hans.firefox. 4 replies.
Sort Posts: Previous Next
  •  08-27-2007, 8:52 AM 92374

    Error: Insert 2 tiffs to one pdf

    If I create a new pdf and insert 2 different multiframe tiff-images, the first image is inserted twice.
    Where is my bug? Kind regards

    using System;
    using System.Drawing;
    using System.IO;
    using Aspose.Pdf;
    using Aspose.Pdf.Kit;
    using System.Drawing.Imaging;

    namespace TiffDebug
    {
        class Mini
        {
            static void Main(string[] args)
            {
                String tiffFile = args[0];
                String tiffFile2 = args[1];

                String outputFile = @"c:\temp\out.pdf";

                Pdf pdf = new Pdf();


                FileStream tiffStream = new FileStream(tiffFile, FileMode.Open, FileAccess.Read);
                addTiff(pdf, tiffStream);
                FileStream tiffStream2 = new FileStream(tiffFile2, FileMode.Open, FileAccess.Read);
                addTiff(pdf, tiffStream2);

                pdf.Save(outputFile);
                tiffStream.Close();
                tiffStream2.Close();
            }

            private static Pdf addTiff(Pdf pdf, Stream source)
            {
                Bitmap bitmap = new Bitmap(source);
                for (int i = 0; i < bitmap.GetFrameCount(FrameDimension.Page); i++)
                {
                    addTiffFrame(pdf, source, i, bitmap);
                }
                return pdf;
            }

            public static Pdf addTiffFrame(Pdf pdf, Stream source, int frame, Bitmap bitmap)
            {
                Aspose.Pdf.Section sec1 = pdf.Sections.Add();
                sec1.PageInfo.Margin.Top = 0;
                sec1.PageInfo.Margin.Left = 0;
                sec1.PageInfo.Margin.Right = 0;
                sec1.PageInfo.Margin.Bottom = 0;
                Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);

                if (bitmap != null)
                {
                    bitmap.SelectActiveFrame(FrameDimension.Page, frame);
                    if (bitmap.Height >= bitmap.Width)
                    {
                        sec1.PageInfo.PageWidth = Aspose.Pdf.PageSize.A4Width;
                        sec1.PageInfo.PageHeight = Aspose.Pdf.PageSize.A4Height;
                        if ((float)bitmap.Width / (float)bitmap.Height >= sec1.PageInfo.PageWidth / sec1.PageInfo.PageHeight)
                        {
                            image1.ImageInfo.FixWidth = sec1.PageInfo.PageWidth;
                        }
                        else
                        {
                            image1.ImageInfo.FixHeight = sec1.PageInfo.PageHeight;
                        }

                    }
                    else
                    {
                        sec1.PageInfo.PageWidth = Aspose.Pdf.PageSize.A4Height;
                        sec1.PageInfo.PageHeight = Aspose.Pdf.PageSize.A4Width;
                        if ((float)bitmap.Width / (float)bitmap.Height >= sec1.PageInfo.PageWidth / sec1.PageInfo.PageHeight)
                        {
                            image1.ImageInfo.FixWidth = sec1.PageInfo.PageWidth;
                        }
                        else
                        {
                            image1.ImageInfo.FixHeight = sec1.PageInfo.PageHeight;
                        }
                    }
                }

                sec1.Paragraphs.Add(image1);
                image1.ImageInfo.ImageStream = source;
                image1.ImageInfo.ImageFileType = ImageFileType.Tiff;
                image1.ImageInfo.TiffFrame = frame;
                image1.ImageInfo.IsAllFramesInNewPage = true;
                return pdf;
            }
        }
    }

     
  •  08-27-2007, 1:57 PM 92423 in reply to 92374

    Re: Error: Insert 2 tiffs to one pdf

    Attachment: Present (inaccessible)

    Hi,

    Thank you for considering Aspose.

    I have test your code and I am unable to reporduce the error. I am sending you the pdf file which i generated from your code. Are you using the latest version of Aspose.pdf.

    Thanks.

     
  •  08-28-2007, 1:35 AM 92484 in reply to 92423

    Re: Error: Insert 2 tiffs to one pdf

    Attachment: Present (inaccessible)
    I am using Aspose.pdf v3.5.5.0.
    Find inputs and output attached.
     
  •  08-28-2007, 11:34 AM 92601 in reply to 92484

    Re: Error: Insert 2 tiffs to one pdf

    Hi,

    I am able to reproduce this  error. I have logged this issue as  PDFNET-3662. I will discuss this with the developers and we will let you know as soon as solution is found.

    Thanks.

     
  •  09-04-2007, 12:19 AM 93307 in reply to 92374

    Re: Error: Insert 2 tiffs to one pdf

    Attachment: Present (inaccessible)
    Hi,

    The bug has been fixed. Please try the attachment before we publish new hotfix.

    Best regards.
    Hans


    Hans Zhang
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML