|
@@ -6,10 +6,48 @@
|
|
|
#include <stdlib.h>
|
|
|
#include <iostream>
|
|
|
#include "PDFWriter.h"
|
|
|
+#include "PDFPage.h"
|
|
|
+#include "PageContentContext.h"
|
|
|
+#include "PDFFormXObject.h"
|
|
|
|
|
|
int main(){
|
|
|
PDFWriter pdfWriter;
|
|
|
- pdfWriter.StartPDF("c:\\myFile.pdf",ePDFVersion13);
|
|
|
- // ...add content to PDF file...
|
|
|
+ // PREPARE PDF DOCUMENT
|
|
|
+ // ********************
|
|
|
+ // set path to output directory for new pdf
|
|
|
+ pdfWriter.StartPDF(".\\myFile.pdf",ePDFVersion13);
|
|
|
+ PDFPage* pdfPage = new PDFPage();
|
|
|
+ // set dimensions for an A4 sized page
|
|
|
+ pdfPage->SetMediaBox(PDFRectangle(0,0,595,842));
|
|
|
+ PageContentContext* pageContentContext = pdfWriter.StartPageContentContext(pdfPage);
|
|
|
+ // include font file
|
|
|
+ PDFUsedFont* arialTTF = pdfWriter.GetFontForFile("C:\\Windows\\Fonts\\arial.ttf");
|
|
|
+ // ADD CONTENT
|
|
|
+ // ********************
|
|
|
+ // set font color to black
|
|
|
+ pageContentContext->k(0,0,0,1);
|
|
|
+ // set text object
|
|
|
+ pageContentContext->BT();
|
|
|
+ // set font
|
|
|
+ pageContentContext->Tf(arialTTF,1);
|
|
|
+ // set position of text
|
|
|
+ pageContentContext->Tm(20,0,0,20,40,822);
|
|
|
+ // insert text into PDF
|
|
|
+ pageContentContext->Tj("Text placed and scaled with Tm");
|
|
|
+ // end of text
|
|
|
+ pageContentContext->ET();
|
|
|
+ PDFFormXObject* image = pdfWriter.CreateFormXObjectFromJPGFile("C:\\Users\\bad-p\\Desktop\\Work Folder\\VS CODE\\SanAntonioPass.jpg");
|
|
|
+ pageContentContext->q();
|
|
|
+ pageContentContext->cm(0.4,0,0,0.4,57.5,241);
|
|
|
+ pageContentContext->Do(
|
|
|
+ pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
|
|
|
+ pageContentContext->Q();
|
|
|
+ // END PAGE, WRITE PDF.
|
|
|
+ // ********************
|
|
|
+ pdfWriter.EndPageContentContext(pageContentContext);
|
|
|
+ pdfWriter.WritePageAndRelease(pdfPage);
|
|
|
pdfWriter.EndPDF();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|