How to use below commands to have Duplex setting & Three Punch Hole setting into the postscript file?
PdfDocument document = new PdfDocument();
document.LoadFromFile("c:\\TestFile.pdf");
document.SaveToFile("c:\\TestFile.ps",FileFormat.POSTSCRIPT);
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.LoadFromFile("TestFile.pdf");
pdfDocument.PrintSettings.PrinterName = "Adobe PDF";
// Double-sided, horizontal printing.
pdfDocument.PrintSettings.Duplex = System.Drawing.Printing.Duplex.Horizontal;
pdfDocument.PrintSettings.PrintToFile("TestFile.ps");
pdfDocument.Print();using Spire.Additions.Qt;
using Spire.Pdf;
using Spire.Pdf.AutomaticFields;
using Spire.Pdf.Graphics;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace pdfSize
{
internal class HtmlPdf
{
public void toHtml()
{
StringBuilder htmlstringSb = new StringBuilder();
htmlstringSb.Append("<html><body><p>This is Test</p></body></html>");
// Create a MemoryStream to hold the generated PDF data
using (MemoryStream stream = new MemoryStream())
{
float top = 60;
float bottom = 50;
float left = 40;
float right = 20;
// Set the margins for the PDF document
PdfMargins margins = new PdfMargins(left, top, right, bottom);
// Set the path to the HTML converter plugins
HtmlConverter.PluginPath = @"D:\DeskTop\plugins-windows-x86\plugins";
// Convert the specified HTML content to PDF and write it to the MemoryStream
HtmlConverter.Convert(htmlstringSb.ToString(),
stream, false, 100 * 1000, new Size(1080, 1000),
margins, LoadHtmlType.SourceCode);
// Create a new PdfDocument object and load the converted PDF from the MemoryStream
PdfDocument doc1 = new PdfDocument();
doc1.LoadFromStream(stream);
// Draw page numbers on each page of the PDF document
// DrawPageNumber(doc, margin, 1, doc.Pages.Count);
AddpaagenotoPDFFile(doc1);
// Save the PDF document to a file named "result.pdf"
doc1.FileInfo.IncrementalUpdate = false;
doc1.SaveToFile(@"../../output/testresult23.pdf", FileFormat.PDF);
}
}
private void AddpaagenotoPDFFile(PdfDocument pdf)
{
string pagefilename = "page" + DateTime.Now.ToString();
//Create a true type font
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Times New Roman", 10f, FontStyle.Bold), true);
//Create a PdfPageNumberField instance
PdfPageNumberField pageNumber = new PdfPageNumberField();
//Create a PdfPageCountField instance
PdfPageCountField pageCount = new PdfPageCountField();
//Create a PdfCompositeField instance
PdfCompositeField compositeField = new PdfCompositeField(font, PdfBrushes.Black, "Page {0} of {1}", pageNumber, pageCount);
//Set the text alignment for the composite field
compositeField.StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
//Loop through the pages
for (int i = 0; i < pdf.Pages.Count; i++)
{
//Draw composite filed on each page
// compositeField.Draw(pdf.Pages[i].Canvas, pdf.Pages[i].Size.Width / 2 - 20, pdf.Pages[i].Size.Height - pdf.PageSettings.Margins.Top);
compositeField.Draw(pdf.Pages[i].Canvas, pdf.Pages[i].Size.Width / 2 - 35, 1);
}
}
}
}...
document.Print();
document.Dispose();
document.Close();