[英]How to save a PDF using Graphics.DrawString in C#?
我有用於打印預覽的Graphics.DrawString
方法。
現在,我想使用相同的代碼將其另存為PDF。 我有一個表格,我創建了一個printprewiew,我想將其保存在printPrview到pdf中。
有可能這樣做嗎?
我有一個可能會對您有所幫助的解決方案,但它需要下載並安裝“ CutePDF Writer”。 CutePDF Writer是免費軟件。 您可以從那里的官方網站下載。
PrintDialog pDia = New PrintDialog()
PrinterSettings ps = New PrinterSettings()
pDia.Document = PrintDocument1
pDia.Document.DocumentName = "Your File Name"
ps.PrinterName = item.ToString()
ps.PrintToFile = False
//Create folder inside Bin folder to save PDFs
String strReportBackupPath = "C:\\"
String strFilePath = strReportBackupPath & "\\" & pDia.Document.DocumentName & ".pdf"
//To avoid the replace dialog of cutePDF - To save new file if have same name
ps.PrintFileName = strFilePath
PrintDocument1.PrinterSettings = ps
PrintDocument1.Print()
但是會顯示另存為對話框,將文件保存為pdf。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.