[C#/VB.NET] PDF to TIFF using Color Detection
Re: [C#/VB.NET] PDF to TIFF using Color Detection
I used the sample code provided to convert PDF to TIFF using color detection however some of the image disappears in the tif file. If I do not use color detection then all the lines appear. I've uploaded two tiff files. GrayWallProblem.tif which is missing lines and GrayWall_Correct.tif which is how it should look. GrayWallProblem.tif was created using ColorDectection. Any insight on this would be appreciated. Thank you.
Code: Select all
Private Sub CreateTiffs(File As String, OutputFilePath As String, RevisionNumber As String)
Dim oGdPicturePDF As New GdPicturePDF
Dim oGdPictureImaging As New GdPictureImaging
If oGdPicturePDF.LoadFromFile(File, False) = GdPictureStatus.OK Then
Dim tiffID As Integer = 0
Dim PageCount As Integer = oGdPicturePDF.GetPageCount()
Me.ProgressBar1.Maximum = PageCount
For i As Integer = 0 To PageCount - 1
oGdPicturePDF.SelectPage(i + 1)
'rasterize page or extract page bitmap.
Dim rasterPage As Integer = oGdPicturePDF.RenderPageToGdPictureImageEx(200.0F, True, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim tiffCompression__1 As TiffCompression = TiffCompression.TiffCompressionCCITT4 'defines the compression of the tiff page. Let's use CCITT4 for bitonal pages and JPEG for others.
'apply color detection and color depth automatic conversion.
'oGdPictureImaging.ColorDetection(rasterPage, True, False, False)
'If oGdPictureImaging.GetBitDepth(rasterPage) = 1 Then
' tiffCompression__1 = TiffCompression.TiffCompressionCCITT4
'Else
' tiffCompression__1 = TiffCompression.TiffCompressionJPEG
'End If
If i = 0 Then
oGdPictureImaging.TiffSaveAsMultiPageFile(rasterPage, OutputFilePath, tiffCompression__1)
'first rasterizer page GdPicture ID becomes the multipage tiff id.
tiffID = rasterPage
Else
oGdPictureImaging.TiffAddToMultiPageFile(tiffID, rasterPage, tiffCompression__1)
oGdPictureImaging.ReleaseGdPictureImage(rasterPage)
End If
Me.ProgressBar1.Value += 1
Next
oGdPictureImaging.TiffCloseMultiPageFile(tiffID)
oGdPictureImaging.ReleaseGdPictureImage(tiffID)
Me.ProgressBar1.Value = 0
SplitTif(OutputFilePath, "original")
GC.Collect()
GC.WaitForPendingFinalizers()
Else
MessageBox.Show("Can not open file. Status: " + oGdPicturePDF.GetStat().ToString())
End If
End Sub
- Attachments
-
- This was created without color detection.
- GrayWall_Correct.tif (830.59 KiB) Viewed 23692 times
-
- This was created with color detection.
- GrayWallProblem.tif (47.65 KiB) Viewed 23692 times
Re: [C#/VB.NET] PDF to TIFF using Color Detection
Hello Ken,
That's an interesting case. We've enhanced the engine to produce the attached result. If our regressive tests are good the next minor release will fix it.
Kind regards,
Loïc
That's an interesting case. We've enhanced the engine to produce the attached result. If our regressive tests are good the next minor release will fix it.
Kind regards,
Loïc
Re: [C#/VB.NET] PDF to TIFF using Color Detection
When is the minor release scheduled?
Re: [C#/VB.NET] PDF to TIFF using Color Detection
On next Monday.
Re: [C#/VB.NET] PDF to TIFF using Color Detection
When using ColorDetection with AutoConvert when the bitdepth = 1 GDPicture converts the image to a mode that when the tif file is opened in Adobe PhotoShop the image mode is "Bitmap" (don't confuse this with the file type bmp; it's not a bitmap file, its image mode is Bitmap) What GDPictureImaging.ConvertTo method do I need to use to duplicate the same AutoConvert during ColorDetection? The end result is that when I open the Tif in PhotoShop it should have an Image Mode of Bitmap. Thanks.
Re: [C#/VB.NET] PDF to TIFF using Color Detection
Hi Ken,
Could you clarify please? I do not understand a word of what you are trying to explain.
Thank you for your efforts.
With best regards,
Loïc
Could you clarify please? I do not understand a word of what you are trying to explain.
Thank you for your efforts.
With best regards,
Loïc
Re: [C#/VB.NET] PDF to TIFF using Color Detection
Using the code below, I am converting pdf to tiff using ColorDetection. I have the AutoConvert parameter set to True. After the tiff files are saved I open them in PhotoShop. The "Image Mode" is Bitmap (see attached image). What conversion is used during the AutoConvert process to make a tiff file with an Image Mode of Bitmap?
Code: Select all
PDFPageID = oGdPicturePDF.RenderPageToGdPictureImageEx(200.0F, False, Imaging.PixelFormat.Format24bppRgb)
oGdPictureImaging.ColorDetection(PDFPageID, True, False, False)
If oGdPictureImaging.GetBitDepth(PDFPageID) = 1 Then
Compression = TiffCompression.TiffCompressionCCITT4
Else
Compression = TiffCompression.TiffCompressionJPEG
End If
oGdPictureImaging.TiffSaveAsMultiPageFile(PDFPageID, FullOutputFileName, Compression)
oGdPictureImaging.TiffCloseMultiPageFile(PDFPageID)
oGdPictureImaging.ReleaseGdPictureImage(PDFPageID)
Re: [C#/VB.NET] PDF to TIFF using Color Detection
I don't understand what the problem is. What did you expect to obtain instead of Bitmap?
In your case the produced document is bitonal, using black & white color palette entries.
Kind regards,
Loïc
In your case the produced document is bitonal, using black & white color palette entries.
Kind regards,
Loïc
Re: [C#/VB.NET] PDF to TIFF using Color Detection
I'm sorry that I am not being clear. How do I produce the same result without using ColorDection. How do I take a color pdf and make a tiff that has an Image Mode of bitmap??
Who is online
Users browsing this forum: No registered users and 1 guest