Browse Source

notnull.cpp was a test to see what null or nullptr returns.
udpated tasks.json to display timestamp for executable creation.
More useful errors were tracked and are now displaying in pdfHummusTest1.
We spent about 3-4hours to finally capture some errors related
to StartPDF.
Microsoft was actually creating our file, but was saving it somewhere else.

wes 4 years ago
parent
commit
1d5c5b2e54
3 changed files with 25 additions and 13 deletions
  1. 4 2
      .vscode/tasks.json
  2. 3 3
      ToDo/ToDo.txt
  3. 18 8
      pdfHummusTest1.cpp

+ 4 - 2
.vscode/tasks.json

@@ -8,10 +8,12 @@
         //  Dont echo executed command in the terminal
         "echo" : false
       },
-    "tasks": [
+      "tasks": [
         {
         "label": "control shift B",
         "type": "shell",
+        //  displays time stamp of executable in directory
+        "command": "ls ${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe |tail -n3 |head -1",
         "dependsOn": ["default run executable"],
         "group": {"kind": "build","isDefault": true}
         },
@@ -31,7 +33,7 @@
         {
         "label": "default run executable",
         "type": "shell",
-        "command": "${fileBasenameNoExtension}/./${fileBasenameNoExtension}.exe",
+        "command": "${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe",
         "dependsOn": ["default compile"]
         },
         {

+ 3 - 3
ToDo/ToDo.txt

@@ -4,7 +4,7 @@
 
 19April20
 Successfully created a log file for errors using Gal's LogConfiguration structure. We are not sure what errors he actually keeps track of so we have to hunt for errors to log.
-Cleaned up tasks.json so there isn't a bunch of unuseful text such as "terminal will be resused message" or "execting tasks" messages. This needs to be cleaned up a little bit more
-and more useful information needs to be added. For instance, failed does not print on the same line inside the terminal.
 
-Kyle states: add one more line of code to state that your program worked as a work around for the "press any key" "error".
+25April20
+Unsure if we can have both text and a picture on the same page for the PDFWriter. Need to possibly create a second page, one with text on it, then one with the picture on it.
+Third page we could try and create it with both. This may have something to do with how pageContentContext works??? Anyways, the image is working now and the text is commented out.

+ 18 - 8
pdfHummusTest1.cpp

@@ -18,15 +18,25 @@
 #include "Trace.h"
 
 int main(){
+    printf("if running on Windows check here for file(s): %%AppData%%\\Local\\VirtualStore\n");
     PDFWriter pdfWriter;
     //  PREPARE PDF DOCUMENT
     //  ********************
-    //  set path to output directory for new pdf
-    EStatusCode e = pdfWriter.StartPDF(".\\myFile.pdf",ePDFVersion13,LogConfiguration(true,true,".\\logMe"));
-    TRACE_LOG("ooogaBooga");
-    if (e){
-        printf ("something interesting");
+    //  get a PDFWriter object to interact with. set the PDF version, set log file
+    EStatusCode e = pdfWriter.StartPDF("c:\\myFile.pdf",ePDFVersion13,LogConfiguration(true,true,".\\logMe"));
+    if (e){ 
+        /*  25APR20 - look through codebase and found these three reasons for nonrecoverable failure:
+         *  - user requested encryption, document doesn't support it
+         *  - it is unlikely, but for some reason GK wanted to call OutputFile::CloseFile(), it failed 
+         *  - operating system was unsuccessful at giving a lock for the filename *
+         * 
+         *  * Windows 'gives' a lock, but doesn't protect others from writing to this filename
+         */
+        printf("Terminating (c:\\myFile.pdf): unsuccessful lock or couldn't close existing or requested encryption but not supported\n");
+        TRACE_LOG("Terminating (c:\\myFile.pdf): unsuccessful lock or couldn't close existing or requested encryption but not supported");
+        exit(1);
     }
+    TRACE_LOG("Notified OS we might use c:\\myFile.pdf");
     PDFPage* pdfPage = new PDFPage();
     //  set dimensions for an A4 sized page
     pdfPage->SetMediaBox(PDFRectangle(0,0,595,842));
@@ -36,7 +46,7 @@ int main(){
     //  ADD CONTENT 
     //  ********************
     //  set font color to black
-    pageContentContext->k(0,0,0,1);
+    /*pageContentContext->k(0,0,0,1);
     //  set text object
     pageContentContext->BT();
     //  set font 
@@ -46,13 +56,13 @@ int main(){
     //  insert text into PDF
     pageContentContext->Tj("Text placed and scaled with Tm");
     //  end of text
-    pageContentContext->ET();
+    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.25,0,0,0.25,86,125);
+    pageContentContext->cm(1,0,0,1,0,0);
     //pageContentContext->cm(0.4,0,0,0.4,57.5,241);
     pageContentContext->Do(pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
     pageContentContext->Q();