In fact this works:
Code: Select all
dc = GetDC_(GadgetID(#MyCanvas))
It also works if rendering directly on the ScrollArea, but again the render is lost if the ScrollArea is scrolled.
So, based on this knowledge, I went back to rendering directly on the Window (as a test, most times that would not be enough). However, if the Window is re-sized after the render (mouse drag edge), the render is lost....
Code: Select all
Global sgPDF.s = "C:\EGG COOKER user guide.pdf"
Prototype protoInitLibrary()
Prototype protoLoadDocument(documentpath.p-utf8,password.p-utf8)
Prototype protoGetPageCount(document)
Prototype protoRenderPage(hDC, page, start_x, start_y, size_x, size_y, rotate, flags);As "_FPDF_RenderPage@32
Prototype protoLoadPage(document, page_index) ;"_FPDF_LoadPage@8"
Procedure Main(*win)
Protected pdf_dll =OpenLibrary(#PB_Any, "pdfium.dll")
Protected InitLibrary.protoInitLibrary = GetFunction(pdf_dll,"_FPDF_InitLibrary@0")
Protected GetPageCount.protoGetPageCount = GetFunction(pdf_dll,"_FPDF_GetPageCount@4")
Protected LoadDocument.protoLoadDocument = GetFunction(pdf_dll,"_FPDF_LoadDocument@8")
Protected RenderPage.protoRenderPage = GetFunction(pdf_dll,"_FPDF_RenderPage@32")
Protected LoadPage.protoLoadPage = GetFunction(pdf_dll,"_FPDF_LoadPage@8")
InitLibrary()
Protected pdf_doc = LoadDocument(sgPDF, "")
Protected pdf_page = LoadPage(pdf_doc, 0)
RenderPage(GetDC_(WindowID(*win)), pdf_page, 0, 0, 794, 1123, 0, $100);
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
CloseLibrary(pdf_dll)
EndProcedure
Define iFlags.i = #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_SizeGadget
Main(OpenWindow(#PB_Any, 0, 0, 800, 640, "Pdfium", iFlags))