Sample to add text to a multipage file

Example requests & Code samples for GdPicture Toolkits.
Post Reply
ICONN
Posts: 3
Joined: Wed Jun 11, 2008 4:22 pm

Sample to add text to a multipage file

Post by ICONN » Wed Jun 11, 2008 4:31 pm

Hi,

I've been evaluating the gdPicture Pro controls to see if it will work for my application. There's one thing left that I need to prove before purchase. I hope you can help.

If I want to open either a multipage TIFF or a multipage PDF, what are the steps to DrawText on any page, and then be able to save the whole multipage document? I have no problem using DrawText, but I lose all pages except the page I just put the text on. Can you provide a sample to open a file, allow a DrawText on page 3, and then save it?

Thanks!


Scott

ICONN
Posts: 3
Joined: Wed Jun 11, 2008 4:22 pm

Re: Sample to add text to a multipage file

Post by ICONN » Thu Jun 12, 2008 8:09 pm

Anybody know how to do this? I know I must be missing something simple...

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Sample to add text to a multipage file

Post by Loïc » Fri Jun 13, 2008 9:32 am

Hi,

You need to use the last GdPicture Pro edition to do that.

I give you a sample code to draw page number on a multipage tiff image and save it:

Code: Select all

Dim nCpt As Long
Dim nTiffImageID As Long
Dim nPageCount As Long

nTiffImageID = Imaging1.TiffCreateMultiPageFromFile("input.tif")
nPageCount = Imaging1.TiffGetPageCount(nTiffImageID)

For nCpt = 1 To nPageCount
    Call Imaging1.TiffSelectPage(nTiffImageID, nCpt)
    Call Imaging1.DrawText("Page " & CStr(nCpt) & " / " & CStr(nPageCount), 50, 50, 10)
Next nCpt

Call Imaging1.TiffSaveMultiPageToFile(nTiffImageID, "output.tif")
Imaging1.CloseImage (nTiffImageID)
Best regards,

Loïc

ICONN
Posts: 3
Joined: Wed Jun 11, 2008 4:22 pm

Re: Sample to add text to a multipage file

Post by ICONN » Fri Jun 13, 2008 6:12 pm

Thanks Loïc, your example does help a lot. But, I have two questions:

1. I'm trying to combine what you have shown here with the TextWriter example so that the user can go to any page in a document and add a comment. Since the code shown here doesn't use the AxGdViewerCnt control, they can't see the document. You know these controls very well, so is there any way that you can provide a code snippet that will combine these two methods? What I really need is a way to type text on any page of a multipage document.

Also, if I want to allow comments to be added to a PDF file, would I have to convert the PDF to TIFF, allow the DrawText, and then convert it back to PDF?

2. I'm starting with a 5 page TIFF file that is 156Kb. After adding a simple text comment on one page and saving the document with Group IV compression, it blows up to 1521Kb. That's a huge difference. Does the DrawText really add that much, or am I doing something else wrong?

Thanks!


Scott

Dabi123
Posts: 22
Joined: Mon Apr 28, 2008 9:28 pm

Re: Sample to add text to a multipage file

Post by Dabi123 » Wed Jul 30, 2008 11:04 pm

Hi, Any idea.. how to do that.. I want the same feature too..
Thanx
Dabi

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Sample to add text to a multipage file

Post by Loïc » Thu Jul 31, 2008 9:25 am

Hi guys,

Sorry I didn't see the last answer to this post.


You are probably drawing text on 1bpp image. To perform this feature, the toolkit convert the image to 32bpp.

After drawing text, you can convert again the image to 1bpp using the ConvertTo1bpp() method.

Best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests