HDC Transfer to PostScript PDF

Source: Internet
Author: User
Software: PDF printer software such as Pdfcreater or PrimoPDF or Bullzip PDF Printer. Ghostscript 9.10
HDC to ps:1. Use the printer name to create the HDC. 2. StartDoc (), set the PS file path name.
PS to PDF: Call Ghostscript's ps2pdf.bat. Note: You may be prompted to find "Gswin32c.exe" when you call. Place the path where it is located.
Example code:
void Hdc2pdf_demo (const cstring& strpsfilename = _t ("c:\\postscript.ps"), const cstring& strpdffilename= _T ("C:\\postscript.pdf"), const cstring& strprintername= _t ("PrimoPDF"),//printer name, from "Control Panel/printer and fax const Cstrin" g& Strhelloworld = _t ("Hello world!!!"))
	{///1. HDC, POSTSCRIPT///1.1. Use the printer name to create the HDC.
	
	HDC HDC =:: CreateDC (NULL, Strprintername, null,null); 1.2.
	StartDoc (), set the PS file path name.
	DocInfo docinfo={0};
	docinfo.cbsize = sizeof (DocInfo);
	
	Docinfo.lpszoutput = Strpsfilename;
	:: StartDoc (HDC, &docinfo);
	
	:: StartPage (HDC);
	
	TextOut (HDC, $, Strhelloworld, Strhelloworld.getlength ());
	:: EndPage (HDC);
	:: EndDoc (HDC);
	
	::D Eletedc (HDC); 2.
	PostScript--PDF CString strparameters; Strparameters.format (_t ("-q-p--dsafer-dnopause-dbatch-sdevice=pdfwrite-soutputfile=%s-dcompatibilitylevel=1.4-
	C. setpdfwrite-f%s "), Strpdffilename, strpsfilename);
	Shellexecuteinfo Shexecinfo = {0}; Shexecinfo.cbsize = sizeof (SHELLEXECUTEINFO);
	Shexecinfo.fmask = see_mask_nocloseprocess;
	Shexecinfo.hwnd = NULL;
	Shexecinfo.lpverb = NULL;
	Shexecinfo.lpfile = _t ("Gswin32c.exe");
	Shexecinfo.lpparameters = strparameters;
	Shexecinfo.nshow = Sw_hide;
	Shexecinfo.hinstapp = NULL;
	ShellExecuteEx (&shexecinfo);
WaitForSingleObject (Shexecinfo.hprocess,infinite); }



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.