Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

  • 2 Pages
  • 1
  • 2
  • >
Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, February 29, 2008 6:41:45 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi There,

I need to know whether there is any way to add some footer to pdf file while converting any document pdf?

 

Your reply will help me a lot.

 

Thanks,

Suresg

 

 

 

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, March 2, 2008 1:22:35 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)


Suresg,


How
exactly do you want to create the footer for the PDF? Do you want to draw
objects on the document or load images and stamp them on the document? Or do
you want to create text on a specific location on the document? What is the nature of the footer?




All
of the above can be done. For more information on how to do that, please specify what exactly you need.


Also,
please specify which LEADTOOLS version (13, 14, 15, etc.) and toolkit
programming interface (OCX, .NET classes, DLL API, C++ Classes, etc.) you're using.

 
#3 Posted : Monday, March 3, 2008 10:03:48 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Thansk for your reply, My requirement is some like to add text with user specific details and timestamp the pdf is viewed and created in footer part of pdf.

I am using Lead Tools V15. And programming interface is is .Net classes. Your reply helps a lot. 

 

Thanks,

Suresh

 
#4 Posted : Tuesday, March 4, 2008 1:43:29 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)


Suresh,










If
you want to make the text part of the image's pixel data, you can use the GDI+ functions like this.
- Load the PDF file in a RasterImage using the RasterCodecs.Load method.
- Converts this RasterImage to a GDI+ image using ConvertToGdiPlusImage Method.
-
Use the Graphics.DrawString Method to define the string, font and location of the text.
-
You can then save the modified image to a new Raster PDF file using the Codecs.Save method.

 
#5 Posted : Tuesday, March 4, 2008 4:21:35 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Thanks for reply,

If you can provide the sample code, that would be great. And also just to let you know, I am converting an image to pdf and rendering the pdf bytes to the browser. So I believe I should be able to add the text (foot print) to the raw pdf on the fly.

And also could you please tell me is theera ny way to disable some functionalities like save in generated pdf?

Thanks in advance.

Suresh

 

 
#6 Posted : Tuesday, March 4, 2008 9:00:45 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Is there any way to turn off  some features in generated pdf file using leadtools ? My requirement is I have some functionality which converts the images to pdf using leadtools v15 in dotnet. So the generated pdf should allow user to allow them to save it in their local or edit?

Thanks,

Suresh

 

 
#7 Posted : Tuesday, March 4, 2008 11:29:10 PM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)




Suresh,
The
code sample will only use the functions I already sent to you. Did you try
them? The help file contains sample code snippets for almost all our LEADTOOLS functions. Basically, you need to do this:








1- Load the source image.
2- Get a GDI+ graphics object of the image.
3- Draw the text on this Graphics object.
4- Use Codecs.Save to save a PDF file.




There
is no 'raw' PDF in LEADTOOLS. You must save to disk or to stream, and the resulting file will contain your image embedded inside a PDF file.


About
configuring security features in the PDF output, the only feature that exist that you can define a password for saving encrypted PDF.

 
#8 Posted : Wednesday, March 5, 2008 6:48:36 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


I tried playing with this and achieved to little bit but not fully. I go the text on generated pdf but with this code it is inverting the colors in pdf. Means background is becoming black and letters are becoming white in color. Without this code it generates the pdf fine.

Getting samples and making it working using leadtools is eating away lot of time.

I dont know when leadtools provide lot of functionalities why dont they give proper documentation. The documentation that exists is not at all helpful.

Anyway here is the code that I got some text to be printed in my genearated pdf.

               rasImage = rasCodecs.Load(inputFile); //load input file

                container = rasImage.CreateGdiPlusGraphics();
                container.Graphics.SmoothingMode = SmoothingMode.Default;
                //container.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                Brush br = new LinearGradientBrush(Point.Empty, new Point(200, 200), Color.Yellow, Color.Green);
                Font textFont = new Font(FontFamily.GenericSansSerif, 12);
                PointF point = new PointF(100, 100);
                container.Graphics.DrawString("Suresh Test", textFont, br, point);

And also let me know how can we find the exact position of footer location of pdf to place this.

 

Your reply will be very helpful and thanks in advance for all your help.

 

Thanks,

Suresh

 

 

 
#9 Posted : Thursday, March 6, 2008 4:45:34 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)

Suresh,


What
is the exact format constant that you are using when saving to PDF? Also what is the build number (version info) of your LEADTOOLS.CODECS.PDF.DLL?


About
the PDF footer, you can assign the footer by setting the location to RasterImage.Height – displacement.

 
#10 Posted : Thursday, March 6, 2008 5:05:28 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi Adam,

I tried with using RasterImageFormat.RasPdf and RasterImageFormat.RasPdfG4.

The version is v15. These formats works in some cases and does not work in some other cases. For example In some cases if tiff is multipage, first page is getting inverted and remaining pages are displaying properly.

 

You know its not predicatable how it behaves.

 

Thanks,

Suresh 

 

 
#11 Posted : Thursday, March 6, 2008 9:29:31 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi Adam,

Sorry for posting you lot of questions, I just examined one more thing. By the code which I given in my earlier post it adds text to pdf but only for the first page.

 

Could you tell me how can we add the text to all the pages in pdf?

Thanks,

Suresh

 

 
#12 Posted : Sunday, March 9, 2008 6:01:12 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)

Hello Suresh,
Can you please try and create a small sample project that isolates the problem (not your full application) and put it in a ZIP or RAR file.
You can either post the project her (don't hit preview or include unlock keys) or you can send it to support@leadtools.com and mention this post.
I will try and solve the issue for you.

 
#13 Posted : Monday, March 10, 2008 11:24:48 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi Adam,

Could you tell me how can we add the text to all the pages in pdf?. At present the text is being added to only first page.

 

Thanks,

Suresh

 
#14 Posted : Tuesday, March 11, 2008 5:49:19 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)

Suresh,
I used this code to load each page of a multi-page tif file, add text to every page and save them to PDF.

//-----------------------------------------
RasterCodecs rasCodecs;
RasterImage rasImage;
RasterImageGdiPlusGraphicsContainer container;
RasterCodecs.Startup();
rasCodecs = new RasterCodecs();
string inputFile = @"C:\Temp\Multipage.tif";
CodecsImageInfo info;
info = rasCodecs.GetInformation(inputFile,true);
for (int i = 1; i <= info.TotalPages; i++ )
{
    rasImage = rasCodecs.Load(inputFile, info.BitsPerPixel, CodecsLoadByteOrder.Bgr, i,i); //load input file
    container = rasImage.CreateGdiPlusGraphics();
    container.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
    container.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
    Brush br = new System.Drawing.Drawing2D.LinearGradientBrush(Point.Empty, new Point(200, 200), Color.Yellow, Color.Green);
    Font textFont = new Font(FontFamily.GenericSansSerif, 12);
    PointF point = new PointF(100, 100);
    container.Graphics.DrawString("Suresh Test", textFont, br, point);
    rasCodecs.Save(rasImage, @"c:\Temp\Saved.pdf", RasterImageFormat.RasPdfLzw, info.BitsPerPixel,1,1,i,CodecsSavePageMode.Append);
}
RasterCodecs.Shutdown();
//-----------------------------------------

Please tell me if you face any problems
 
#15 Posted : Wednesday, May 5, 2010 11:42:49 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi There,

Using the above code some how I got it working to add some text to the footer of the pdf. Now when this code is used in a asp.net webapplication for converting large tiff images like more than 500 pages to pdf on the fly, the process is eating server resources and timing out. When I comment out the code to add the text to the footer of each page in pdf it is fast and does not timeout. Can you recommend someother alternative to the above solution, I am just trying to see if there is something that adds watermarks to all the pages in the converted pdf with out looping through each page.

Please reply...

Thanks,
Suresh
 
#16 Posted : Thursday, May 6, 2010 4:43:35 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

To free up the memory after loading the image and drawing the text, try to dispose the RasterImage and RasterImageGdiPlusGraphicsContainer objects. Also, use the .Net garbage Collector to free resources (managed/unmanaged).

Please try the same issue by using the following code:
+--------+
RasterCodecs rasCodecs;
RasterImage rasImage;
RasterImageGdiPlusGraphicsContainer container;
RasterCodecs.Startup();
rasCodecs = new RasterCodecs();
string inputFile = @"c:\multipage.tif";
CodecsImageInfo info;
info = rasCodecs.GetInformation(inputFile, true);
for (int i = 1; i <= info.TotalPages; i++)
{
rasImage = rasCodecs.Load(inputFile, info.BitsPerPixel, CodecsLoadByteOrder.Bgr, i, i); //load input file
container = rasImage.CreateGdiPlusGraphics();
container.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
container.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
Brush br = new System.Drawing.Drawing2D.LinearGradientBrush(Point.Empty, new Point(200, 200), Color.Yellow, Color.Green);
Font textFont = new Font(FontFamily.GenericSansSerif, 12);
PointF point = new PointF(100, 100);
container.Graphics.DrawString("Suresh Test", textFont, br, point);
 rasCodecs.Save(rasImage, @"c:\Temp\Saved.pdf", RasterImageFormat.RasPdfLzw, info.BitsPerPixel, 1, 1, i, CodecsSavePageMode.Append);

 rasImage.Dispose();
 container.Graphics.Dispose();
 System.GC.Collect();
 System.GC.WaitForPendingFinalizers();  
}
RasterCodecs.Shutdown();
+--------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#17 Posted : Thursday, May 6, 2010 5:43:24 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Hi Maen,

Thank you very much for your alternate code. This helps a lot to me. I will try with this,

can you tell me whether I need to call GC.Collect for every page that I create in the for loop or Can I call this in the finally block of whole code ?
 
#18 Posted : Thursday, May 6, 2010 5:53:59 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

If you are getting the memory problem inside the loop, then you need to keep the GC.Collect method inside the loop.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#19 Posted : Thursday, May 6, 2010 5:58:18 AM(UTC)
SureshMittapalli

Groups: Registered
Posts: 22


Thats quick, Thank you. Just want to make sure.

And could you tell me if there is any other alternative to writing text to the footer like watermarking the pdf using .net and Leadtools v15?

Thanks,
Suresh
 
#20 Posted : Sunday, May 9, 2010 4:00:24 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)

Suresh,
The approach we discussed is the 'straightforward' way of doing it. If it's causing a problem, we can discuss solving the problem. If it's not causing a problem, why exactly do you want a different approach?
 
  • 2 Pages
  • 1
  • 2
  • >
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.366 seconds.