Please see the topics below and take a look on the relevant example projects once you downloaded our plugin.
Create New PDF from scratch
Start a new blank PDF and add content to it. Just call DynaPDF.Append to add a new page and then while the page is open, draw some content on it. This may involve setting color with DynaPDF.SetFillColor or DynaPDF.SetStrokeColor functions and calling drawing functions like DynaPDF.MoveTo and DynaPDF.LineTo to draw a line. With DynaPDF.Rectangle, DynaPDF.DrawArc, DynaPDF.Bezier123 and our other drawing functions, you may build complex vector graphics.
You can play pictures with DynaPDF.InsertImage function right from a container or with DynaPDF.InsertImageFile from a picture file. But if the picture should be a barcode, please consider using DynaPDF.InsertBarcode function instead to get your code as vector graphics.
Load PDF documents
You can load PDF documents into memory. Either you use DynaPDF.OpenPDFFromContainer for a container value, which may be a container field or some variable. Or you have a file and then use DynaPDF.OpenPDFFromFile function to open it. After you loaded a PDF and then you can inspect it:
- Get page count via DynaPDF.GetImportPageCount
- Get page sizes via DynaPDF.GetImportPageBounds
- Get metadata via DynaPDF.GetInMetadata, DynaPDF.GetImportDocInfo, DynaPDF.GetInDocInfoCount, DynaPDF.GetImportDocInfoAsJSON
- Finally import individual pages (DynaPDF.ImportPDFPage) or whole file (DynaPDF.ImportPDFFile).
Once you have a page or the whole PDF imported, you can use DynaPDF.ExtractText function to extract text from a page or multiple pages. A special possibility is to specify an area in a page and only extract the text from that area, e.g. to read an invoice number.
You can store text of the whole document or per page into fields and later search for this text. That is how our PDF Library example can provide search and find words and know which page they belong to.
See Extract Text.fmp12 and PDF Library.fmp12
With DynaPDF.GetImageCount function you can query how many images you have in your current PDF document. Then loop over them with DynaPDF.GetImage and query various values for those images like width and height.
MBS( "DynaPDF.GetImage"; $PDF; $Index; "Picture"; "test.jpg"; "JPEG" )
And his provides you the picture as JPEG file and you can assign it to a container field to show.
See Extract Images.fmp12
Merge PDF documents
Since you can import pages from a PDF file, you may loop and import from various PDF documents. Just call DynaPDF.OpenPDFFromContainer or DynaPDF.OpenPDFFromFile multiple times for different input PDF documents. Then import the content as needed with DynaPDF.ImportPDFFile or DynaPDF.ImportPDFPagefunctions for each document. There is always only one open import PDF, so you may switch between different ones with opening a new import document.
You can also add pictures as PDF pages. While you can do it manually with DynaPDF.AppendPage and DynaPDF.InsertImage, we got a convenience function for you: DynaPDF.AppendImagePage. With DynaPDF.AppendImagePages you can easily pass a list of native file paths and we loop over them to insert them all as pages.
If you like to split a PDF into new PDFs for each page, check the split example. We simply loop over page count, import one page into each its own new document. And than save each PDF into a separate field or container.
If you like to have chapter marks, you can check our bookmark functions.
See Merge PDFs.fmp12, Merge PDFs to File.fmp12, Split PDF.fmp12, Picture to PDF.fmp12, Bookmarks.fmp12 and Scan with WIA to PDF.fmp12
Add pages numbers
You may have a document created already, then import it and start to edit pages. The DynaPDF.GetPageCount function tells how many pages you have, so you can loop over them and call DynaPDF.EditPage to edit a page. As in our examples you may best just use DynaPDF.WriteFTextEx to draw your page number left or right aligned within a text box on the bottom right or left of a page.
See Add Page Numbers.fmp12 and Personalized PDFs.fmp12
You can use the same function as DynaPDF uses internally for the demo watermark in your own PDFs. So if you like to have a blue "PRIVATE" or "UNDER NDA" text on the page, you can set the color and use our DynaPDF.WriteDemoText function.
Since we can also do transparency for text or images, your watermark can be any text or image placed on the pages with high transparency. You may even place invisible text on a page to include information like the name of the user, who downloaded a confidential PDF, so you can identify it later.
See Watermark pages.fmp12 and Personalized PDFs.fmp12