Rank: Newbie
Groups: Registered
Joined: 6/10/2020(UTC) Posts: 5  Location: Zedelgem Thanks: 1 times
|
We are having a small issue when printing our PDF files through the Pdfium library. There is often some text or other information that is printed towards the very bottom of a page, usually detailing where it was printed from and what version of our software was being used, but this text is cropped off. When printing the same pdf through Adobe or one of our other libraries, this text is displayed just fine, so it is not an issue with the printer itself. This same bottom text is also cropped out the same way on a page that is printed in Landscape, meaning it is cropped out prior to rotating the page for the printer. It is also cropped out prior to any scaling, as the text is still missing when printed without the PrintSizeMode set to ActualSize. How would I go about solving this issue? The code below is how we call the print event. The PrinterSettings are created much earlier elsewhere and are passed down to here. Code:PdfCommon.Initialize(PdfLicense.Key);
var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { PrinterSettings = settings };
if (settings.MinimumPage == 0)
{
pd.PrinterSettings.MinimumPage = 1;
}
if (settings.MaximumPage == 9999)
{
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;
}
PrintController printController = new StandardPrintController();
pd.PrintController = printController;
pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;
pd.Print();
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/10/2020(UTC) Posts: 5  Location: Zedelgem Thanks: 1 times
|
I have just sent a test PDF that showcases the issue to support.
Even when using PrintSizeMode.Fit, the text is still cropped out, so it doesn't seem to have anything to do with the actual area available on a page or any printer-related issues (as the same file printed through a PDF reader like Adobe or Edge prints just fine). We're required to use PrintSizeMode.ActualSize either way to ensure everything is printed in the correct place on the paper we supply to our printer.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
We could not reproduce the problem on any of our virtual and physical printers. We used your document and code below. May be the problem in this line of code: Code:var pd = new PdfPrintDocument(doc) { PrinterSettings = settings };
In our tests, we removed the PrinterSettings and, of course, used the PrintSizeMode.Fit. Code:private static void PrintDocument()
{
var doc = PdfDocument.Load(@"e:\58\Test File Pdfium.pdf");
var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
pd.PrinterSettings.MinimumPage = 1;
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;
PrintController printController = new StandardPrintController();
pd.PrintController = printController;
pd.PrintSizeMode = PrintSizeMode.Fit;
pd.AutoCenter = true;
pd.Print();
}
Edited by user Friday, June 12, 2020 11:38:04 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/10/2020(UTC) Posts: 5  Location: Zedelgem Thanks: 1 times
|
It is indeed true that PrintSizeMode.Fit prints the text correctly. I should have tested that more thoroughly earlier. However, this does not solve our issue, as we specifically do not want the pdf to be scaled down to fit. We absolutely must have the actual size printed, and while this proves to be no issue for other print-tools such as Microsoft Edge or Adobe Acrobat Reader, it strangely does not work with Pdfium. It also does not seem to be an issue with our printersettings, as commenting them out changes nothing of the end result. Below is a picture I took of the issue, as well as the code used for each page.  IMG_20200615_115223.jpg (44kb) downloaded 2 time(s).Left page: Code:
var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
pd.PrinterSettings.MinimumPage = 1;
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;
PrintController printController = new StandardPrintController();
pd.PrintController = printController;
pd.PrintSizeMode = PrintSizeMode.Fit;
pd.AutoCenter = true;
pd.Print();
Middle page (text is cropped off): Code:
var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
pd.PrinterSettings.MinimumPage = 1;
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;
PrintController printController = new StandardPrintController();
pd.PrintController = printController;
pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;
pd.Print();
Right page (what we want to see): Printed through Adobe Acrobat Reader, with "Actual Size" option set.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
The page size is 8.27x11.69 inches, What about PrintableArea and/or PageSize in your printer settings?
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/10/2020(UTC) Posts: 5  Location: Zedelgem Thanks: 1 times
|
The pd.PrinterSettings.DefaultPageSettings.PrintableArea for the default PrinterSettings (so with our own still commented out, as in the previous reply) appears to be X = 16.666666, Y = 19.666666, Width = 793.3333, Height = 1129.83337 Both height and width do appear to be a little lower than the page size, which is the same as you said, 8.27 x 11.69 inches, but the difference doesn't seem large enough to cause this issue. I will see if I can adjust this value and what the result is then. It's clear that our printer is fully capable of printing said text with for example Adobe Acrobat Reader, so is there a chance the PrintableArea is misinterpreted somehow by Pdfium? Edited by user Monday, June 15, 2020 8:04:41 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
Originally Posted by: Senne  The pd.PrinterSettings.DefaultPageSettings.PrintableArea for the default PrinterSettings (so with our own still commented out, as in the previous reply) appears to be X = 16.666666, Y = 19.666666, Width = 793.3333, Height = 1129.83337 PrintableArea is 7.93x11.29 inches. The printer cannot print outside this area. https://docs.microsoft.c...view=dotnet-plat-ext-3.1Quote:A RectangleF representing the length and width, in hundredths of an inch, of the area the printer is capable of printing in. Quote:You can use this property to print outside the margins of the page, but within the printable area. Currently I don't know how Adobe do that. Edited by user Monday, June 15, 2020 9:00:04 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/10/2020(UTC) Posts: 5  Location: Zedelgem Thanks: 1 times
|
I've double checked with Word to make sure that the text is within the printable area, and it absolutely is. The image below is the printable area as shown in Word (by first setting the margins to 0 and then hitting "Fix" on the warning). The math also checks out, the A4 width/height - the margins = 7.93x11.29. The PDF at actual size is shown to clearly be within those bounds.  pdfiumissue.png (13kb) downloaded 4 time(s).The PDF prints perfectly fine at actual size using: - Microsoft Edge - Adobe Acrobat Reader - PdfPrintingNet, a different NuGet library The issue only presents itself using Pdfium out of the various methods I've tried, so surely there's a problem somewhere? Edited by user Monday, June 15, 2020 9:26:14 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 963
Thanks: 3 times Was thanked: 115 time(s) in 112 post(s)
|
Fixed! Please update to the latest version (4.29.2704) You can print the document in this way Code:pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;
pd.Print();
or this Code:pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.OriginAtMargins = true;
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.Print();
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close