PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bitonal tiff images bug/adding from System Bitmap

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
neilw



Joined: 31 Mar 2009
Posts: 3

PostPosted: Tue Mar 31, 2009 12:32 pm    Post subject: bitonal tiff images bug/adding from System Bitmap Reply with quote

Hello,
I've just started using pdfSharp and wondered if anyone can answer these two simple questions.

1. Is there a way to add an image from anything other than a file? I already have the Bitmap in memory so it seems a bit daft to save it then add it to the pdf. I saw Add() method but that takes a pdfsharp type of image, whereas I have a System.Drawing.Image

2. If I add an image to my pdf (using AddImage) and my image is a png or a 24bpp tiff, all is well. If I add a bitonal tiff (I've tried 200dpi and 96dpi) all I get is the top corner of the image. I have to set the page height/width to a massive number in order to show it. I tried using:
section.PageSetup.PageHeight = Unit.FromPoint(i.Height*72/i.VerticalResolution);

But the same thing happens. It is only with bitonal TIFF that fails.



Thanks.
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Tue Mar 31, 2009 1:21 pm    Post subject: Reply with quote

Hi!

Re 1:
With PDFsharp you can use System.Drawing.Image; with MigraDoc you need a file-based image.

Re 2:
Should be simple with PDFsharp (see PageSizes sample).
Should also work with MigraDoc (you need a new section for every new page).

Depending on your images it may be more convenient for the user to have a constant page size and to re-size the images to fit the page (maintaining the aspect ratio so you'll get some padding).

If only certain TIFF files fail there may be something special about them - or there may be a bug in MigraDoc/PDFsharp with respect to those special images.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
neilw



Joined: 31 Mar 2009
Posts: 3

PostPosted: Tue Mar 31, 2009 1:25 pm    Post subject: Reply with quote

Thanks.

I used migradoc because it said pdfsharp was the low level library and all I wanted was some simple stuff. So I'll check it out to see how easy it is.

As for the TIFF, I've found the problem. I was using a 1bpp conversion library I found at CodeProject but there's a bug in that they don't save the dpi so the file thinks it is 96 when in fact it is something else (200 in my case). This is what you get for trusting somebody else's code Wink
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Tue Mar 31, 2009 1:42 pm    Post subject: Reply with quote

neilw wrote:
This is what you get for trusting somebody else's code Wink

Own, untested code can be even worse ...
Glad to hear it's not a PDFsharp bug.

MigraDoc is fine if you have lots of text and don't want to manage page breaks.

You want one image per page, therefore I think PDFsharp may be appropriate.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
neilw



Joined: 31 Mar 2009
Posts: 3

PostPosted: Tue Mar 31, 2009 1:52 pm    Post subject: Reply with quote

Thanks again.

I see that pdfsharp can load from a Graphics object, whereas I have a Bitmap. Obviously it's quicker from memory than file, but is there a way to create a page from a Bitmap rather than a Graphics object, or is the conversion (Graphics.FromBitmap) almost cost free (I don't know what is actually involved in this call) and I'm worrying too much about nothing.

I'm just trying to make it as quick as possible as I have to convert about 9 million images to pdf files. It was about 200ms to load and convert my images to bitonal and save as tiff files, but using the migradoc as I originally did upped it to about 2 seconds (convert to bitonal and save as pdf).
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Apr 01, 2009 11:33 am    Post subject: Reply with quote

JPEGs are simply copied into the PDF file, everything else needs to be converted. That conversion is my only contribution to PDFsharp and I hope it's quick (written in C#).
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com