ASPOSE.PDF - Converting TIFF To PDF Gives Blank PDF

Hi Aspose Team,

Related to the thread below …

ASPOSE.PDF - Converting TIFF To PDF Throws System.NullReference Exception

We installed the below set of fonts in DEV/QA PCF machine of Ubuntu flavor. We are trying to convert TIFF image to PDF, which works fine in LOCAL (Windows) machine but in DEV/QA machine I get a blank pdf only with ASPOSE evaluation text in header.

Sample generated PDF

image.png (6.3 KB)

Fonts (Set) Installed:

AndaleMo.TTF Ariali.TTF Comicbd.TTF courbi.ttf Georgiab.TTF Georgiaz.TTF Timesbd.TTF Times.TTF trebucit.ttf Verdanai.TTF Webdings.TTF
Arialbd.TTF Arial.TTF Comic.TTF couri.ttf Georgiai.TTF Impact.TTF Timesbi.TTF Trebucbd.ttf trebuc.ttf Verdana.TTF
Arialbi.TTF AriBlk.TTF courbd.ttf cour.ttf Georgia.TTF README.md Timesi.TTF trebucbi.ttf Verdanab.TTF Verdanaz.TTF

Can you please shade some light why the issue is? Are those fonts enough to work with (OR) we are missing any other fonts package to be installed?

Thanks,
Sirsendu

@sirsendu.m

As mentioned in referred thread, all windows fonts needs to be installed in the system where you are generating PDF files. If PDF needs to use some font which is not present in that set, you need to install that font separately. You can check in the properties of PDF (generated in windows) which fonts it used during generation and verify if those are present in the Linux system or not.

In case issue still persists, please share your sample TIFF file along with sample code snippet with us. We will test the scenario in our environment and address it accordingly. Also, please make sure to use a valid license while performing conversion.

@asad.ali asad - Appreciate your prompt response. To provide more information – yes we have installed all the required fonts as in referred previous support thread and we tested and observed that the TIFF to PDF conversion worked fine.

For your ease of reference, below are the fonts we installed
image.png (17.4 KB)

Per your suggestion, I checked the PDF properties and found that it’s using “Arial (Embedded Subset)” TrueType fonts (see blow). Which I believe we have already installed (see highlighted fonts TTF file in above screen pic)
image.png (14.8 KB)

But still converted PDF is having only blank page. I have no idea why?

I see you have mentioned to install “All Windows Fonts” when you say

As mentioned in referred thread, all windows fonts needs to be installed in the system where you are generating PDF files

  1. Do we really need to install all (every) fonts available under “C:\Windows\Fonts” directory?

  2. Are the subset of fonts installed currently by us not sufficient? (OR) installed subset of fonts could be an issue that converted PDF document having only blank pages?

I looked into other similar issues related to ASPOSE.PDF library “Converting TIFF To PDF Generated Blank Pages” but none them are helpful for me.

I am using below code (C#) for the conversion process. Do you see any issues with the implemented code

            // Set Fonts Directory If Directory Exists
            if (System.IO.Directory.Exists(Constants.ASPOSE_PDF_FONTS_DIRECTORY))
            {
                Aspose.Pdf.Text.FontRepository.Sources.Add(new Aspose.Pdf.Text.FolderFontSource(Constants.ASPOSE_PDF_FONTS_DIRECTORY));
            }

            Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();

            //Convert Tiff document image into bytes stream.
            using (var ms = new System.IO.MemoryStream(ConfirmationDocument))
            {
                // Converting bytes into Image from the (image bytes)
                System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);

                //Pass the Image for converion into PDF
                System.Drawing.Bitmap myimage = new System.Drawing.Bitmap(returnImage);

                // Convert multi page or multi frame TIFF to PDF
                System.Drawing.Imaging.FrameDimension dimension = new System.Drawing.Imaging.FrameDimension(myimage.FrameDimensionsList[0]);
                int frameCount = myimage.GetFrameCount(dimension);

                for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
                {
                    Page sec = pdf.Pages.Add();

                    myimage.SelectActiveFrame(dimension, frameIdx);

                    var currentImage = new System.IO.MemoryStream();

                    myimage.Save(currentImage, System.Drawing.Imaging.ImageFormat.Tiff);
                    Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
                    imageht.ImageStream = currentImage;
                    sec.Paragraphs.Add(imageht);
                }

                //Convert/Saving file into PDF Format
                using (var stream = new System.IO.MemoryStream())
                {
                    pdf.Save(stream, Aspose.Pdf.SaveFormat.Pdf);

                    //Converting Pdf File To Bytes
                    byte[] weFaxPdfDocumentBytes = stream.ToArray();
                    return weFaxPdfDocumentBytes;
                }

ASPOSE.PDF version 20.3.0
Sample TIFF Image - You can use any multi-page TIFF image as sample
Extra Note: We are receiving byte[] of the TIFF image and converting that to PDF byte[] which is getting saved to external file storage.
OS Platform: Non Windows PCF Server (Ubuntu / Linux)
License: Confirmed and we are using a valid license only for ASPOSE.TOTAL For .NET (Latest Version).

Please help on this. I am trying to work on a critical issue at my end and kind of held up because of this. Let me know if you need any other information from my end?

Another Question: Can you please provide me a sample C# code to convert multi-page TIFF image to PDF.

Waiting for a early response from your end. Thank You.

@asad.ali Asad - Also per ASPOSE.PDF Documentation

Please install:

  1. libgdiplus package
  2. package with Microsoft compatible fonts: ttf-mscorefonts-installer. (e.g. sudo apt-get install ttf-mscorefonts-installer )

If I look over and see; essentially mscorefonts have below fonts only … which we have anyways installed in our DEV/QA machine (based on the installed subset fonts list I have provided earlier). That means, fonts can’t be an issue here for the observed problem.

Arial, Arial Black, Comic Sans MS, Courier New, Georgia, Impact, Times New Roman, Trebuchet, Verdana and Webdings

Reference:

How to install Microsoft fonts on Linux - OnMSFT.com.

@sirsendu.m

Sorry for the delayed response.

Your code snippet and installed fonts seem fine as per the details you have shared with us. As per your request, please check following sample C# code to generate PDF from a Multipage TIFF:

Document pdf1 = new Document();

FileStream ms = new FileStream(dataDir + "test.tiff", FileMode.Open);
Bitmap myimage = new Bitmap(ms);
FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);

for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
{
 Page sec = pdf1.Pages.Add();
 myimage.SelectActiveFrame(dimension, frameIdx);
 MemoryStream currentImage = new MemoryStream();
 myimage.Save(currentImage, ImageFormat.Tiff);
 if (myimage.Width > myimage.Height)
 {
  sec.PageInfo.IsLandscape = true;
 }
 else
 {
  sec.PageInfo.IsLandscape = false;
 }
 sec.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
 sec.PageInfo.Height = myimage.Height;
 sec.PageInfo.Width = myimage.Width;
 Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
 imageht.ImageStream = currentImage;
 sec.Paragraphs.Add(imageht);
}
pdf1.Save(dataDir + "TifftoPDF.pdf");

Furthermore, we are testing the scenario using Aspose.PDF for .NET 20.9 in our environment and will get back to you in a while. Please give us some time.

@asad.ali Appreciate for the response. Have you had a chance to investigate the issue at your end? Did you found anything? Would appreciate if you can expedite the investigation/resolution on this issue.

Again, Thanks for sharing the sample code for converting multi-page tiff to pdf. I tried the same as-is, except the below change; since my requirement is to return a byte[]

pdf1.Save(dataDir + "TifftoPDF.pdf"); 

Changed to

using (var stream = new System.IO.MemoryStream())
{
   pdf.Save(stream);
   //Converting Pdf File To Bytes
   PdfDocumentBytes = stream.ToArray();                        
 }			
return PdfDocumentBytes;

But while testing, I sent a fax and choose the 3 pictures separately (see attached screen pic) …

image.jpg (176.5 KB)

But in the converted PDF I could see only 1 page. see the below attached image … observe the red highlighted circled part … it very well says page 1 out of 3 … BUT there is only 1 page. Rest of the pages are simply LOST in conversion.

image.png (204.2 KB)

Please provide a resolution for this issue as well as early possible.

@sirsendu.m

We tested the scenario in an environment i.e. CentOS 7 64-bit, Aspose.PDF for .NET 20.9 and faced an Exception. TypeInitializeError.png (182.8 KB) We confirm that environment has all essential fonts and libgdiplus package installed. Nevertheless, we have logged an issue as PDFNET-48803 in our issue management system for your this case.

We will further look into its details and keep you informed with the status of its rectification. Please be patient and spare us some time.

We apologize for the inconvenience caused.

@asad.ali I am a coworker of @sirsendu.m. The type initialization error you report I also saw:

image.png (34.4 KB)

…this is resolved by installing:

sudo apt-get install libgdiplus

Now the issue I’m seeing is that my sample code will generate output when run on Windows, but not on Linux (using our desired setup of Ubuntu 18.04 w/ libstdc++7).

image.png (104.8 KB)

Please refer to the attached ZIP file.

I have tried to “save” the PDF object as both a file on disk as well as a memory stream - same error either way.aspose-poc.zip (14.2 KB)

@mcorven

We are further checking the scenario and will get back to you in a while.

@asad.ali Any update on the ticket PDFNET-48803? As well on the issue posted by @mcorven

We are waiting on a quick resolution for this; as we are kind of blocked due to this which will essentially impact the delivery. Please let know early by when we can expect a fix (OR) at least a workaround for this issue? It’s been already 7 days the ticket has been logged at your end.

Thank You.

@sirsendu.m

We are afraid that the ticket is not yet resolved. However, we have escalated its priority to next level and as soon as it is investigated completely, we will inform you.

We again tested the scenario in our environment i.e. CentOS 7 - x64 and still faced the exception shared earlier. We installed latest version of libgdiplus as well as CoreCompat.System.Drawing but, it did not give any success. The information under the logged ticket is already updated. We surely understand your concerns and will definitely consider them while analyzing the issue further. We highly appreciate your patience in this regard. Please give us some time.

We apologize for the inconvenience.

The issues you have found earlier (filed as PDFNET-48803) have been fixed in Aspose.PDF for .NET 23.3.