12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include <stdlib.h>
- #include <iostream>
- #include "PDFWriter.h"
- #include "PDFPage.h"
- #include "PageContentContext.h"
- #include "PDFFormXObject.h"
- #include "Trace.h"
- int main(){
- printf("if running on Windows check here for file(s): %%AppData%%\\Local\\VirtualStore\n");
- PDFWriter pdfWriter;
-
-
-
- EStatusCode e = pdfWriter.StartPDF("c:\\myFile.pdf",ePDFVersion13,LogConfiguration(true,true,".\\logMe"));
- if (e){
-
- 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();
-
- pdfPage->SetMediaBox(PDFRectangle(0,0,595,842));
- PageContentContext* pageContentContext = pdfWriter.StartPageContentContext(pdfPage);
-
- PDFUsedFont* arialTTF = pdfWriter.GetFontForFile("C:\\Windows\\Fonts\\arial.ttf");
-
-
- PDFFormXObject* image = pdfWriter.CreateFormXObjectFromJPGFile("C:\\Users\\bad-p\\Desktop\\Work Folder\\VS CODE\\SanAntonioPass.jpg");
- if (!image){
- printf ("hiiii");
- }
- pageContentContext->q();
- pageContentContext->cm(1,0,0,1,0,0);
-
- pageContentContext->Do(pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
- pageContentContext->Q();
- delete image;
-
- pageContentContext->k(0,0,0,1);
-
- pageContentContext->BT();
-
- pageContentContext->Tf(arialTTF,1);
-
- pageContentContext->Tm(20,0,0,20,40,822);
-
- pageContentContext->Tj("Text placed and scaled with Tm");
-
- pageContentContext->ET();
-
-
- pdfWriter.EndPageContentContext(pageContentContext);
- EStatusCode f = pdfWriter.WritePageAndRelease(pdfPage);
- if (f){
- printf ("something interesting");
- }
- pdfWriter.EndPDF();
- }
|