full Black/blank Pages on colored pages

With the following code, I create a PDF document from a tif file, if necessary, but when I save the file and some of its pages have color like ink, image or something, the pages turn out completely black. Am I doing something wrong?

 public PdfLoadedDocument GetPDF(FileInfo FOrigen, String tempfile = "", bool EliminaORigen = false)

        {


            PdfLoadedDocument _pdfloadedDocument;

            try

            {

                if(FOrigen.Extension.ToLower() == ".pdf")

                    System.IO.File.Copy(FOrigen.FullName, tempfile);

                else

                {

                    PdfDocument _pdfDocument = new PdfDocument();

                    _pdfDocument.PageSettings.Margins.All = 0;

                    //Get the image stream and draw frame by frame

                    using (var tiffImage = new PdfBitmap(FOrigen.FullName))

                    {

                        int frameCount = tiffImage.FrameCount;

                        for (int i = 0; i < frameCount; i++)

                        {

                            //Add pages to the document

                            var page = _pdfDocument.Pages.Add();

                            //Getting page size to fit the image within the page

                            SizeF pageSize = page.GetClientSize();

                            //Selecting frame in TIFF

                            tiffImage.ActiveFrame = i;

                            //Draw TIFF frame

                            page.Graphics.DrawImage(tiffImage, 0, 0, pageSize.Width, pageSize.Height);

                        }

                        tiffImage.Dispose();

                    }

                    _pdfDocument.Compression = PdfCompressionLevel.Best;

                    _pdfDocument.Save(tempfile);

                    _pdfDocument.Close();


                }

                _pdfloadedDocument = new PdfLoadedDocument(tempfile);

                if (EliminaORigen && File.Exists(FOrigen.FullName))

                    File.Delete(FOrigen.FullName);

                return _pdfloadedDocument;

            }

            catch(Exception)

            {

                if (EliminaORigen && File.Exists(FOrigen.FullName))

                    File.Delete(FOrigen.FullName);

                throw;

            }


        }

-----------------------------------

private static void SaveOpenpdf(PdfLoadedDocument _pdfloadedDocument, String temppdf)

        {

            _pdfloadedDocument.Compression = PdfCompressionLevel.Best;

            PdfCompressionOptions options = new PdfCompressionOptions

            {

                OptimizeFont = true,

                OptimizePageContents = true,

                CompressImages = true,

                ImageQuality = 10

            };

            _pdfloadedDocument.CompressionOptions = options;

            _pdfloadedDocument.Save(temppdf);

            _pdfloadedDocument?.Close();

        }


1 Reply

RB Ravikumar Baladhandapani Syncfusion Team July 27, 2021 12:21 PM UTC

Hi Jorge, 
 
Thank you for contacting Syncfusion support.  
 
We have tried to reproduce the reported issue based on the details provided, but we are unable to reproduce in our end. We suspect this issue seems to be document specific. So kindly share the original input tif file and output pdf document. It helps us to further investigate on this. We have an NDA (Non-Disclosure Agreement) in place with our customers and we maintain the confidentiality of the information disclosed by our customers to us. Therefore, any documents shared with Syncfusion will only be used to replicate the issue and will not be shared with anyone else. 
 
 
Regards, 
Ravikumar. 


Loader.
Up arrow icon