Browse Source

created pdf document with text.
attempted to add a jpg image, was unsuccessful.
kyle says talk about version control next time & get jpg into file.

wes 4 years ago
parent
commit
3ca9276ee3

+ 6 - 1
PDFHummus-minGW-tools/README.txt

@@ -31,4 +31,9 @@
    For all CMake instructions create a build directory in the source root. CD in to build, run Cmake .. for windows using msys pass the 'Cmake .. -G "MSYS Makefiles"' 
    build option to generate a makefile appropiate for msys; You can use make afterwards to compile as normal.
    After all of the object files are moved into the same folder, generate a library for PDFWriter.
-   ar -cvq PDFWriter.lib *.o 
+   ar -cvq PDFWriter.lib *.o 
+
+   14 April 2020
+      Talked about cleaning up the README as well as rebuilding PDFHummus as a statically linked library "on my own". We will try and do this in a couple more sessions, so Wesley 
+      can rest his small brain. :D
+      

BIN
SanAntonioPass.jpg


BIN
myFile.pdf


+ 40 - 2
pdfHummusTest1.cpp

@@ -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();
+
+
+
 }

+ 2 - 0
pdfHummusTest1/README.txt

@@ -0,0 +1,2 @@
+1. Succesfully created a PDF and added text
+2. issues adding a jpg file to the PDF, figure it out next time

BIN
pdfHummusTest1/myFile.pdf


BIN
pdfHummusTest1/pdfHummusTest1.exe