Kaynağa Gözat

Added a JPEG to the pdf, got it to display once. There were some issues that we are trying to figure out still.
Need to introduce an error handling system.

wes 4 yıl önce
ebeveyn
işleme
cf052a9ba3
1 değiştirilmiş dosya ile 17 ekleme ve 7 silme
  1. 17 7
      pdfHummusTest1.cpp

+ 17 - 7
pdfHummusTest1.cpp

@@ -1,6 +1,9 @@
 /*  Found that previous library was complied with the MSVC compiler and not compatible with GNU toolchain. Tried to use Msys with PDFHummus Cmake build tools and it was hard-coded
  *  to MSVC. So building for GNU compiler will take some modification of Cmake.
- *  
+ *  4.16.20 - after getting an image onto the pdf, we realized there was an error that was not getting logged/presented to us.
+ *  we came upon this error, by trying to run the pdfHummusTest1.exe and the pdf file was not being created (because it was still
+ *  open -> Windows locking files regardless of where they are open). This is the reason why we wanted to figure out if PDFHummus
+ *  had an error logging capability and then we had to try and figure out how to use it... to be continued for next time.
  */
 
 #include <stdlib.h>
@@ -14,8 +17,14 @@ int main(){
     PDFWriter pdfWriter;
     //  PREPARE PDF DOCUMENT
     //  ********************
+    LogConfiguration test = LogConfiguration::DefaultLogConfiguration();
+    test.ShouldLog = true;
+    test.LogFileLocation = ".\\hemph";
     //  set path to output directory for new pdf
-    pdfWriter.StartPDF(".\\myFile.pdf",ePDFVersion13);
+    EStatusCode e = pdfWriter.StartPDF(".\\myFile.pdf",ePDFVersion13,test);
+    if (e){
+        printf ("something interesting");
+    }
     PDFPage* pdfPage = new PDFPage();
     //  set dimensions for an A4 sized page
     pdfPage->SetMediaBox(PDFRectangle(0,0,595,842));
@@ -37,10 +46,13 @@ int main(){
     //  end of text
     pageContentContext->ET();
     PDFFormXObject* image = pdfWriter.CreateFormXObjectFromJPGFile("C:\\Users\\bad-p\\Desktop\\Work Folder\\VS CODE\\SanAntonioPass.jpg");
+    if (!image){
+        printf ("hiiii");
+    }
     pageContentContext->q();
-    pageContentContext->cm(0.4,0,0,0.4,57.5,241);
-    pageContentContext->Do(
-    pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
+    pageContentContext->cm(0.25,0,0,0.25,86,125);
+    //pageContentContext->cm(0.4,0,0,0.4,57.5,241);
+    pageContentContext->Do(pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
     pageContentContext->Q();
     //  END PAGE, WRITE PDF.
     //  ******************** 
@@ -48,6 +60,4 @@ int main(){
     pdfWriter.WritePageAndRelease(pdfPage);
     pdfWriter.EndPDF();
 
-
-
 }