We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Conversion to tif or png

Generally, the conversion from PDF to TIF or PNG is quite satisfactory.

I encountered a problem with one pdf file. It is a complex map with text and image overlays.
The attached pdf is displayed correctly in the syncfusion pdf viewer

However, when converted to tif or png using code such as the one posted here
https://www.syncfusion.com/kb/9112/how-to-convert-pdf-to-png
the resulting tif or png is quite different



Attachment: ErrDisplay_91b80197.zip

14 Replies

KC Karthikeyan Chandrasekar Syncfusion Team October 17, 2018 12:20 PM UTC

Hi Alain, 
The reported issue is resolved while exporting the PDF pages as images by using the PdfViewercontrol with Pdfium rendering engine. 
Please find the below code snippet to export the PDF pages as images using PdfViewerControl with Pdfium rendering engine. From the essential studio version 16.3.0.21, the default rendering engine of PdfViewerControl is Pdfium. So, there is no need to set the rendering engine of PdfViewercontrol as Pdfium in sample level. 
PdfViewerControl pdfViewer = new PdfViewerControl(); 
pdfViewer.Load(@"ErrDisplay.pdf"); 
Bitmap image = pdfViewer.ExportAsImage(0); 
image.Save("Image.png", ImageFormat.Png); 

Please find the UG documentation link for exporting the PDF document as images using PdfViewerControl.
https://help.syncfusion.com/windowsforms/pdfviewer/working-with-pdf-viewer#exporting-pdf

 
Regards, 
Karthikeyan  



AL Alain October 17, 2018 04:09 PM UTC

Thanks, this is better.

However, this is a bit confusing.
I understand the PDFViewerControl is using the pdfium rendering engine.
But it is not the case for PDFLoadedDocument ?


KC Karthikeyan Chandrasekar Syncfusion Team October 18, 2018 05:12 AM UTC

Hi Alain, 
We use Pdfium only for rendering PDF document in our PDF Viewer, and we do not use is in PdfLoadedDocument. Please let us know if you need any further assistance in this. 

Regards, 
Karthikeyan 



AL Alain October 18, 2018 01:10 PM UTC

Looks good. Case closed. Thank you !


AL Alain October 18, 2018 03:50 PM UTC

Well, there is still a problem.
The viewer does not release the displayed file completely, I can't delete it.
So the following triggers an exception.

PdfViewerControl pdfViewer = new PdfViewerControl(); 
pdfViewer.Load(@"ErrDisplay.pdf"); 
pdfViewer.Dispose();

try
{
     IO.file.Delete(@"ErrDisplay.pdf")
}
catch (Exception ex)
{
     Debug.Print(ex.message);
}


However, if I use
pdfViewer.RenderingEngine = PdfRenderingEngine.SfPdf
there is no such problem.
there is no problem.



KC Karthikeyan Chandrasekar Syncfusion Team October 19, 2018 05:37 AM UTC

Hi Alain, 
We are able to reproduce this issue and it is already fixed. This fix will be included in our upcoming 2018 Vol-3 SP1 release which is expected to be available in the end of October. 

Regards 
Karthikeyan 



AL Alain October 31, 2018 09:52 PM UTC

I have installed the latest
Version : 16.3.0.29 (Service Pack)
Released on : Oct 30, 2018

Other issues I had seems OK now.

However this issue is still there.
using Syncfusion.Windows.Forms.PdfViewer;
PdfViewerControl pdfViewer = new PdfViewerControl(); 
pdfViewer.Load(@"ErrDisplay.pdf"); 
pdfViewer.Dispose();

try
{
     IO.file.Delete(@"ErrDisplay.pdf")
}
catch (Exception ex)
{
     Debug.Print(ex.message);
}


KK Karthik Krishnaraj Syncfusion Team November 1, 2018 02:14 PM UTC

 
Hi Alian, 
 
We were unable to reproduce the issue. Here we could load and dispose the document properly. I have attached the sample and video for your reference. Can you please modify the sample to replicate the issue? It will be helpful for us to analyze further and provide better solution. 
 
Sample Link: 
 
Video Link: 
 
Regards, 
Karthik. 



AL Alain November 2, 2018 02:03 PM UTC

Thanks, I tried your code snippet and it worked fine.


However, in your example

instead of
control.Load(@"D:\HTTP Succinctly.pdf");

use the following
control.Load(@"D:\HTTP Succinctly.pdf","");

This should trigger the exception.


Also, I tried with a pdf AES 256 rev B encrypted with the password X12345
and I used the following
control.Load(@"D:\HTTP Succinctly Encrypted X.pdf","X12345");

Should also trigger the exception, even if we provide a valid owner password !




DB Dilli Babu Nandha Gopal Syncfusion Team November 5, 2018 03:42 PM UTC

Hi Alain,  
  
We are afraid that we are unable to reproduce the exception while loading the encrypted PDF document in our PDF viewer control Windows Forms platform. We suspect that the issue occurred with specific to the PDF document you are using in your end. So, we request you to provide the PDF document with which the issue could be reproduced.  
  
Note: If you have any confidential data in your PDF document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.  
  
Regards, 
Dilli babu. 



AL Alain November 5, 2018 04:25 PM UTC

Hi, I don't believe it depends of the pdf

In the zip file, you will find pdftest.pdf

using Syncfusion.Windows.Forms.PdfViewer;
PdfViewerControl pdfViewer = new PdfViewerControl(); 

//pdfViewer.Load(@"pdftest.pdf");  //this is not raising an exception
pdfViewer.Load(@"pdftest.pdf","");  //when providing an empty password, it will raise the exception
//pdfViewer.Load(@"pdftest.pdf","alain");  //alain is the admin password, it will also raise the exception

try
{
     IO.file.Delete(@"pdftest.pdf");
}
catch (Exception ex)
{
     Debug.Print(ex.message);
}





Attachment: pdftest_beb8634c.zip


BS Balasubramanian Sundararajan Syncfusion Team November 6, 2018 07:36 AM UTC

Hi Alain,   
 
Thank you for your update. 
   
Still we could not reproduce the exception while loading the encrypted PDF document in our PDF viewer control Windows Forms platform. Also we have created a simple sample to reproduce the reported exception with the PDF document attached by you in your previous update.  Can you please modify the sample to replicate the issue? It will be helpful for us to analyze further and provide better solution.  
 
 
Please let me know if you have any concern. 
 
Thanks, 
Balasubramanian S 



AL Alain November 6, 2018 02:24 PM UTC

In form1.cs, use this instead

public Form1()

{

InitializeComponent();

pdfViewerControl1.Load("../../Data/pdftest.pdf", "alain");

pdfViewerControl1.Dispose(); //This is supposed to clear all resources used by the viewer.

System.IO.File.Delete("../../Data/pdftest.pdf"); //<--- This is raising an exception, the file pdfviewer.pdf is "used by another process"

}



KK Karthik Krishnaraj Syncfusion Team November 9, 2018 09:44 AM UTC

Hi Alain, 
 
We have confirmed that the reported case is a defect from our side. We will include the fix for this issue in our Essential Studio Volume 4 release which will be rolled out in the month of December 2018. 
 
Regards, 
Karthik. 


Loader.
Live Chat Icon For mobile
Up arrow icon