Examples Howto Create a PDF Document With Use Of Debenu Free PDF Library Lite

Some of you might be interested in using the Debenu Free PDF Library Lite to create PDF documents or Convert images to Pdf. Which allow you to install the LICENSED SOFTWARE on any number of computers, for any number of developers for both personal or commercial use. (http://www.debenu.com/products/development/debenu-pdf-library-lite/)

Check the license agreement before you install it, as the license agreement could have changes while you are reading this

When you download the software. Read the GettingStarted.pdf file which explains howto registering the ActiveX DLL. And the “Debenu Quick PDF Library 11.12 Reference Guide.pdf” will explain howto use the Library.

Attached two examples:

Create a PDF document with text: “Hello from XOJO”

  // Create a PDF document with text: "Hello from XOJO"
  
  Dim PDFLibrary As OLEObject
  Dim Stf as Integer
  Dim PdfFile As String
  
  PdfFile = "C:\\TEMP\\PDF\\HelloFromXojo.pdf"
  PDFLibrary = NEW OLEObject("DebenuPDFLibraryLite1112.PDFLibrary")
  PDFLibrary.DrawText(100, 500, "Hello from XOJO")
    
  Stf = PDFLibrary.SaveToFile(PdfFile)  
  
  //Stf = 0 "The file could not be created",  Stf = 1 "The file was created successfully"
  If Stf = 0 Then
    MsgBox ("Could not save the PDF file: "+pdfFile)
  End If
    
  PDFLibrary = Nil
  
exception err as oleexception
  msgbox err.message

Import image to pdf

  // Import image to pdf
  
  Dim PDFLibrary As OLEObject
  Dim Stf as Integer
  Dim ImageFile, OutPutFile As String
  Dim IWidth, IHeight As Integer
    
  ImageFile = "C:\\TEMP\\PDF\\Xojo_images.jpg"
  OutPutFile = "C:\\TEMP\\PDF\\ImagetoPdf.pdf"
  
  PDFLibrary = NEW OLEObject("DebenuPDFLibraryLite1112.PDFLibrary")
  
  //Add Image
  PDFLibrary.AddImageFromFile( ImageFile, 0 )
  
  // Get the width and height of the image
  IWidth = PDFLibrary.ImageWidth
  IHeight = PDFLibrary.ImageHeight
  
  // Set new document page size
  PDFLibrary.SetPageDimensions( IWidth, IHeight )
  
  // Draw the image onto the page using the the images
  // height and width. The image will be drawn in the
  // top right hand corner of the page.
  PDFLibrary.DrawImage( 0, PDFLibrary.PageHeight, IWidth, IHeight )
  
  // Save the new document
  Stf = PDFLibrary.SaveToFile( OutPutFile )
  
  //Stf = 0 "The file could not be created",  Stf = 1 "The file was created successfully"
  
  If Stf = 0 Then
    MsgBox ("Could not save the PDF file: "+OutPutFile )
  End If
    
  PDFLibrary = Nil
  
exception err as oleexception
  msgbox err.message

John, If I am not mistaken, the image functionality is only working with the full version of Debenu.

In any case, in a test program, I use this function to load an image file from a location on my computer:

dim LogoFile as string dim posX as Double ' variables de positionnement sur la page dim posY as double logoFile = "c:\\temp\\LogoMSM2013.jpg" 'attention valeur hardcode corriger retval = QP.addImageFromFile (LogoFile,0) posx = .5 posY = .375 retval = QP.drawimage(posX,posY,1.25,1.25)

hope this helps. LD

re-read the post. so, images work with the free version. You will however need the paid version to control fonts and a number of other features. Quite a nice tool.

The examples I showed works fine with the free version…

Also if you read the link: http://www.debenu.com/products/development/debenu-pdf-library-lite/

These are some of the key functions in this free PDF SDK. A full list of functions can be found in the “Appendix C: Functions available in the Lite Edition” section found in the Function Reference provided with the installer.

  1. Load existing PDFs or generate new ones
  2. Add images to existing PDF files and convert images to PDF files (JPG, GIF, TIFF, PNG, BMP, etc)
  3. Add text and control location, size, color and font
  4. Generate QR codes and add them to PDF files
  5. Merge PDF files together
  6. Set and get document properties (title, author, subject, keyword)
  7. Add web links and set base URL
  8. Get page rotation information and rotate pages
  9. Get security info such as encryption strength and document permissions
  10. Set and get PageBox info (MediaBox, CropBox, BleedBox, TrimBox, ArtBox)
  11. Check for fonts, count embedded images, get page width and height

The Library also exist for: Mac OS X 10.5 to 10.9 (32-bit) I don’t have a Mac so I have no examples for that platform.

I tried to use Debenu Quick PDF ActiveX with code written in first example above, but I cant save the file!

Anyone has solution for this problem?

I found solution: you must enter licence key if you are using full version of Quick Pdf library.

How Did I use this in Xojo “Mac”?

you don’t

but you can create PDF just by virtue of OSX built in PDF printer, or there are other similar tools available

You read the post before :

[quote=148573:@John Hansen]Also if you read the link: http://www.debenu.com/products/development/debenu-pdf-library-lite/

The Library also exist for: Mac OS X 10.5 to 10.9 (32-bit) I don’t have a Mac so I have no examples for that platform.

[/quote]

I found this Norman Pallardy’s post, about importing Dylib into xojo.
Will be this possible to this, in order to use that library on Xojo project?

I mean, It looks so attractive, considering the fact that have many abilities, including to add QR Codes inside the PDF Document.

This is the link: http://www.realsoftwareblog.com/2011/12/how-to-create-dylib-on-mac-os-x-and.html

I understand that this is the way to import it on Mac:

CONST dylibLocation = “@executable_path/libDebenuPDFLibrary64CPLiteDylib1115.dylib”

pls, correct me If I wrong

The problem is OLE, Ole is for Windows right?

right

I Opened the DebenuPDFLibraryCPLiteDylibObjC1115.h with Xcode, in order to find the INT values for Declare that in Xojo, and that Is what I found:

  • (int)AddImageFromFile:(NSString *)FileName :(int)Options;
  • (int)AddLinkToWeb:(double)Left :(double)Top :(double)Width :(double)Height :(NSString *)Link :(int)Options;
  • (int)AddStandardFont:(int)StandardFontID;
  • (int)DeletePages:(int)StartPage :(int)PageCount;
  • (int)DocumentCount;
  • (int)DrawHTMLText:(double)Left :(double)Top :(double)Width :(NSString *)HTMLText;
  • (NSString *)DrawHTMLTextBox:(double)Left :(double)Top :(double)Width :(double)Height :(NSString *)HTMLText;
  • (int)DrawImage:(double)Left :(double)Top :(double)Width :(double)Height;
  • (int)DrawQRCode:(double)Left :(double)Top :(double)SymbolSize :(NSString *)Text :(int)EncodeOptions :(int)DrawOptions;
  • (int)DrawText:(double)XPos :(double)YPos :(NSString *)Text;
  • (int)DrawTextBox:(double)Left :(double)Top :(double)Width :(double)Height :(NSString *)Text :(int)Options;
  • (int)ExtractPages:(int)StartPage :(int)PageCount;
  • (int)FindImages;
  • (int)GetImageListCount:(int)ImageListID;
  • (NSString *)GetImageListItemFormatDesc:(int)ImageListID :(int)ImageIndex :(int)Options;
  • (NSString *)GetInformation:(int)Key;
  • (double)GetPageBox:(int)BoxType :(int)Dimension;
  • (int)GetPageImageList:(int)Options;
  • (int)HasFontResources;
  • (int)ImageCount;
  • (int)ImageHeight;
  • (int)ImageWidth;
  • (int)IsLinearized;
  • (int)LastErrorCode;
  • (int)LoadFromFile:(NSString *)FileName :(NSString *)Password;
  • (int)MergeDocument:(int)DocumentID;
  • (int)NewDocument;
  • (int)NewPage;
  • (int)NormalizePage:(int)NormalizeOptions;
  • (int)PageCount;
  • (int)PageHasFontResources:(int)PageNumber;
  • (double)PageHeight;
  • (int)PageRotation;
  • (double)PageWidth;
  • (int)RemoveDocument:(int)DocumentID;
  • (int)RotatePage:(int)PageRotation;
  • (int)SaveToFile:(NSString *)FileName;
  • (int)SecurityInfo:(int)SecurityItem;
  • (int)SelectDocument:(int)DocumentID;
  • (int)SelectFont:(int)FontID;
  • (int)SelectImage:(int)ImageID;
  • (int)SelectPage:(int)PageNumber;
  • (int)SelectedDocument;
  • (int)SetBaseURL:(NSString *)NewBaseURL;
  • (int)SetInformation:(int)Key :(NSString *)NewValue;
  • (int)SetMeasurementUnits:(int)MeasurementUnits;
  • (int)SetOrigin:(int)Origin;
  • (int)SetPageBox:(int)BoxType :(double)Left :(double)Top :(double)Width :(double)Height;
  • (int)SetPageDimensions:(double)NewPageWidth :(double)NewPageHeight;
  • (int)SetPageLayout:(int)NewPageLayout;
  • (int)SetPageMode:(int)NewPageMode;
  • (int)SetPageSize:(NSString *)PaperName;
  • (int)SetTextAlign:(int)TextAlign;
  • (int)SetTextColor:(double)Red :(double)Green :(double)Blue;
  • (int)SetTextSize:(double)TextSize;
  • (int)SetTextUnderline:(int)Underline;

So, for Example If I want to Declare,one of that functions, Is it wright to do this?:

Example I’ll gonna try with this: - (int)DrawText:(double)XPos :(double)YPos :(NSString *)Text;

Declare Function DrawText lib dylibLocation (x as double, y as double, text as String)

That file was inside of Objective and inside of It there’s two files: one with *.h Extension and one with *.m extension

[quote=199092:@Dave S]you don’t

but you can create PDF just by virtue of OSX built in PDF printer, or there are other similar tools available[/quote]
And How did you do that?

As I cannot post anymore in longer threads, I’ll post the answer for Gerardo’s OS X / dylib question here:
I think the dylib you downloaded cannot be used through declares as it seems it is intended for static linking into an Objective C project.