1
1
Bläddra i källkod

now has text on one page, picture on second page.

wes 4 år sedan
förälder
incheckning
fb70193960
1 ändrade filer med 11 tillägg och 7 borttagningar
  1. 11 7
      pdfHummusTest1.cpp

+ 11 - 7
pdfHummusTest1.cpp

@@ -19,6 +19,7 @@
 #include <windows.h>
 #include <winnt.h>
 int main(){
+    //  
     //  Go to: "%AppData%\..\Local\VirtualStore"  - because Windows does not write to the C:\ drive  
     printf("if running on Windows check here for file(s): %%AppData%%\\..\\Local\\VirtualStore\n");
     PDFWriter pdfWriter;
@@ -100,13 +101,16 @@ int main(){
     pdfPage2->SetMediaBox(PDFRectangle(0,0,595,842));
     // Create a content context for the page
     PageContentContext* pageContentContext2 = pdfWriterB.StartPageContentContext(pdfPage2);
-    PDFUsedFont* arialTTF2 = pdfWriterB.GetFontForFile("C:\\Windows\\Fonts\\arial.ttf");
-    pageContentContext2->k(0,0,0,1);
-    pageContentContext2->BT();
-    pageContentContext2->Tf(arialTTF2,1);
-    pageContentContext2->Tm(20,0,0,20,40,822);
-    pageContentContext2->Tj("Hello Again, World");
-    pageContentContext2->ET();				
+    PDFFormXObject* image = pdfWriterB.CreateFormXObjectFromJPGFile("C:\\Users\\bad-p\\Desktop\\Work Folder\\VS CODE\\SanAntonioPass.jpg");
+    if (!image){
+        TRACE_LOG("Image file not found, creating PDF without image.");
+        printf("The image \"C:\\Users\\bad-p\\Desktop\\Work Folder\\VS CODE\\SanAntonioPass.jpg\" was not found.");
+    }
+    pageContentContext2->q();
+    pageContentContext2->cm(0.4,0,0,0.4,57.5,241);
+    pageContentContext2->Do(pdfPage2->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
+    pageContentContext2->Q();
+    delete image;				
     // End content context, and write the page
     pdfWriterB.EndPageContentContext(pageContentContext2);
     pdfWriterB.WritePageAndRelease(pdfPage2);