.NET Core Exact Dimension PDF Printer
Budget: €30 – €250 EUR
"C# .NET Core PDF Printing Service (Exact Size, No Scaling) for Windows"
Project Description
Develop a C# .NET Core class/service that prints PDFs at their exact dimensions (no scaling/distortion) on any Windows-supported printer. The solution must:
Accept a PDF file path and printer name.
Auto-detect the PDF’s page size (in millimeters).
Configure the printer temporarily to match the PDF’s dimensions.
Handle printer limitations (margins, unsupported sizes).
Requirements
Deliverables:
A C# class/service (e.g., PdfPrintService.cs) with a method:
public bool PrintPdf(string pdfPath, string printerName);
Optional helper class to detect PDF dimensions (e.g., PdfSizeReader.cs).
Test PDFs will be provided for testing with non-standard sizes (e.g., 132x96 mm, 340x110 mm).
Technical Constraints:
Target .NET Core 7/8 (cross-platform, but Windows-only for printing).
No third-party PDF libraries (unless open-source and MIT license).
Key Features:
Precision: Match PDF dimensions exactly (1:1).
Centering: Content centered if hardware margins allow.
Error Handling: Clear exceptions for unsupported sizes.
Skills Required
Expertise in C# .NET Core and Windows printing APIs.
Experience with PDF metadata extraction (e.g., page size in mm).
Knowledge of printer configuration (custom paper sizes).
Example Code Structure
using System.Drawing.Printing;
using PdfSharp.Pdf; // Example with PDFSharp (open-source)
public class PdfPrintService
{
public bool PrintPdf(string pdfPath, string printerName)
{
// 1. Get PDF dimensions
var (widthMm, heightMm) = GetPdfSize(pdfPath);
// 2. Configure printer
var settings = new PrinterSettings
{
PrinterName = printerName,
DefaultPageSettings = new PageSettings
{
PaperSize = CreateCustomPaperSize(widthMm, heightMm),
Margins = new Margins(0, 0, 0, 0) // Minimize margins
}
};
// 3. Print
using var document = new PdfDocument(pdfPath);
// ... (implement printing logic)
return true;
}
private PaperSize CreateCustomPaperSize(float widthMm, float heightMm)
{
// Convert mm to hundredths of inches (1 inch = 25.4 mm)
int widthHundredthsInch = (int)(widthMm / 25.4 * 100);
int heightHundredthsInch = (int)(heightMm / 25.4 * 100);
return new PaperSize("Custom", widthHundredthsInch, heightHundredthsInch);
}
}
Testing Criteria
Test 1 – Exact Dimensions:
Print a 132x96 mm PDF and measure the output with calipers.
Test 2 – Printer Agnostic:
Verify compatibility with 2+ printers (e.g., HP LaserJet, Brother).
Budget & Timeline
Budget: Fixed price (specify in proposal).
Deadline: 7 days after acceptance.
Submission Guidelines
Proposal Must Include:
Approach to extract PDF dimensions (library or custom code).
Strategy to handle printer margins.
Example of printing logic (pseudo-code or snippet).
Exclude: Proposals relying on paid libraries (e.g., Adobe Acrobat SDK).
Project Description
Develop a C# .NET Core class/service that prints PDFs at their exact dimensions (no scaling/distortion) on any Windows-supported printer. The solution must:
Accept a PDF file path and printer name.
Auto-detect the PDF’s page size (in millimeters).
Configure the printer temporarily to match the PDF’s dimensions.
Handle printer limitations (margins, unsupported sizes).
Requirements
Deliverables:
A C# class/service (e.g., PdfPrintService.cs) with a method:
public bool PrintPdf(string pdfPath, string printerName);
Optional helper class to detect PDF dimensions (e.g., PdfSizeReader.cs).
Test PDFs will be provided for testing with non-standard sizes (e.g., 132x96 mm, 340x110 mm).
Technical Constraints:
Target .NET Core 7/8 (cross-platform, but Windows-only for printing).
No third-party PDF libraries (unless open-source and MIT license).
Key Features:
Precision: Match PDF dimensions exactly (1:1).
Centering: Content centered if hardware margins allow.
Error Handling: Clear exceptions for unsupported sizes.
Skills Required
Expertise in C# .NET Core and Windows printing APIs.
Experience with PDF metadata extraction (e.g., page size in mm).
Knowledge of printer configuration (custom paper sizes).
Example Code Structure
using System.Drawing.Printing;
using PdfSharp.Pdf; // Example with PDFSharp (open-source)
public class PdfPrintService
{
public bool PrintPdf(string pdfPath, string printerName)
{
// 1. Get PDF dimensions
var (widthMm, heightMm) = GetPdfSize(pdfPath);
// 2. Configure printer
var settings = new PrinterSettings
{
PrinterName = printerName,
DefaultPageSettings = new PageSettings
{
PaperSize = CreateCustomPaperSize(widthMm, heightMm),
Margins = new Margins(0, 0, 0, 0) // Minimize margins
}
};
// 3. Print
using var document = new PdfDocument(pdfPath);
// ... (implement printing logic)
return true;
}
private PaperSize CreateCustomPaperSize(float widthMm, float heightMm)
{
// Convert mm to hundredths of inches (1 inch = 25.4 mm)
int widthHundredthsInch = (int)(widthMm / 25.4 * 100);
int heightHundredthsInch = (int)(heightMm / 25.4 * 100);
return new PaperSize("Custom", widthHundredthsInch, heightHundredthsInch);
}
}
Testing Criteria
Test 1 – Exact Dimensions:
Print a 132x96 mm PDF and measure the output with calipers.
Test 2 – Printer Agnostic:
Verify compatibility with 2+ printers (e.g., HP LaserJet, Brother).
Budget & Timeline
Budget: Fixed price (specify in proposal).
Deadline: 7 days after acceptance.
Submission Guidelines
Proposal Must Include:
Approach to extract PDF dimensions (library or custom code).
Strategy to handle printer margins.
Example of printing logic (pseudo-code or snippet).
Exclude: Proposals relying on paid libraries (e.g., Adobe Acrobat SDK).