Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Image to PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Image to PDF

 Post Reply Post Reply
Author
Message
skwirelboy View Drop Down
Team Player
Team Player


Joined: 27 Feb 06
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote skwirelboy Quote  Post ReplyReply Direct Link To This Post Topic: Image to PDF
    Posted: 27 Feb 06 at 1:13PM

I want to add convert a tiff to a pdf (ok I guess I'm not converting but just embedding).

I'm using Delphi and here's what I have so far:

  QP := TiSEDQuickPDF.Create;
  QP.UnlockKey('[MyKey]');
  QP.NewDocument;
  QP.AddImageFromFile(dlg1.filename, 1);
  QP.SelectPage(0);
  QP.AddImageFromStream(stream, 0);
  QP.DrawScaledImage(1, 1, 100);

qp.SaveToFile('c:\pdf.pdf');

This is as far as I've got. I have a saved file which is roughly the size of the image I'm inserting, but when you open it it is blank. I've tried setting selectPage to 1 as well as 0, but to no avail.

If anyone can give me any pointers I'd be much obliged.

 

Thanks,

 

Mark

 

 

Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 06 at 1:51PM
RTFM

AddImageFromFile() returns an image ID, you then need to use SelectImage() with that ID, finally DrawScaledImage()

Also, the second argument to AddImageFromFile() is normally 0, unless dealing with multi-page TIFFs.

Your example also shows reading image data from a non-initialized stream.
Back to Top
skwirelboy View Drop Down
Team Player
Team Player


Joined: 27 Feb 06
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote skwirelboy Quote  Post ReplyReply Direct Link To This Post Posted: 28 Feb 06 at 4:28AM

Thanks for reply. I'm actually loading from stream, but thought it easier from my example if I showed it as being loaded from file. I've tried selectimage, but still don't seem to be getting anywhere (ie blank pdf, yet roughly same size as the tiff file). My code now is:

QP := TiSEDQuickPDF.Create;
  QP.UnlockKey('[MyKey]');
  QP.NewDocument;
  QP.SelectPage(0);

  Stream.Position:=0;

  QP.SelectImage(QP.AddImageFromStream(stream, 0));
  QP.DrawScaledImage(1, 1, 100);

  QP.SaveToFile('c:\pdf.pdf');

The stream is initialised although the example doesn't show the code and the stream contains a valid tif (tested at end of process by saving to a file). I'm not sure to what SelectPage should be set (ie whether 0 based index), but I;ve tried both as 0 and 1 and same result.

Any ideas why the above doesn't work?

Thanks in advance.

Mark

Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 28 Feb 06 at 11:12AM
Try checking ALL return codes from QP functions, might be something as simple as a mis-typed key, etc.

Also, QP has problems with some images, though it's mostly a rendering issue, not embedding, in my experience.

Added:

Just noticed that you're positioning the image at top,left=1,1. Note that the origin is the bottom left corner unless you specify otherwise, so your image is probably being embedded, but its top is just at the bottom of the screen. See the SetOrigin() function.



Edited by chicks
Back to Top
skwirelboy View Drop Down
Team Player
Team Player


Joined: 27 Feb 06
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote skwirelboy Quote  Post ReplyReply Direct Link To This Post Posted: 28 Feb 06 at 2:08PM

Thanks again. I've added setOrigin.

Drawing a scaled image was also failing for me, although I have no idea why. I've changed to DrawImage, but I'm setting the dimensions of the page first so that they match the image dimensions and this seems to do the trick perfectly.

Many thanks for your help. Don't think I would have got there without it.

Cheers,

Mark

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store