123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #include <stdlib.h>
- #include <iostream>
- #include "PDFWriter.h"
- #include "PDFPage.h"
- #include "PageContentContext.h"
- #include "PDFFormXObject.h"
- #include "Trace.h"
- #include <windows.h>
- #include <winnt.h>
- #include "PDFModifiedPage.h"
- #include "AbstractContentContext.h"
- int main(){
-
-
- printf("if running on Windows check here for file(s): %%LOCALAPPDATA%%\\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");
-
-
-
-
-
-
- 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);
- pdfWriter.WritePageAndRelease(pdfPage);
- pdfWriter.EndPDF();
-
-
-
-
-
-
-
-
-
-
- pdfWriter.ModifyPDF("c:\\myFile.pdf",ePDFVersion13,"", LogConfiguration(true,true,".\\logMe"));
- PDFModifiedPage pdfPage2(&pdfWriter,0);
- AbstractContentContext* contentContext = pdfPage2.StartContentContext();
- PDFFormXObject* image = pdfWriter.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.");
- }
- contentContext->q();
- contentContext->cm(0.4,0,0,0.4,57.5,241);
- contentContext->Do("oooogAAABooogggAAABoogggaaa");
-
- contentContext->Q();
- delete image;
-
-
- pdfPage2.EndContentContext();
- pdfPage2.WritePage();
-
- pdfWriter.EndPDF();
- }
|