12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #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");
-
-
-
-
-
-
- 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.Shutdown("c:\\myFile.pdf.shutdown");
- PDFWriter pdfWriterB;
- pdfWriterB.ContinuePDF("c:\\myFile.pdf","myFile.pdf.shutdown","",LogConfiguration(true,true,".\\logMe"));
- PDFPage* pdfPageB = new PDFPage();
-
- pdfPageB->SetMediaBox(PDFRectangle(0,0,595,842));
- PageContentContext* pageContentContextB = pdfWriterB.StartPageContentContext(pdfPageB);
- 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.");
- }
- pageContentContextB->q();
- pageContentContextB->cm(0.4,0,0,0.4,57.5,241);
- pageContentContextB->Do(pdfPageB->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID()));
- pageContentContextB->Q();
- delete image;
-
-
- pdfWriterB.EndPageContentContext(pageContentContextB);
- EStatusCode f = pdfWriterB.WritePageAndRelease(pdfPageB);
- if (f){
- printf ("something interesting");
- }
- pdfWriterB.EndPDF();
- }
|