Converting ICO to multipage TIF or PDF without OCR Issue
Converting ICO to multipage TIF or PDF without OCR Issue
I was testing various conversions with my GdPicture.NET Ultimate SDK, and I discovered that there are some issues converting .ICO files:
1) No pages are available if you try to convert .ICO to multipage TIFF using TiffCreateMultiPageFromGdPictureImage, TiffSaveMultiPageToFile, and TiffAppendPageFromGdPictureImage methods. (Other image types like JPG seem to work fine.)
2) Very odd sized empty pages are created if you try to convert .ICO to multipage PDF using non-OCR PDF methods. (PDF OCR methods work fine.)
Converting these same .ICO files to JPG, PNG, WMF, etc work fine.
----
Is there an estimated release date for the next version? I'm anxiously awaiting the fixes for the bugs we discussed in my last three topic posts.
https://www.gdpicture.com/forum/viewtopic.php?t=2049
https://www.gdpicture.com/forum/viewtopic.php?t=2048
https://www.gdpicture.com/forum/viewtopic.php?t=2025
~ Don ~
1) No pages are available if you try to convert .ICO to multipage TIFF using TiffCreateMultiPageFromGdPictureImage, TiffSaveMultiPageToFile, and TiffAppendPageFromGdPictureImage methods. (Other image types like JPG seem to work fine.)
2) Very odd sized empty pages are created if you try to convert .ICO to multipage PDF using non-OCR PDF methods. (PDF OCR methods work fine.)
Converting these same .ICO files to JPG, PNG, WMF, etc work fine.
----
Is there an estimated release date for the next version? I'm anxiously awaiting the fixes for the bugs we discussed in my last three topic posts.
https://www.gdpicture.com/forum/viewtopic.php?t=2049
https://www.gdpicture.com/forum/viewtopic.php?t=2048
https://www.gdpicture.com/forum/viewtopic.php?t=2025
~ Don ~
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Good and bad news with GdPicture version 6.5.0...
Converting ICO to multipage TIF now works correctly!
Converting ICO to PDF or PDFA without OCR still does not work.
Converting ICO to multipage TIF now works correctly!
Converting ICO to PDF or PDFA without OCR still does not work.
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Hi,
With best regards,
Loïc
It is working for me. Please, give me a code snippet to reproduce your problem and attach the image you are trying to convert.Converting ICO to PDF or PDFA without OCR still does not work.
With best regards,
Loïc
Re: Converting ICO to multipage TIF or PDF without OCR Issue
As I said before, adding any other image type to a PDF using the exact same code below works fine.
Also using the PDF OCR methods to add these same icons will work fine.
(Adding these icons to a multipage TIF works now in 6.5.0.)
This leads me to believe it is a problem with the methods, not the files or code.
Attached are two sample icons I was using to test. The VB.NET code basically looks like this (very simplified):
Also using the PDF OCR methods to add these same icons will work fine.
(Adding these icons to a multipage TIF works now in 6.5.0.)
This leads me to believe it is a problem with the methods, not the files or code.
Attached are two sample icons I was using to test. The VB.NET code basically looks like this (very simplified):
Code: Select all
'create pdf output (no ocr)
intGdPicImgOutputID= gdPicImg.PdfNewPdf("C:\output\IconTest.pdf", false, "Title", "Author", "Subject", "" , "" )
gdPicImg.PdfSetCompressionForColorImage(intGdPicImgOutputID,PdfCompression.PdfCompressionNone)
'get and add ico #1
intGdPicImgInputID1 = gdPicImg.CreateGdPictureImageFromFile("c:\input\BatSymbolIcon.ico")
intPdfImageID1 = gdPicImg.PdfAddImageFromGdPictureImage(intGdPicImgOutputID, intGdPicImgInputID1)
sngPdfImageWidthIn1 = gdPicImg.GetWidthInches(intGdPicImgInputID1)
sngPdfImageHeightIn1 = gdPicImg.GetHeightInches(intGdPicImgInputID1)
'get and add ico #2
intGdPicImgInputID1 = gdPicImg.CreateGdPictureImageFromFile("c:\input\StratixIcon.ico")
intPdfImageID2 = gdPicImg.PdfAddImageFromGdPictureImage(intGdPicImgOutputID, intGdPicImgInputID2)
sngPdfImageWidthIn2 = gdPicImg.GetWidthInches(intGdPicImgInputID2)
sngPdfImageHeightIn2 = gdPicImg.GetHeightInches(intGdPicImgInputID2)
'set pdf measurement unit
gdPicImg.PdfSetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
'add ico #1 page and draw image
gdPicImg.PdfNewPage(intGdPicImgOutputID, sngPdfImageWidthIn1 , sngPdfImageHeightIn1)
gdPicImg.PdfDrawImage(intGdPicImgOutputID, intPdfImageID1, 0, 0, sngPdfImageWidthIn1, sngPdfImageHeightIn1)
'add ico #2 page and draw image
gdPicImg.PdfNewPage(intGdPicImgOutputID, sngPdfImageWidthIn2 , sngPdfImageHeightIn2)
gdPicImg.PdfDrawImage(intGdPicImgOutputID, intPdfImageID2, 0, 0, sngPdfImageWidthIn2, sngPdfImageHeightIn2)
'end pdf output
gdPicImg.PdfEndPdf(intGdPicImgOutputID)
'cleanup
gdPicImg.ReleaseGdPictureImage(intGdPicImgOutputID)
gdPicImg.ReleaseGdPictureImage(intGdPicImgInputID1)
gdPicImg.ReleaseGdPictureImage(intGdPicImgInputID2)
gdPicImg.ReleaseGdPictureImage(intPdfImageID1)
gdPicImg.ReleaseGdPictureImage(intPdfImageID2)
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Don, I'll check this issue tomorrow. We will fix your problem.
Cheers,
Loïc
Cheers,
Loïc
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Thanks, let me know if you need anything else.
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Hi Don,
Your code is wrong. If I understand, you are trying to create a multipage from 2 icons, 1 on each page.
Here a vb.net sample to do that. Let me know if you need more information.
Kind regards,
Loïc
Your code is wrong. If I understand, you are trying to create a multipage from 2 icons, 1 on each page.
Here a vb.net sample to do that. Let me know if you need more information.
Code: Select all
Dim PdfID As Integer = Imaging1.PdfNewPdf("c:\test.pdf")
Dim ImageWidth, ImageHeight As Single
Imaging1.PdfAddImageFromFile(PdfID, "c:\BatSymbolIcon.ico") 'Image 1
Imaging1.PdfAddImageFromFile(PdfID, "c:\StratixIcon.ico") ' Image 2
'Drawing first image
ImageWidth = Imaging1.PdfGetImageWidth(PdfID, 1)
ImageHeight = Imaging1.PdfGetImageHeight(PdfID, 1)
Imaging1.PdfNewPage(PdfID, ImageWidth, ImageHeight)
Imaging1.PdfDrawImage(PdfID, 1, 0, 0, ImageWidth, ImageHeight)
'Drawing second image
ImageWidth = Imaging1.PdfGetImageWidth(PdfID, 2)
ImageHeight = Imaging1.PdfGetImageHeight(PdfID, 2)
Imaging1.PdfNewPage(PdfID, ImageWidth, ImageHeight)
Imaging1.PdfDrawImage(PdfID, 2, 0, 0, ImageWidth, ImageHeight)
Imaging1.PdfEndPdf(PdfID)
Kind regards,
Loïc
Re: Converting ICO to multipage TIF or PDF without OCR Issue
The only major difference I see is that you hardcoded the values 1 and 2 in the PdfDrawImage() methods where I used the returned IDs from the PdfAddImageFromGdPictureImage() methods.
I don't think you can count on those values always being 1 and 2. The documentation says that you should use "value returned by the PdfAddImageFromFile or the PdfAddImageFromGdPictureImage function", which is exactly what I did.
The other differences are different ways to do the same thing. You used PdfAddImageFromFile(), I used CreateGdPictureImageFromFile() + PdfAddImageFromGdPictureImage(). You got your width and height after adding the image to the PDF, I got width and height from the original image.
Note: This is only a problem with ICO files and the PDF non-OCR methods.
If you add a 3rd image and it is any other image type, it will show up in the PDF fine along with the two bad pages from the ICO files... using the exact same code.
Using the PDF OCR methods, ICO files can be added to PDF without issues.
I don't think you can count on those values always being 1 and 2. The documentation says that you should use "value returned by the PdfAddImageFromFile or the PdfAddImageFromGdPictureImage function", which is exactly what I did.
The other differences are different ways to do the same thing. You used PdfAddImageFromFile(), I used CreateGdPictureImageFromFile() + PdfAddImageFromGdPictureImage(). You got your width and height after adding the image to the PDF, I got width and height from the original image.
Note: This is only a problem with ICO files and the PDF non-OCR methods.
If you add a 3rd image and it is any other image type, it will show up in the PDF fine along with the two bad pages from the ICO files... using the exact same code.
Using the PDF OCR methods, ICO files can be added to PDF without issues.
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Here is a screenshot of what the PDF output looks like.
I am using the code I sent you earlier for the PDF on the right.
I'm using almost the same code with the PDF OCR methods for the PDF on the left.
I added the two .ICO files that I attached, then a 2 page TIF, then a JPG to the PDF output.
Notice the PDF OCR methods produce a good PDF with the icons visible on the left side.
The PDF non-OCR methods produce a good PDF, but the icon pages are blank with weird sizes and the other image pages look fine.
http://www.northernshaolinacademy.com/d ... enshot.jpg
(Note: the forum clips images if your window isn't wide enough.)
I am using the code I sent you earlier for the PDF on the right.
I'm using almost the same code with the PDF OCR methods for the PDF on the left.
I added the two .ICO files that I attached, then a 2 page TIF, then a JPG to the PDF output.
Notice the PDF OCR methods produce a good PDF with the icons visible on the left side.
The PDF non-OCR methods produce a good PDF, but the icon pages are blank with weird sizes and the other image pages look fine.
http://www.northernshaolinacademy.com/d ... enshot.jpg
(Note: the forum clips images if your window isn't wide enough.)
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Don,
From your code:
What is intGdPicImgInputID2 ??
intPdfImageID1 & intPdfImageID2 are no GdPicture image. You don't have to release they.
here your code with some basic corrections:
Also, you should add this in your source code:
Hope this helps,
Loïc
From your code:
Code: Select all
intPdfImageID2 = gdPicImg.PdfAddImageFromGdPictureImage(intGdPicImgOutputID, intGdPicImgInputID2)
You can. Don't make confusion between a GdPicture image and a number of an image embedded in a PDF.I don't think you can count on those values always being 1 and 2
Code: Select all
gdPicImg.ReleaseGdPictureImage(intPdfImageID1)
gdPicImg.ReleaseGdPictureImage(intPdfImageID2)
here your code with some basic corrections:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim gdPicImg As New GdPictureImaging
Dim PdfID As Integer
Dim intGdPicImgInputID1, intGdPicImgInputID2 As Integer
Dim intPdfImageID1, intPdfImageID2 As Integer
Dim sngPdfImageWidthIn1, sngPdfImageHeightIn1, sngPdfImageWidthIn2, sngPdfImageHeightIn2 As Double
'create pdf output (no ocr)
PdfID = gdPicImg.PdfNewPdf("C:\IconTest.pdf", False, "Title", "Author", "Subject", "", "")
gdPicImg.PdfSetCompressionForColorImage(PdfID, PdfCompression.PdfCompressionNone)
'get and add ico #1
intGdPicImgInputID1 = gdPicImg.CreateGdPictureImageFromFile("c:\BatSymbolIcon.ico")
intPdfImageID1 = gdPicImg.PdfAddImageFromGdPictureImage(PdfID, intGdPicImgInputID1)
sngPdfImageWidthIn1 = gdPicImg.GetWidthInches(intGdPicImgInputID1)
sngPdfImageHeightIn1 = gdPicImg.GetHeightInches(intGdPicImgInputID1)
'get and add ico #2
intGdPicImgInputID2 = gdPicImg.CreateGdPictureImageFromFile("c:\StratixIcon.ico")
intPdfImageID2 = gdPicImg.PdfAddImageFromGdPictureImage(PdfID, intGdPicImgInputID2)
sngPdfImageWidthIn2 = gdPicImg.GetWidthInches(intGdPicImgInputID2)
sngPdfImageHeightIn2 = gdPicImg.GetHeightInches(intGdPicImgInputID2)
'set pdf measurement unit
gdPicImg.PdfSetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
'add ico #1 page and draw image
gdPicImg.PdfNewPage(PdfID, CSng(sngPdfImageWidthIn1), CSng(sngPdfImageHeightIn1))
gdPicImg.PdfDrawImage(PdfID, intPdfImageID1, 0, 0, CSng(sngPdfImageWidthIn1), CSng(sngPdfImageHeightIn1))
'add ico #2 page and draw image
gdPicImg.PdfNewPage(PdfID, CSng(sngPdfImageWidthIn2), CSng(sngPdfImageHeightIn2))
gdPicImg.PdfDrawImage(PdfID, intPdfImageID2, 0, 0, CSng(sngPdfImageWidthIn2), CSng(sngPdfImageHeightIn2))
'end pdf output
gdPicImg.PdfEndPdf(PdfID)
'cleanup
gdPicImg.ReleaseGdPictureImage(intGdPicImgInputID1)
gdPicImg.ReleaseGdPictureImage(intGdPicImgInputID2)
End Sub
Also, you should add this in your source code:
Code: Select all
Option Strict On
Option Explicit On
Hope this helps,
Loïc
Re: Converting ICO to multipage TIF or PDF without OCR Issue
I just tried the same test with 4 microsoft icon files, just to make sure it isn't my icons that are causing the issue.
The same problem occurs with the microsoft icons.
This is pretty conclusive that the problem is somewhere in the GdPicture.NET PDF non-OCR methods when using ICO input files.
Let me know if you want me to try anything else.
The same problem occurs with the microsoft icons.
This is pretty conclusive that the problem is somewhere in the GdPicture.NET PDF non-OCR methods when using ICO input files.
Let me know if you want me to try anything else.
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Don,
Please consider my previous answer: viewtopic.php?t=2092#p7038
There in not any problem in GdPicture.NET, no problem with your file, only problem with your code...
Cheers,
Loïc
Please consider my previous answer: viewtopic.php?t=2092#p7038
There in not any problem in GdPicture.NET, no problem with your file, only problem with your code...
Cheers,
Loïc
Re: Converting ICO to multipage TIF or PDF without OCR Issue
Sorry, I just saw your previous posts. The code I posted is not the actual code. The actual code is much more complex, and I definitely declare all variables and use option explicit, etc. Broken down and simplified for this problem, those are the methods being used.
If the values returned by PdfAddImageFromGdPictureImage() are not ImageIDs, then my only mistake is trying to release them later. I don't think it would really matter since the release doesn't cause an error and it happens after the PDF is done being created.
Again, this code works for any other type of file EXCEPT ICO files. It works for JPG, BMP, WMF, PNG, multipage TIF, multiframe GIF, etc. It will even add those other types to the same PDF fine and only the ICO pages will have issues.
If the values returned by PdfAddImageFromGdPictureImage() are not ImageIDs, then my only mistake is trying to release them later. I don't think it would really matter since the release doesn't cause an error and it happens after the PDF is done being created.
Again, this code works for any other type of file EXCEPT ICO files. It works for JPG, BMP, WMF, PNG, multipage TIF, multiframe GIF, etc. It will even add those other types to the same PDF fine and only the ICO pages will have issues.
Re: Converting ICO to multipage TIF or PDF without OCR Issue
OK... What is the actual code ??The code I posted is not the actual code
Re: Converting ICO to multipage TIF or PDF without OCR Issue
I tried your code and it does work. There must be a mistake somewhere. I noticed that the heights I am getting from the icons are all 0. I will review all my code thoroughly. Thank you for your help. I'll post if I figure it out.
Who is online
Users browsing this forum: No registered users and 1 guest