Hello support team,
I want to save a pdf file as a bitmap.
Code
void __fastcall TfrmMain::SaveAsBitmap()
{
Graphics::TBitmap *bit = new Graphics::TBitmap;
int w, h, resx = 100, resy = 100, pageno;
HDC DC;
TJPEGImage* jpeg;
pageno = WPViewPDF->Page;
w = WPViewPDF->CommandEx(COMPDF_GetPageWidth, 1);
h = WPViewPDF->CommandEx(COMPDF_GetPageHeight, 1);
WPViewPDF->CommandEx(COMPDF_PrintHDCSetXRes, resx);
WPViewPDF->CommandEx(COMPDF_PrintHDCSetYRes, resy);
WPViewPDF->CommandEx(160, pageno); // Select Page number
bit->Width = MulDiv(w, resx, 72);
bit->Height = MulDiv(h, resy, 72);
DC = bit->Canvas->Handle;
Rectangle(DC, 0, 0, bit->Width - 1, bit->Height - 1);
WPViewPDF->CommandEx(161, Integer(DC));
jpeg = new TJPEGImage;
jpeg->Assign(bit);
bit->SaveToFile("C:\\test.bmp");
jpeg->SaveToFile("C:\\test.jpg");
jpeg->Free();
bit->Free();
}
Alles anzeigen
Now i started to open a file to the WPViewPDF and call the function. The file will be created, but it is only an empty page.
Can anybody help me? Where is my mistake?
Thank you very much.
Greetings,
Testuser