PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 11:17 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Sep 21, 2009 11:25 pm 
Offline

Joined: Mon Sep 21, 2009 11:17 pm
Posts: 3
Hi,
I'm using pdfsharp version 1.3.

I'm trying to convert multiple multi page tiffs into a single pdf with bookmarks. The code is working, but it take about 3 minutes to convert 225 pages.
Is there anyway for me to increase the speed?

Here are my code:


Dim wid As Integer
Dim max As Integer
Dim hei As Integer
Dim sc As Double
Dim doc As New PdfDocument()
Dim p As Integer = 0
Dim temp As String = rec(0, 1)
Dim outline As PdfOutline
For j = 0 To i - 1
Try
Dim timage As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(rec(j, 0)))
Dim index As guid = timage.FrameDimensionsList(0)
Dim dimension As FrameDimension = New FrameDimension(index)
Dim pagecount As Integer = timage.GetFrameCount(dimension)
For k = 0 To pagecount - 1
timage.SelectActiveFrame(dimension, k)
wid = timage.Width
hei = timage.Height
If wid > hei Then
max = wid
Else
max = hei
End If
If max > 1000 Then
sc = (1000 / max)
wid = CInt(wid * sc)
hei = CInt(hei * sc)
End If
Dim page As New PdfPage()
Dim image As XImage = XImage.FromGdiPlusImage(timage)
page.Width = wid
page.Height = hei
doc.Pages.Add(page)
Dim xgr As XGraphics = XGraphics.FromPdfPage(doc.Pages(p))
If p = 0 Or temp <> rec(j, 1) Then
outline = doc.Outlines.Add(rec(j, 1), page, True, PdfOutlineStyle.Bold, XColors.Black)
temp = rec(j, 1)
End If
If k = 0 Then
outline.Outlines.Add(rec(j, 2), page, True)
End If
p += 1
xgr.DrawImage(image, 0, 0, wid, hei)
xgr.Dispose()
Next
timage.Dispose()
Catch ex As Exception
prog.text += ex.message & "<br/> Failed to merge " & rec(j, 1) & " on " & rec(j, 2) & "<br/>"
End Try
Next
doc.Save(Server.MapPath("upload/combine.pdf"))
doc.Close()


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 22, 2009 7:44 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!
nguye1r wrote:
The code is working, but it take about 3 minutes to convert 225 pages.
Is there anyway for me to increase the speed?

Without knowing your task, your TIFF files, or your PC: what can I say?

I expect JPEG files to be processed faster.

Reducing the resolution of the TIFF files will probably also speed up the conversion.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 22, 2009 5:05 pm 
Offline

Joined: Mon Sep 21, 2009 11:17 pm
Posts: 3
Hello,
Thanks for replying.

my task is to convert a bunch of multipage tiffs into a single pdf with bookmarks. If the tiffs are bigger than a certain size I need to scale them to a consistent size.

I'm using Microsoft Windows Server 2003.
Intel(R) Xeon(TM) CPU 3.20GHz
3.20 GHZ, 2.00 GB of RAM
System Model is ProLiant DL360 G3

Unfortunately I can not control how big the input tiffs will be


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 23, 2009 8:42 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!
nguye1r wrote:
If the tiffs are bigger than a certain size I need to scale them to a consistent size.

PDFsharp takes the images as they are. A 4 megapixel photo drawn on 1" by 1" will have about 2000 dpi.
If 300 dpi are sufficient, it's up to you to call GDI+ to shrink the image (from 2000x2000 down to 300x300 in this example).

This shrinking will take some time, but it'll save some time while the PDF is being written - and the final PDF should be smaller.
That's what I mean with "reducing the resolution"

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 24, 2009 11:13 pm 
Offline

Joined: Mon Sep 21, 2009 11:17 pm
Posts: 3
Thanks for the help


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 guests


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 post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group