PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
TIF to PDF but pdf looks zoomed in and corrupt http://forum.pdfsharp.de/viewtopic.php?f=3&t=3267 |
Page 1 of 1 |
Author: | stevejebson [ Wed Jan 13, 2016 3:53 pm ] |
Post subject: | TIF to PDF but pdf looks zoomed in and corrupt |
Hi, I've been asked to try and debug an app that i didn't write. The app converts TIF's to PDF's however I have a scenario where one works and the other doesn't, i'm wondering if it has anything to do with the Bit Depth but can find nothing in the documentation about this. The TIF with a bit depth of 1 works but a it Depth of 8 doesn't, not that I know what that means ! Source TIF's http://www.bill-brown.com/images/116953726.tif http://www.bill-brown.com/images/116769530.tif PDF's Produced http://www.bill-brown.com/images/116953726-works.pdf http://www.bill-brown.com/images/116769530-failed.pdf And here's the Code.... Code: Dim FN As String
Dim document As New PdfDocument Dim docImage As Image Dim dimension As FrameDimension Dim page As PdfPage Dim pdfImage As XImage = Nothing Dim graphics As XGraphics = Nothing FN = txtTIFLocation.Text & DataRowView("FileName").ToString & ".tif" docImage = Image.FromFile(FN) dimension = New FrameDimension(docImage.FrameDimensionsList(0)) page = New PdfPage pdfImage = XImage.FromGdiPlusImage(docImage) page.Height = pdfImage.PointHeight page.Width = pdfImage.PointWidth document.Pages.Add(page) docImage.SelectActiveFrame(dimension, 0) graphics = XGraphics.FromPdfPage(page) graphics.DrawImage(pdfImage, 0, 0) page.Close() page = Nothing docImage.Dispose() docImage = Nothing graphics.Dispose() graphics = Nothing pdfImage.Dispose() pdfImage = Nothing |
Author: | Thomas Hoevel [ Wed Jan 13, 2016 4:09 pm ] |
Post subject: | Re: TIF to PDF but pdf looks zoomed in and corrupt |
Hi! The file that fails is a JPEG file, not a TIFF file. Try your code under XP, most likely it will work. There is a bug in Windows and some grayscale JPEGs get messed up. You should call "XImage.FromFile(FN)" instead of "Image.FromFile(FN)". And you should try the latest PDFsharp version 1.50 beta 3. Then it should also work with Windows 7, 8.1, and 10. |
Author: | stevejebson [ Wed Jan 13, 2016 5:24 pm ] |
Post subject: | Re: TIF to PDF but pdf looks zoomed in and corrupt |
Thanks for quick reply Thomas, not sure what you mean by "The file that fails is a JPEG file, not a TIFF file" as for sure I'm reading in a TIF file, no jpeg's in sight ! I'll try the beta version though... |
Author: | TH-Soft [ Wed Jan 13, 2016 8:13 pm ] |
Post subject: | Re: TIF to PDF but pdf looks zoomed in and corrupt |
stevejebson wrote: Thanks for quick reply Thomas, not sure what you mean by "The file that fails is a JPEG file, not a TIFF file" as for sure I'm reading in a TIF file, no jpeg's in sight! Open the "TIFF" file with Wordpad or a hex editor and you will see the "JFIF" file header.Try downloading "116769530.tif " with Internet Explorer 11 and it will prompt to save as "116769530.jpg". It is a renamed JPEG file, not a TIFF file. I see the TIF extension, but no TIFF in sight (neither inside). |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |