visual c++ - printing pdf file on printer using c++ -
in c++ application (dll) printing bitmaps without using print dialogue i.e. end code without prompting user select file. functionality working fine. trying implement method print existing pdf file on printer. exisiting function specific bitmaps, confused how can send pdf file printer. following working code
docinfo didocinfo = {0}; didocinfo.cbsize = sizeof( docinfo ); didocinfo.lpszdocname = l"printtest"; if( startdoc( memdc.getsafehdc(), &didocinfo ) > 0 ) { if( startpage( memdc.getsafehdc() ) > 0 ) { cbitmap bitmap; cimage frontimage; frontimage.load(_t("c:test.bmp")); bitmap.attach(frontimage.detach()); bitmap bm; bitmap.getbitmap(&bm); int w = bm.bmwidth; int h = bm.bmheight; // create memory device context cdc tempdc; tempdc.createcompatibledc(&memdc); cbitmap *pbmp = tempdc.selectobject(&bitmap); tempdc.setmapmode(memdc.getmapmode()); memdc.setstretchbltmode(halftone); memdc.stretchblt(0, 0, 994, 624, &tempdc, 0, 0, 994, 624, 13369376); endpage(memdc.getsafehdc()); } }
i unable find way pass pdf file instead of bitmap dc
a bitmap raw data accessible operating system. pdf files quite complicated beasts must parsed (difficult) , rendered (hard) if written scratch.
your best course of action using existing pdf access library (like mupdf) heavy lifting you. should either produce rasterization of pdf, or vector drawing commands sent gdi print. fortunately pdf (-1/a) not things can't mapped gdi; hardest part processing embedded fonts; if don't want rasterize them you'll have upload glyph data gdi context used printing.
Comments
Post a Comment