FPDF_InitLibrary(NULL); /* CFX_FolderFontInfo sysfont; CFX_FontMapper fontmap; CFX_Font myfont; IFX_SystemFontInfo *isysfont = NULL; IFX_FontMapper *ifontmap = NULL; CFX_FontMgr fontmgr; fontmgr.InitFTLibrary(); fontmgr.m_pExtMapper = new CFX_FontMapper(); fontmgr.m_pExtMapper->m_pFontMgr = &fontmgr; */ FPDF_DOCUMENT outdoc; // string inpdf = "/home/lyd/work/gnpdf/441.pdf"; // outdoc = FPDF_CreateNewDocument(); // CPDF_Document* cpdf_doc_ = CPDFDocumentFromFPDFDocument(outdoc); // const CPDF_Font* stock_font = CPDF_Font::GetStockFont(cpdf_doc_, "sysfFS"); //SimSun // int type = stock_font->GetFontType(); // CPDF_Type3Font typefont; /* FPDF_PAGE page = FPDFPage_New(outdoc, 0, 612, 792); FPDF_PAGEOBJECT text_object1 = FPDFPageObj_NewTextObj(outdoc, "Arial", 12.0f); std::unique_ptr<unsigned short, pdfium::FreeDeleter> text1 = GetFPDFWideString(L"this is yignsdfsf"); FPDFText_SetText(text_object1, text1.get()); // FPDFPageObj_SetFillColor(text_object1, 0, 0, 255, 150) FPDFPageObj_Transform(text_object1, 1, 0, 0, 1, 200, 600); FPDFPage_InsertObject(page, text_object1); FPDFPage_GenerateContent(page); */ string filename2 = "/root/me.pdf"; int fp = open(filename2.c_str(), O_RDWR | O_CREAT); PdfToFdWriter writer; writer.version = 1; writer.dstFd = fp; writer.WriteBlock = &writeBlock; FPDF_SaveAsCopy(outdoc, &writer, FPDF_NO_INCREMENTAL); FPDF_DestroyLibrary();
来源:https://www.cnblogs.com/hshy/p/12185920.html